From da71ba783c6b2ab35d6d5fc4ea7afe76450079c3 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 9 Nov 2016 15:01:41 +0100 Subject: [PATCH] [bug] exports for events reservation always have seats=1 (fixes #54) --- CHANGELOG.md | 2 ++ app/controllers/api/exports_controller.rb | 6 +++++- app/views/exports/users_reservations.xlsx.axlsx | 2 +- config/locales/en.yml | 1 + config/locales/fr.yml | 1 + 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ff7531a5..b87e5a735 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,10 @@ ## next release +- Fix a bug: number of reserved seats for an event is always of 1 in the excel export of reservations - Fix a bug: conflict between similar translations around "reservations" - Fix a bug: later occurrences of recurrent events does not have the initially configured theme and age range +- [TODO DEPLOY] delete the `exports/users/reservations` folder to prevent the usage of old invalid exports ## v2.4.2 2016 November 8 diff --git a/app/controllers/api/exports_controller.rb b/app/controllers/api/exports_controller.rb index 0ec8dff1c..69a204d99 100644 --- a/app/controllers/api/exports_controller.rb +++ b/app/controllers/api/exports_controller.rb @@ -5,7 +5,11 @@ class API::ExportsController < API::ApiController def download authorize @export - send_file File.join(Rails.root, @export.file), :type => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', :disposition => 'attachment' + if FileTest.exist?(@export.file) + send_file File.join(Rails.root, @export.file), :type => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', :disposition => 'attachment' + else + render text: I18n.t('errors.messages.export_not_found'), status: :not_found + end end def status diff --git a/app/views/exports/users_reservations.xlsx.axlsx b/app/views/exports/users_reservations.xlsx.axlsx index 54bbb0e90..98a56b8c4 100644 --- a/app/views/exports/users_reservations.xlsx.axlsx +++ b/app/views/exports/users_reservations.xlsx.axlsx @@ -21,7 +21,7 @@ wb.add_worksheet(name: t('export_reservations.reservations')) do |sheet| resrv.created_at.to_date, resrv.reservable_type, (resrv.reservable.nil? ? '' : resrv.reservable.name), - resrv.slots.count, + (resrv.reservable_type == 'Event') ? resrv.total_booked_seats: resrv.slots.count, (resrv.stp_invoice_id.nil?)? t('export_reservations.local_payment') : t('export_reservations.online_payment') ] styles = [nil, nil, nil, date, nil, nil, nil, nil] diff --git a/config/locales/en.yml b/config/locales/en.yml index f4dec8b83..557404a50 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -31,6 +31,7 @@ en: wrong_size: "is the wrong size (should be %{file_size})" size_too_small: "is too small (should be at least %{file_size})" size_too_big: "is too big (should be at most %{file_size})" + export_not_found: "Requested export was not found. It was probably deleted, please generate a new export." activemodel: errors: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 1b6629cc1..cd3fb70bb 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -31,6 +31,7 @@ fr: wrong_size: "ne fait pas la taille du fichier (doit comporter %{file_size})" size_too_small: "est trop petite (au moins %{file_size})" size_too_big: "est trop grande (pas plus de %{file_size})" + export_not_found: "L'export demandé n'a pas été trouvé. Il a probablement été supprimé, veuillez lancer la génération d'un nouvel export." activemodel: errors: