From 1aa9b2fe395648be3ddb2df270b092dfa4d5080c Mon Sep 17 00:00:00 2001 From: Guilherme Chaguri Date: Wed, 1 Mar 2023 17:44:01 -0300 Subject: [PATCH 1/3] Added reservation deadlines for each type of reservation --- app/frontend/src/javascript/models/setting.ts | 5 +++- app/frontend/src/javascript/router.js | 3 +- .../admin/settings/reservations.html | 28 +++++++++++++++++-- app/helpers/settings_helper.rb | 5 +++- app/models/cart_item/event_reservation.rb | 4 +++ app/models/cart_item/machine_reservation.rb | 4 +++ app/models/cart_item/reservation.rb | 8 +++++- app/models/cart_item/space_reservation.rb | 4 +++ app/models/cart_item/training_reservation.rb | 4 +++ .../availabilities/availabilities_service.rb | 19 +++++++++++-- config/locales/app.admin.en.yml | 5 +++- db/seeds/settings.rb | 10 ++++++- test/frontend/__fixtures__/settings.ts | 22 +++++++++++++-- .../reservations/last_minute_test.rb | 6 ++-- 14 files changed, 112 insertions(+), 15 deletions(-) diff --git a/app/frontend/src/javascript/models/setting.ts b/app/frontend/src/javascript/models/setting.ts index 6337466d2..27f84db14 100644 --- a/app/frontend/src/javascript/models/setting.ts +++ b/app/frontend/src/javascript/models/setting.ts @@ -81,7 +81,10 @@ export const bookingSettings = [ 'reminder_delay', 'visibility_yearly', 'visibility_others', - 'reservation_deadline', + 'machine_reservation_deadline', + 'training_reservation_deadline', + 'event_reservation_deadline', + 'space_reservation_deadline', 'display_name_enable', 'book_overlapping_slots', 'slot_duration', diff --git a/app/frontend/src/javascript/router.js b/app/frontend/src/javascript/router.js index d54da8537..f2186e456 100644 --- a/app/frontend/src/javascript/router.js +++ b/app/frontend/src/javascript/router.js @@ -1175,7 +1175,8 @@ angular.module('application.router', ['ui.router']) "'renew_pack_threshold', 'pack_only_for_subscription', 'overlapping_categories', 'public_registrations'," + "'extended_prices_in_same_day', 'recaptcha_site_key', 'recaptcha_secret_key', 'user_validation_required', " + "'user_validation_required_list', 'machines_module', 'user_change_group', 'show_username_in_admin_list', " + - "'store_module', 'reservation_deadline']" + "'store_module', 'machine_reservation_deadline', 'training_reservation_deadline', 'event_reservation_deadline', " + + "'space_reservation_deadline']" }).$promise; }], privacyDraftsPromise: ['Setting', function (Setting) { return Setting.get({ name: 'privacy_draft', history: true }).$promise; }], diff --git a/app/frontend/templates/admin/settings/reservations.html b/app/frontend/templates/admin/settings/reservations.html index 6f6469ba1..3307fedd9 100644 --- a/app/frontend/templates/admin/settings/reservations.html +++ b/app/frontend/templates/admin/settings/reservations.html @@ -108,9 +108,33 @@

{{ 'app.admin.settings.reservation_deadline' }}

{{ 'app.admin.settings.reservation_deadline_help' }}

- + + + + + + = ? AND available_type = ?', window_end, window_start, type) diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml index c89977d48..c8d48c577 100644 --- a/config/locales/app.admin.en.yml +++ b/config/locales/app.admin.en.yml @@ -1578,7 +1578,10 @@ en: visibility_for_other_members: "For all other members" reservation_deadline: "Prevent last minute booking" reservation_deadline_help: "If you increase the prior period, members won't be able to book a slot X minutes before its start." - deadline_minutes: "Prior period (minutes)" + machine_deadline_minutes: "Machine prior period (minutes)" + training_deadline_minutes: "Training prior period (minutes)" + event_deadline_minutes: "Event prior period (minutes)" + space_deadline_minutes: "Space prior period (minutes)" ability_for_the_users_to_move_their_reservations: "Ability for the users to move their reservations" reservations_shifting: "Reservations shifting" prior_period_hours: "Prior period (hours)" diff --git a/db/seeds/settings.rb b/db/seeds/settings.rb index 87c5faba0..4df47c23c 100644 --- a/db/seeds/settings.rb +++ b/db/seeds/settings.rb @@ -418,7 +418,15 @@ Setting.set('visibility_yearly', 3) unless Setting.find_by(name: 'visibility_yea Setting.set('visibility_others', 1) unless Setting.find_by(name: 'visibility_others').try(:value) -Setting.set('reservation_deadline', 0) unless Setting.find_by(name: 'reservation_deadline').try(:value) +reservation_deadline = Setting.get('reservation_deadline') || 0 + +Setting.set('machine_reservation_deadline', reservation_deadline) unless Setting.find_by(name: 'machine_reservation_deadline').try(:value) + +Setting.set('training_reservation_deadline', reservation_deadline) unless Setting.find_by(name: 'training_reservation_deadline').try(:value) + +Setting.set('event_reservation_deadline', reservation_deadline) unless Setting.find_by(name: 'event_reservation_deadline').try(:value) + +Setting.set('space_reservation_deadline', reservation_deadline) unless Setting.find_by(name: 'space_reservation_deadline').try(:value) Setting.set('display_name_enable', false) unless Setting.find_by(name: 'display_name_enable').try(:value) diff --git a/test/frontend/__fixtures__/settings.ts b/test/frontend/__fixtures__/settings.ts index 430b439d2..9c45bb421 100644 --- a/test/frontend/__fixtures__/settings.ts +++ b/test/frontend/__fixtures__/settings.ts @@ -737,9 +737,27 @@ export const settings: Array = [ localized: 'éviter la génération de factures à 0' }, { - name: 'reservation_deadline', + name: 'machine_reservation_deadline', value: '0', - last_update: '2022-11-29T21:02:47-0300', + last_update: '2023-03-01T16:28:23-0300', + localized: "Empêcher la réservation avant qu'elle ne commence" + }, + { + name: 'training_reservation_deadline', + value: '0', + last_update: '2023-03-01T16:28:23-0300', + localized: "Empêcher la réservation avant qu'elle ne commence" + }, + { + name: 'event_reservation_deadline', + value: '0', + last_update: '2023-03-01T16:28:23-0300', + localized: "Empêcher la réservation avant qu'elle ne commence" + }, + { + name: 'space_reservation_deadline', + value: '0', + last_update: '2023-03-01T16:28:23-0300', localized: "Empêcher la réservation avant qu'elle ne commence" }, { diff --git a/test/integration/reservations/last_minute_test.rb b/test/integration/reservations/last_minute_test.rb index d0910ea37..88b366f75 100644 --- a/test/integration/reservations/last_minute_test.rb +++ b/test/integration/reservations/last_minute_test.rb @@ -13,7 +13,7 @@ class Reservations::LastMinuteTest < ActionDispatch::IntegrationTest end test 'user cannot reserve last minute booking' do - Setting.set('reservation_deadline', '120') + Setting.set('space_reservation_deadline', '120') login_as(@user, scope: :user) @@ -44,7 +44,7 @@ class Reservations::LastMinuteTest < ActionDispatch::IntegrationTest end test 'user can reserve last minute booking' do - Setting.set('reservation_deadline', '0') + Setting.set('space_reservation_deadline', '0') login_as(@user, scope: :user) @@ -85,7 +85,7 @@ class Reservations::LastMinuteTest < ActionDispatch::IntegrationTest end test 'admin can reserve last minute booking anyway' do - Setting.set('reservation_deadline', '120') + Setting.set('space_reservation_deadline', '120') login_as(@admin, scope: :user) From 27a946b7d3264dba593a2b1aec58cd0029780250 Mon Sep 17 00:00:00 2001 From: Guilherme Chaguri Date: Wed, 15 Mar 2023 16:47:46 -0300 Subject: [PATCH 2/3] Fix syntax error --- app/models/cart_item/reservation.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/cart_item/reservation.rb b/app/models/cart_item/reservation.rb index 48d72f892..653032992 100644 --- a/app/models/cart_item/reservation.rb +++ b/app/models/cart_item/reservation.rb @@ -249,6 +249,7 @@ class CartItem::Reservation < CartItem::BaseItem ## def reservation_deadline_minutes return 0 + end # @param reservation_slot [CartItem::ReservationSlot] # @param pending_subscription [CartItem::Subscription, NilClass] From 0ab998cb5b5b63e03cc12fb071195b63f6d0e9d1 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Mon, 20 Mar 2023 10:40:10 +0100 Subject: [PATCH 3/3] (i18n) updated translations --- config/locales/app.admin.de.yml | 5 ++++- config/locales/app.admin.es.yml | 5 ++++- config/locales/app.admin.fr.yml | 5 ++++- config/locales/app.admin.no.yml | 5 ++++- config/locales/app.admin.pt.yml | 5 ++++- config/locales/app.admin.zu.yml | 5 ++++- config/locales/app.shared.zu.yml | 2 +- test/frontend/__fixtures__/settings.ts | 8 ++++---- 8 files changed, 29 insertions(+), 11 deletions(-) diff --git a/config/locales/app.admin.de.yml b/config/locales/app.admin.de.yml index b66a6a873..55b1c5d0e 100644 --- a/config/locales/app.admin.de.yml +++ b/config/locales/app.admin.de.yml @@ -1608,7 +1608,10 @@ de: visibility_for_other_members: "Für alle anderen Mitglieder" reservation_deadline: "Prevent last minute booking" reservation_deadline_help: "If you increase the prior period, members won't be able to book a slot X minutes before its start." - deadline_minutes: "Prior period (minutes)" + machine_deadline_minutes: "Machine prior period (minutes)" + training_deadline_minutes: "Training prior period (minutes)" + event_deadline_minutes: "Event prior period (minutes)" + space_deadline_minutes: "Space prior period (minutes)" ability_for_the_users_to_move_their_reservations: "Möglichkeit für die Benutzer, ihre Reservierungen zu verschieben" reservations_shifting: "Verschiebung von Reservierungen" prior_period_hours: "Vorheriger Zeitraum (Stunden)" diff --git a/config/locales/app.admin.es.yml b/config/locales/app.admin.es.yml index 993aa8ebd..59b37e971 100644 --- a/config/locales/app.admin.es.yml +++ b/config/locales/app.admin.es.yml @@ -1608,7 +1608,10 @@ es: visibility_for_other_members: "Para todos los demás miembros" reservation_deadline: "Prevent last minute booking" reservation_deadline_help: "If you increase the prior period, members won't be able to book a slot X minutes before its start." - deadline_minutes: "Prior period (minutes)" + machine_deadline_minutes: "Machine prior period (minutes)" + training_deadline_minutes: "Training prior period (minutes)" + event_deadline_minutes: "Event prior period (minutes)" + space_deadline_minutes: "Space prior period (minutes)" ability_for_the_users_to_move_their_reservations: "Capacidad para que los usuarios muevan sus reservas" reservations_shifting: "Cambio de reservas" prior_period_hours: "Período anterior (horas)" diff --git a/config/locales/app.admin.fr.yml b/config/locales/app.admin.fr.yml index 4a005937e..e7082ef58 100644 --- a/config/locales/app.admin.fr.yml +++ b/config/locales/app.admin.fr.yml @@ -1608,7 +1608,10 @@ fr: visibility_for_other_members: "Pour tous les autres membres" reservation_deadline: "Empêcher les réservations de dernière minute" reservation_deadline_help: "Si vous augmentez le délai préalable, les membres ne pourront pas réserver un créneau X minutes avant le début de celui-ci." - deadline_minutes: "Délai préalable (en minutes)" + machine_deadline_minutes: "Délai préalable pour les machines (en minutes)" + training_deadline_minutes: "Délai préalable pour les formations (en minutes)" + event_deadline_minutes: "Délai préalable pour les événements (en minutes)" + space_deadline_minutes: "Délai préalable pour les espaces (en minutes)" ability_for_the_users_to_move_their_reservations: "Possibilité pour l'utilisateur de déplacer ses réservations" reservations_shifting: "Déplacement des réservations" prior_period_hours: "Délai préalable (en heures)" diff --git a/config/locales/app.admin.no.yml b/config/locales/app.admin.no.yml index 894bf2fd4..352d90f9d 100644 --- a/config/locales/app.admin.no.yml +++ b/config/locales/app.admin.no.yml @@ -1608,7 +1608,10 @@ visibility_for_other_members: "For alle andre medlemmer" reservation_deadline: "Prevent last minute booking" reservation_deadline_help: "If you increase the prior period, members won't be able to book a slot X minutes before its start." - deadline_minutes: "Prior period (minutes)" + machine_deadline_minutes: "Machine prior period (minutes)" + training_deadline_minutes: "Training prior period (minutes)" + event_deadline_minutes: "Event prior period (minutes)" + space_deadline_minutes: "Space prior period (minutes)" ability_for_the_users_to_move_their_reservations: "Om brukerne kan flytte sine bestillinger" reservations_shifting: "Reservasjonsendringer" prior_period_hours: "Tidligere perioder (timer)" diff --git a/config/locales/app.admin.pt.yml b/config/locales/app.admin.pt.yml index 9e3f2fb5d..3af29bcbb 100644 --- a/config/locales/app.admin.pt.yml +++ b/config/locales/app.admin.pt.yml @@ -1608,7 +1608,10 @@ pt: visibility_for_other_members: "Para todos os outros membros" reservation_deadline: "Impedir a reserva da última hora" reservation_deadline_help: "Se você aumentar o período prévio, os membros não serão capazes de reservar um slot X minutos antes do seu início." - deadline_minutes: "Período prévio (minutos)" + machine_deadline_minutes: "Machine prior period (minutes)" + training_deadline_minutes: "Training prior period (minutes)" + event_deadline_minutes: "Event prior period (minutes)" + space_deadline_minutes: "Space prior period (minutes)" ability_for_the_users_to_move_their_reservations: "Habilidade para os usuários mover suas reservas" reservations_shifting: "Mudança de reservas" prior_period_hours: "Período anterior (horas)" diff --git a/config/locales/app.admin.zu.yml b/config/locales/app.admin.zu.yml index 2aa768026..65698c181 100644 --- a/config/locales/app.admin.zu.yml +++ b/config/locales/app.admin.zu.yml @@ -1608,7 +1608,10 @@ zu: visibility_for_other_members: "crwdns26448:0crwdne26448:0" reservation_deadline: "crwdns31751:0crwdne31751:0" reservation_deadline_help: "crwdns36265:0crwdne36265:0" - deadline_minutes: "crwdns31753:0crwdne31753:0" + machine_deadline_minutes: "crwdns37593:0crwdne37593:0" + training_deadline_minutes: "crwdns37595:0crwdne37595:0" + event_deadline_minutes: "crwdns37597:0crwdne37597:0" + space_deadline_minutes: "crwdns37599:0crwdne37599:0" ability_for_the_users_to_move_their_reservations: "crwdns26450:0crwdne26450:0" reservations_shifting: "crwdns26452:0crwdne26452:0" prior_period_hours: "crwdns26454:0crwdne26454:0" diff --git a/config/locales/app.shared.zu.yml b/config/locales/app.shared.zu.yml index dbdb40ae2..cd69f2292 100644 --- a/config/locales/app.shared.zu.yml +++ b/config/locales/app.shared.zu.yml @@ -103,7 +103,7 @@ zu: must_accept_terms: "crwdns28700:0crwdne28700:0" save: "crwdns28702:0crwdne28702:0" gender_input: - label: "crwdns37591:0crwdne37591:0" + label: "crwdns37601:0crwdne37601:0" man: "crwdns28704:0crwdne28704:0" woman: "crwdns28706:0crwdne28706:0" change_password: diff --git a/test/frontend/__fixtures__/settings.ts b/test/frontend/__fixtures__/settings.ts index 9c45bb421..03dd134be 100644 --- a/test/frontend/__fixtures__/settings.ts +++ b/test/frontend/__fixtures__/settings.ts @@ -740,25 +740,25 @@ export const settings: Array = [ name: 'machine_reservation_deadline', value: '0', last_update: '2023-03-01T16:28:23-0300', - localized: "Empêcher la réservation avant qu'elle ne commence" + localized: 'Machine prior period (minutes)' }, { name: 'training_reservation_deadline', value: '0', last_update: '2023-03-01T16:28:23-0300', - localized: "Empêcher la réservation avant qu'elle ne commence" + localized: 'Training prior period (minutes)' }, { name: 'event_reservation_deadline', value: '0', last_update: '2023-03-01T16:28:23-0300', - localized: "Empêcher la réservation avant qu'elle ne commence" + localized: 'Event prior period (minutes)' }, { name: 'space_reservation_deadline', value: '0', last_update: '2023-03-01T16:28:23-0300', - localized: "Empêcher la réservation avant qu'elle ne commence" + localized: 'Space prior period (minutes)' }, { name: 'invoice_VAT-name',