mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-30 19:52:20 +01:00
(feat) admin cannot validate pre-registration > nb total places
This commit is contained in:
parent
a2a970cba4
commit
aa6aab48b2
@ -436,7 +436,7 @@ Application.Controllers.controller('AdminEventsController', ['$scope', '$state',
|
|||||||
/**
|
/**
|
||||||
* Controller used in the reservations listing page for a specific event
|
* 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
|
// retrieve the event from the ID provided in the current URL
|
||||||
$scope.event = eventPromise;
|
$scope.event = eventPromise;
|
||||||
|
|
||||||
@ -472,6 +472,9 @@ Application.Controllers.controller('ShowEventReservationsController', ['$scope',
|
|||||||
growl.success(_t('app.admin.event_reservations.reservation_was_successfully_validated'));
|
growl.success(_t('app.admin.event_reservations.reservation_was_successfully_validated'));
|
||||||
const index = $scope.reservations.indexOf(reservation);
|
const index = $scope.reservations.indexOf(reservation);
|
||||||
$scope.reservations[index].slots_reservations_attributes[0].is_valid = true;
|
$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'));
|
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'));
|
growl.success(_t('app.admin.event_reservations.reservation_was_successfully_invalidated'));
|
||||||
const index = $scope.reservations.indexOf(reservation);
|
const index = $scope.reservations.indexOf(reservation);
|
||||||
$scope.reservations[index].slots_reservations_attributes[0].is_valid = false;
|
$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'));
|
growl.warning(_t('app.admin.event_reservations.invalidation_failed'));
|
||||||
});
|
});
|
||||||
|
@ -59,11 +59,11 @@
|
|||||||
<div ng-if="!isCancelled(reservation) && !reservation.is_paid">
|
<div ng-if="!isCancelled(reservation) && !reservation.is_paid">
|
||||||
<label class="m-r-sm">
|
<label class="m-r-sm">
|
||||||
<span translate>{{ 'app.admin.event_reservations.negative' }}</span>
|
<span translate>{{ 'app.admin.event_reservations.negative' }}</span>
|
||||||
<input type="radio" name="validate" ng-value="false" ng-click="invalidateReservation(reservation)" ng-model="reservation.slots_reservations_attributes[0].is_valid" >
|
<input type="radio" name="invalidate-{{reservation.id}}" ng-value="false" ng-click="invalidateReservation(reservation)" ng-model="reservation.slots_reservations_attributes[0].is_valid" ng-disabled="reservation.total_booked_seats > event.nb_free_places && !reservation.slots_reservations_attributes[0].is_valid">
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span translate>{{ 'app.admin.event_reservations.affirmative' }}</span>
|
<span translate>{{ 'app.admin.event_reservations.affirmative' }}</span>
|
||||||
<input type="radio" name="validate" ng-value="true" ng-click="validateReservation(reservation)" ng-model="reservation.slots_reservations_attributes[0].is_valid" >
|
<input type="radio" name="validate-{{reservation.id}}" ng-value="true" ng-click="validateReservation(reservation)" ng-model="reservation.slots_reservations_attributes[0].is_valid" ng-disabled="reservation.total_booked_seats > event.nb_free_places && !reservation.slots_reservations_attributes[0].is_valid" >
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-default" ng-click="payReservation(reservation)" ng-if="isValidated(reservation) && !isCancelled(reservation) && !reservation.is_paid">
|
<button class="btn btn-default" ng-click="payReservation(reservation)" ng-if="isValidated(reservation) && !isCancelled(reservation) && !reservation.is_paid">
|
||||||
|
@ -17,10 +17,6 @@ class Slot < ApplicationRecord
|
|||||||
# @param reservable [Machine,Space,Training,Event,NilClass]
|
# @param reservable [Machine,Space,Training,Event,NilClass]
|
||||||
# @return [Integer] the total number of reserved places
|
# @return [Integer] the total number of reserved places
|
||||||
def reserved_places(reservable = nil)
|
def reserved_places(reservable = nil)
|
||||||
p '-----------'
|
|
||||||
p id
|
|
||||||
p places
|
|
||||||
p reservable
|
|
||||||
if reservable.nil?
|
if reservable.nil?
|
||||||
places.pluck('reserved_places').reduce(:+)
|
places.pluck('reserved_places').reduce(:+)
|
||||||
else
|
else
|
||||||
|
@ -30,10 +30,14 @@ class Slots::PlacesCacheService
|
|||||||
reservations = Slots::ReservationsService.reservations(slot.slots_reservations, [reservable])
|
reservations = Slots::ReservationsService.reservations(slot.slots_reservations, [reservable])
|
||||||
pending = Slots::ReservationsService.pending_reservations(slot.cart_item_reservation_slots.map(&:id), [reservable])
|
pending = Slots::ReservationsService.pending_reservations(slot.cart_item_reservation_slots.map(&:id), [reservable])
|
||||||
|
|
||||||
|
reserved_places = (reservations[:reservations].count || 0) + (pending[:reservations].count || 0)
|
||||||
|
if slot.availability.available_type == 'event'
|
||||||
|
reserved_places = slot.availability.event.nb_total_places - slot.availability.event.nb_free_places
|
||||||
|
end
|
||||||
places.push({
|
places.push({
|
||||||
reservable_type: reservable.class.name,
|
reservable_type: reservable.class.name,
|
||||||
reservable_id: reservable.try(&:id),
|
reservable_id: reservable.try(&:id),
|
||||||
reserved_places: (reservations[:reservations].count || 0) + (pending[:reservations].count || 0),
|
reserved_places: reserved_places,
|
||||||
user_ids: reservations[:user_ids] + pending[:user_ids]
|
user_ids: reservations[:user_ids] + pending[:user_ids]
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -29,6 +29,7 @@ class SlotsReservationsService
|
|||||||
reservable.update_nb_free_places
|
reservable.update_nb_free_places
|
||||||
reservable.save
|
reservable.save
|
||||||
end
|
end
|
||||||
|
Slots::PlacesCacheService.refresh(slot_reservation.slot)
|
||||||
NotificationCenter.call type: 'notify_member_reservation_validated',
|
NotificationCenter.call type: 'notify_member_reservation_validated',
|
||||||
receiver: slot_reservation.reservation.user,
|
receiver: slot_reservation.reservation.user,
|
||||||
attached_object: slot_reservation.reservation
|
attached_object: slot_reservation.reservation
|
||||||
@ -47,6 +48,7 @@ class SlotsReservationsService
|
|||||||
reservable.update_nb_free_places
|
reservable.update_nb_free_places
|
||||||
reservable.save
|
reservable.save
|
||||||
end
|
end
|
||||||
|
Slots::PlacesCacheService.refresh(slot_reservation.slot)
|
||||||
NotificationCenter.call type: 'notify_member_reservation_invalidated',
|
NotificationCenter.call type: 'notify_member_reservation_invalidated',
|
||||||
receiver: slot_reservation.reservation.user,
|
receiver: slot_reservation.reservation.user,
|
||||||
attached_object: slot_reservation.reservation
|
attached_object: slot_reservation.reservation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user