1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-20 14:54:15 +01:00

(bug) cannot show event reservation success info

This commit is contained in:
Du Peng 2023-07-12 14:46:30 +02:00
parent 3b5e087b7a
commit a2a970cba4
3 changed files with 19 additions and 10 deletions

View File

@ -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;

View File

@ -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

View File

@ -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)