1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-22 11:52:21 +01:00

Merge branch 'pre_inscription' into staging

This commit is contained in:
Du Peng 2023-07-12 15:07:31 +02:00
commit e7a4ab2140
10 changed files with 69 additions and 43 deletions

View File

@ -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'));
});

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

@ -48,7 +48,8 @@
</td>
<td ng-if="event.pre_registration">
<span ng-if="!isValidated(reservation) && !isCancelled(reservation) && !reservation.is_paid" class="v-middle badge text-sm bg-info" translate="">{{ 'app.admin.event_reservations.event_status.pre_registered' }}</span>
<span ng-if="isValidated(reservation) && !isCancelled(reservation) && !reservation.is_paid" class="v-middle badge text-sm bg-stage" translate="">{{ 'app.admin.event_reservations.event_status.to_pay' }}</span>
<span ng-if="event.amount !== 0 && isValidated(reservation) && !isCancelled(reservation) && !reservation.is_paid" class="v-middle badge text-sm bg-stage" translate="">{{ 'app.admin.event_reservations.event_status.to_pay' }}</span>
<span ng-if="event.amount === 0 && isValidated(reservation) && !isCancelled(reservation) && !reservation.is_paid" class="v-middle badge text-sm bg-stage" translate="">{{ 'app.admin.event_reservations.event_status.registered' }}</span>
<span ng-if="event.amount !== 0 && reservation.is_paid && !isCancelled(reservation)" class="v-middle badge text-sm bg-success" translate="">{{ 'app.admin.event_reservations.event_status.paid' }}</span>
<span ng-if="event.amount === 0 && reservation.is_paid && !isCancelled(reservation)" class="v-middle badge text-sm bg-success" translate="">{{ 'app.admin.event_reservations.event_status.present' }}</span>
<span ng-if="isCancelled(reservation)" class="v-middle badge text-sm bg-event" translate="">{{ 'app.admin.event_reservations.event_status.canceled' }}</span>
@ -58,11 +59,11 @@
<div ng-if="!isCancelled(reservation) && !reservation.is_paid">
<label class="m-r-sm">
<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>
<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>
</div>
<button class="btn btn-default" ng-click="payReservation(reservation)" ng-if="isValidated(reservation) && !isCancelled(reservation) && !reservation.is_paid">

View File

@ -51,29 +51,6 @@
<user-validation-setting on-success="onSuccess" on-error="onError" />
</div>
</div>
<div class="row">
<h3 class="m-l" translate>{{ 'app.admin.settings.family_account' }}</h3>
<p class="alert alert-warning m-h-md" ng-bind-html="'app.admin.settings.family_account_info_html' | translate"></p>
<div class="col-md-10 col-md-offset-1">
<boolean-setting name="'family_account'"
settings="allSettings"
label="'app.admin.settings.enable_family_account' | translate"
on-success="onSuccess"
on-error="onError">
</div>
<div class="col-md-10 col-md-offset-1">
<boolean-setting name="'child_validation_required'"
settings="allSettings"
label="'app.admin.settings.child_validation_required_label' | translate"
on-success="onSuccess"
on-error="onError">
</div>
</div>
<div class="row">
<div class="col-md-12">
<supporting-documents-types-list on-success="onSuccess" on-error="onError" document-type="'Child'" />
</div>
</div>
<div class="row">
<h3 class="m-l" translate>{{ 'app.admin.settings.captcha' }}</h3>
@ -97,6 +74,37 @@
</div>
</div>
</div>
<div class="panel panel-default m-t-md">
<div class="panel-heading">
<span class="font-sbold" translate>{{ 'app.admin.settings.family_account' }}</span>
</div>
<div class="panel-body">
<div class="row">
<p class="alert alert-warning m-h-md" ng-bind-html="'app.admin.settings.family_account_info_html' | translate"></p>
<div class="col-md-10 col-md-offset-1">
<boolean-setting name="'family_account'"
settings="allSettings"
label="'app.admin.settings.enable_family_account' | translate"
on-success="onSuccess"
on-error="onError">
</div>
<div class="col-md-10 col-md-offset-1">
<boolean-setting name="'child_validation_required'"
settings="allSettings"
label="'app.admin.settings.child_validation_required_label' | translate"
on-success="onSuccess"
on-error="onError">
</div>
</div>
<div class="row">
<div class="col-md-12">
<supporting-documents-types-list on-success="onSuccess" on-error="onError" document-type="'Child'" />
</div>
</div>
</div>
</div>
<div class="panel panel-default m-t-md">
<div class="panel-heading">
<span class="font-sbold" translate>{{ 'app.admin.settings.accounts_management' }}</span>

View File

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

View File

@ -30,10 +30,14 @@ class Slots::PlacesCacheService
reservations = Slots::ReservationsService.reservations(slot.slots_reservations, [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({
reservable_type: reservable.class.name,
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]
})
end

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)

View File

@ -29,6 +29,7 @@ class SlotsReservationsService
reservable.update_nb_free_places
reservable.save
end
Slots::PlacesCacheService.refresh(slot_reservation.slot)
NotificationCenter.call type: 'notify_member_reservation_validated',
receiver: slot_reservation.reservation.user,
attached_object: slot_reservation.reservation
@ -47,6 +48,7 @@ class SlotsReservationsService
reservable.update_nb_free_places
reservable.save
end
Slots::PlacesCacheService.refresh(slot_reservation.slot)
NotificationCenter.call type: 'notify_member_reservation_invalidated',
receiver: slot_reservation.reservation.user,
attached_object: slot_reservation.reservation

View File

@ -654,6 +654,7 @@ en:
paid: "Paid"
canceled: "Canceled"
present: "Present"
registered: "Registered"
affirmative: "yes"
negative: "no"
validate: "Validate"

View File

@ -654,6 +654,7 @@ fr:
paid: "Payé"
canceled: "Annulée"
present: "Présent"
registered: "Inscrit"
affirmative: "Oui"
negative: "Non"
validate: "Valider"