From 25d8b258087bd2431914dbb368403c2d17e30c49 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Wed, 12 Jul 2023 11:23:00 +0200 Subject: [PATCH 1/5] (feat) add reservation status registered --- app/frontend/templates/admin/events/reservations.html | 3 ++- config/locales/app.admin.en.yml | 1 + config/locales/app.admin.fr.yml | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/frontend/templates/admin/events/reservations.html b/app/frontend/templates/admin/events/reservations.html index 44f7392ef..5d747bbd2 100644 --- a/app/frontend/templates/admin/events/reservations.html +++ b/app/frontend/templates/admin/events/reservations.html @@ -48,7 +48,8 @@ {{ 'app.admin.event_reservations.event_status.pre_registered' }} - {{ 'app.admin.event_reservations.event_status.to_pay' }} + {{ 'app.admin.event_reservations.event_status.to_pay' }} + {{ 'app.admin.event_reservations.event_status.registered' }} {{ 'app.admin.event_reservations.event_status.paid' }} {{ 'app.admin.event_reservations.event_status.present' }} {{ 'app.admin.event_reservations.event_status.canceled' }} diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml index 63d082b5e..47b95d2d8 100644 --- a/config/locales/app.admin.en.yml +++ b/config/locales/app.admin.en.yml @@ -654,6 +654,7 @@ en: paid: "Paid" canceled: "Canceled" present: "Present" + registered: "Registered" affirmative: "yes" negative: "no" validate: "Validate" diff --git a/config/locales/app.admin.fr.yml b/config/locales/app.admin.fr.yml index 709e68ae4..ec0b5cdae 100644 --- a/config/locales/app.admin.fr.yml +++ b/config/locales/app.admin.fr.yml @@ -654,6 +654,7 @@ fr: paid: "Payé" canceled: "Annulée" present: "Présent" + registered: "Inscrit" affirmative: "Oui" negative: "Non" validate: "Valider" From e8228ce48ff8d34a63148d989e8001b7f8682e0f Mon Sep 17 00:00:00 2001 From: Du Peng Date: Wed, 12 Jul 2023 12:26:49 +0200 Subject: [PATCH 2/5] (bug) event cannot update nb of free places --- app/models/event.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index af039ca81..0cfd546cb 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -87,11 +87,9 @@ class Event < ApplicationRecord if nb_total_places.nil? self.nb_free_places = nil else - reserved_places = reservations.joins(:slots_reservations) - .where('slots_reservations.canceled_at': nil) - .where('slots_reservations.is_valid': true) - .map(&:total_booked_seats) - .inject(0) { |sum, t| sum + t } + reserved = reservations.joins(:slots_reservations).where('slots_reservations.canceled_at': nil) + reserved = reserved.where('slots_reservations.is_valid': true) if pre_registration? + reserved_places = reserved.map(&:total_booked_seats).inject(0) { |sum, t| sum + t } self.nb_free_places = (nb_total_places - reserved_places) end end From 3b5e087b7a921086b18698bff039e1255c90d3c2 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Wed, 12 Jul 2023 12:47:35 +0200 Subject: [PATCH 3/5] (feat) family compte setting in panel --- .../templates/admin/settings/compte.html | 54 +++++++++++-------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/app/frontend/templates/admin/settings/compte.html b/app/frontend/templates/admin/settings/compte.html index 7be0fb820..241196c69 100644 --- a/app/frontend/templates/admin/settings/compte.html +++ b/app/frontend/templates/admin/settings/compte.html @@ -51,29 +51,6 @@ -
-

{{ 'app.admin.settings.family_account' }}

-

-
- -
-
- -
-
-
-
- -
-

{{ 'app.admin.settings.captcha' }}

@@ -97,6 +74,37 @@
+ +
+
+ {{ 'app.admin.settings.family_account' }} +
+
+
+

+
+ +
+
+ +
+
+
+
+ +
+
+
+
+
{{ 'app.admin.settings.accounts_management' }} From a2a970cba4399f9b053e970c1de6d491a2d51721 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Wed, 12 Jul 2023 14:46:30 +0200 Subject: [PATCH 4/5] (bug) cannot show event reservation success info --- .../src/javascript/controllers/events.js.erb | 24 +++++++++++-------- app/models/slot.rb | 4 ++++ app/services/slots/reservations_service.rb | 1 + 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/app/frontend/src/javascript/controllers/events.js.erb b/app/frontend/src/javascript/controllers/events.js.erb index eceaacc9f..8117807a1 100644 --- a/app/frontend/src/javascript/controllers/events.js.erb +++ b/app/frontend/src/javascript/controllers/events.js.erb @@ -360,9 +360,10 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', ' if ($scope.ctrl.member) { Member.get({ id: $scope.ctrl.member.id }, function (member) { $scope.ctrl.member = member; - getReservations($scope.event.id, 'Event', $scope.ctrl.member.id); - getChildren($scope.ctrl.member.id).then(() => { - updateNbReservePlaces(); + getReservations($scope.event.id, 'Event', $scope.ctrl.member.id).then(function (reservations) { + getChildren($scope.currentUser.id).then(function (children) { + updateNbReservePlaces(); + }); }); }); } @@ -441,8 +442,10 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', ' let index; growl.success(_t('app.public.events_show.reservation_was_successfully_cancelled')); index = $scope.reservations.indexOf(reservation); - $scope.event.nb_free_places = $scope.event.nb_free_places + reservation.total_booked_seats; $scope.reservations[index].slots_reservations_attributes[0].canceled_at = new Date(); + Event.get({ id: $scope.event.id }).$promise.then(function (event) { + $scope.event = event; + }); }, function(error) { growl.warning(_t('app.public.events_show.cancellation_failed')); }); @@ -985,13 +988,14 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', ' * @param invoice {Object} the invoice for the booked reservation */ const afterPayment = function (invoice) { - Reservation.get({ id: invoice.main_object.id }, function (reservation) { - $scope.event.nb_free_places = $scope.event.nb_free_places - reservation.total_booked_seats; - $scope.reservations.push(reservation); + Event.get({ id: $scope.event.id }).$promise.then(function (event) { + $scope.event = event; + getReservations($scope.event.id, 'Event', $scope.ctrl.member.id).then(function (reservations) { + updateNbReservePlaces(); + $scope.reserveSuccess = true; + $scope.coupon.applied = null; + }); resetEventReserve(); - updateNbReservePlaces(); - $scope.reserveSuccess = true; - $scope.coupon.applied = null; }); if ($scope.currentUser.role === 'admin') { return $scope.ctrl.member = null; diff --git a/app/models/slot.rb b/app/models/slot.rb index 673b6a306..650448b84 100644 --- a/app/models/slot.rb +++ b/app/models/slot.rb @@ -17,6 +17,10 @@ class Slot < ApplicationRecord # @param reservable [Machine,Space,Training,Event,NilClass] # @return [Integer] the total number of reserved places def reserved_places(reservable = nil) + p '-----------' + p id + p places + p reservable if reservable.nil? places.pluck('reserved_places').reduce(:+) else diff --git a/app/services/slots/reservations_service.rb b/app/services/slots/reservations_service.rb index fcdc87082..913764bf1 100644 --- a/app/services/slots/reservations_service.rb +++ b/app/services/slots/reservations_service.rb @@ -19,6 +19,7 @@ class Slots::ReservationsService .where('reservations.reservable_type': reservable_types) .where('reservations.reservable_id': reservables.map { |r| r.try(:id) }) .where('slots_reservations.canceled_at': nil) + reservations = reservations.where('slots_reservations.is_valid': true) if reservables.first&.pre_registration? user_ids = reservations.includes(reservation: :statistic_profile) .map(&:reservation) From aa6aab48b28d4361b9a2bdbad953b1014555487d Mon Sep 17 00:00:00 2001 From: Du Peng Date: Wed, 12 Jul 2023 15:07:14 +0200 Subject: [PATCH 5/5] (feat) admin cannot validate pre-registration > nb total places --- app/frontend/src/javascript/controllers/admin/events.js | 8 +++++++- app/frontend/templates/admin/events/reservations.html | 4 ++-- app/models/slot.rb | 4 ---- app/services/slots/places_cache_service.rb | 6 +++++- app/services/slots_reservations_service.rb | 2 ++ 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/frontend/src/javascript/controllers/admin/events.js b/app/frontend/src/javascript/controllers/admin/events.js index d1288f4f2..02b19a1d4 100644 --- a/app/frontend/src/javascript/controllers/admin/events.js +++ b/app/frontend/src/javascript/controllers/admin/events.js @@ -436,7 +436,7 @@ Application.Controllers.controller('AdminEventsController', ['$scope', '$state', /** * Controller used in the reservations listing page for a specific event */ -Application.Controllers.controller('ShowEventReservationsController', ['$scope', 'eventPromise', 'reservationsPromise', 'dialogs', 'SlotsReservation', 'growl', '_t', 'Price', 'Wallet', '$uibModal', function ($scope, eventPromise, reservationsPromise, dialogs, SlotsReservation, growl, _t, Price, Wallet, $uibModal) { +Application.Controllers.controller('ShowEventReservationsController', ['$scope', 'eventPromise', 'reservationsPromise', 'dialogs', 'SlotsReservation', 'growl', '_t', 'Price', 'Wallet', '$uibModal', 'Event', function ($scope, eventPromise, reservationsPromise, dialogs, SlotsReservation, growl, _t, Price, Wallet, $uibModal, Event) { // retrieve the event from the ID provided in the current URL $scope.event = eventPromise; @@ -472,6 +472,9 @@ Application.Controllers.controller('ShowEventReservationsController', ['$scope', growl.success(_t('app.admin.event_reservations.reservation_was_successfully_validated')); const index = $scope.reservations.indexOf(reservation); $scope.reservations[index].slots_reservations_attributes[0].is_valid = true; + Event.get({ id: $scope.event.id }).$promise.then(function (event) { + $scope.event = event; + }); }, () => { growl.warning(_t('app.admin.event_reservations.validation_failed')); }); @@ -488,6 +491,9 @@ Application.Controllers.controller('ShowEventReservationsController', ['$scope', growl.success(_t('app.admin.event_reservations.reservation_was_successfully_invalidated')); const index = $scope.reservations.indexOf(reservation); $scope.reservations[index].slots_reservations_attributes[0].is_valid = false; + Event.get({ id: $scope.event.id }).$promise.then(function (event) { + $scope.event = event; + }); }, () => { growl.warning(_t('app.admin.event_reservations.invalidation_failed')); }); diff --git a/app/frontend/templates/admin/events/reservations.html b/app/frontend/templates/admin/events/reservations.html index 5d747bbd2..ea5f3d8c7 100644 --- a/app/frontend/templates/admin/events/reservations.html +++ b/app/frontend/templates/admin/events/reservations.html @@ -59,11 +59,11 @@