diff --git a/app/models/reservation.rb b/app/models/reservation.rb index ddf443681..c6677a0d3 100644 --- a/app/models/reservation.rb +++ b/app/models/reservation.rb @@ -23,11 +23,10 @@ class Reservation < ApplicationRecord has_many :prepaid_pack_reservations, dependent: :destroy + belongs_to :reservation_context has_many :booking_users, dependent: :destroy accepts_nested_attributes_for :booking_users, allow_destroy: true - belongs_to :reservation_context - validates :reservable_id, :reservable_type, presence: true validate :machine_not_already_reserved, if: -> { reservable.is_a?(Machine) } validate :training_not_fully_reserved, if: -> { reservable.is_a?(Training) } diff --git a/app/policies/setting_policy.rb b/app/policies/setting_policy.rb index 9c7fddb77..5e3a620b6 100644 --- a/app/policies/setting_policy.rb +++ b/app/policies/setting_policy.rb @@ -47,7 +47,7 @@ class SettingPolicy < ApplicationPolicy machines_banner_cta_url trainings_banner_active trainings_banner_text trainings_banner_cta_active trainings_banner_cta_label trainings_banner_cta_url events_banner_active events_banner_text events_banner_cta_active events_banner_cta_label events_banner_cta_url projects_list_member_filter_presence projects_list_date_filters_presence advanced_accounting - project_categories_filter_placeholder project_categories_wording family_account child_validation_required reservation_context_feature] + project_categories_filter_placeholder project_categories_wording reservation_context_feature family_account child_validation_required] end ## diff --git a/app/workers/supporting_documents_reminder_worker.rb b/app/workers/supporting_documents_reminder_worker.rb index dfe9ca42c..6aa1a2910 100644 --- a/app/workers/supporting_documents_reminder_worker.rb +++ b/app/workers/supporting_documents_reminder_worker.rb @@ -8,7 +8,7 @@ class SupportingDocumentsReminderWorker users_to_notify = User.members .supporting_documents_reminder_not_sent .where("users.created_at < ?", 2.days.ago) - .left_outer_joins(supporting_document_files: { supporting_document_type: :groups }) + .joins("LEFT OUTER JOIN supporting_document_files ON supporting_document_files.supportable_id = users.id AND supporting_document_files.supportable_type = 'User' LEFT OUTER JOIN supporting_document_types ON supporting_document_types.id = supporting_document_files.supporting_document_type_id LEFT OUTER JOIN supporting_document_types_groups ON supporting_document_types_groups.supporting_document_type_id = supporting_document_types.id LEFT OUTER JOIN groups ON groups.id = supporting_document_types_groups.group_id") .where("groups.id = users.group_id OR groups.id IS NULL") .select("users.*, count(supporting_document_files.id)") .group("users.id") diff --git a/config/initializers/notification_types.rb b/config/initializers/notification_types.rb index 395928db5..1f9f81b58 100644 --- a/config/initializers/notification_types.rb +++ b/config/initializers/notification_types.rb @@ -77,5 +77,24 @@ NOTIFICATIONS_TYPES = [ { name: 'notify_admin_low_stock_threshold', category: 'shop', is_configurable: true, roles: ['admin', 'manager'] }, { name: 'notify_admin_training_auto_cancelled', category: 'trainings', is_configurable: true, roles: ['admin', 'manager'] }, { name: 'notify_member_training_auto_cancelled', category: 'trainings', is_configurable: false }, - { name: 'notify_user_supporting_document_reminder', category: 'supporting_documents', is_configurable: false } + { name: 'notify_user_supporting_document_reminder', category: 'supporting_documents', is_configurable: false }, + + { name: 'notify_member_training_authorization_expired', category: 'trainings', is_configurable: false }, + { name: 'notify_member_training_invalidated', category: 'trainings', is_configurable: false }, + { name: 'notify_member_reservation_limit_reached', category: 'agenda', is_configurable: false }, + { name: 'notify_admin_user_child_supporting_document_refusal', category: 'supporting_documents', is_configurable: true, roles: ['admin', 'manager'] }, + { name: 'notify_user_child_supporting_document_refusal', category: 'supporting_documents', is_configurable: false }, + { name: 'notify_admin_child_created', category: 'users_accounts', is_configurable: true, roles: ['admin', 'manager'] }, + { name: 'notify_user_child_is_validated', category: 'users_accounts', is_configurable: false }, + { name: 'notify_user_child_is_invalidated', category: 'users_accounts', is_configurable: false }, + { name: 'notify_admin_user_child_supporting_document_files_updated', category: 'supporting_documents', is_configurable: true, roles: ['admin', 'manager'] }, + { name: 'notify_admin_user_child_supporting_document_files_created', category: 'supporting_documents', is_configurable: true, roles: ['admin', 'manager'] }, + + { name: 'notify_member_reservation_validated', category: 'agenda', is_configurable: false }, + { name: 'notify_admin_reservation_validated', category: 'agenda', is_configurable: true, roles: ['admin', 'manager'] }, + { name: 'notify_member_pre_booked_reservation', category: 'agenda', is_configurable: false }, + { name: 'notify_admin_member_pre_booked_reservation', category: 'agenda', is_configurable: true, roles: ['admin', 'manager'] }, + { name: 'notify_member_reservation_invalidated', category: 'agenda', is_configurable: false }, + { name: 'notify_admin_reservation_invalidated', category: 'agenda', is_configurable: true, roles: ['admin', 'manager'] }, + { name: 'notify_user_when_child_age_will_be_18', category: 'users_accounts', is_configurable: false } ].freeze diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml index a57ff4be8..6c2beef97 100644 --- a/config/locales/app.admin.en.yml +++ b/config/locales/app.admin.en.yml @@ -1857,11 +1857,6 @@ en: projects_list_date_filters_presence: "Presence of date filters on projects list" project_categories_filter_placeholder: "Placeholder for categories filter in project gallery" project_categories_wording: "Wording used to replace \"Categories\" on public pages" - family_account: "family account" - family_account_info_html: "The Family account allows your members to add their children under 18 years old to their own account and directly register them for Family events. You can also request supporting documents for each child and validate their account." - enable_family_account: "Enable the Family Account option" - child_validation_required: "the account validation option for children" - child_validation_required_label: "Activate the account validation option for children" reservation_context_feature_title: Reservation context reservation_context_feature_info: "If you enable this feature, members will have to enter the context of their reservation when reserving." reservation_context_feature: "Enable the feature \"Reservation context\"" @@ -1871,6 +1866,11 @@ en: do_you_really_want_to_delete_this_reservation_context: "Do you really want to delete this context?" unable_to_delete_reservation_context_already_related_to_reservations: "Unable to delete this context because it is already associated to a reservation" unable_to_delete_reservation_context_an_error_occured: "Unable to delete: an error occurred" + family_account: "family account" + family_account_info_html: "The Family account allows your members to add their children under 18 years old to their own account and directly register them for Family events. You can also request supporting documents for each child and validate their account." + enable_family_account: "Enable the Family Account option" + child_validation_required: "the account validation option for children" + child_validation_required_label: "Activate the account validation option for children" overlapping_options: training_reservations: "Trainings" machine_reservations: "Machines" diff --git a/config/locales/app.admin.fr.yml b/config/locales/app.admin.fr.yml index 9e17f9374..19ef5a426 100644 --- a/config/locales/app.admin.fr.yml +++ b/config/locales/app.admin.fr.yml @@ -1849,11 +1849,6 @@ fr: projects_list_date_filters_presence: "Permettre la recherche de projets par dates" project_categories_filter_placeholder: "Dans la galerie de projets, renommer le filtre \"Toutes les catégories\"" project_categories_wording: "Dans la fiche projet, renommer l'intitulé de l'encart Catégories" - family_account: "Compte famille" - family_account_info_html: "Le compte Famille permet à vos membres d'ajouter leurs enfants de moins de 18 ans sur leur propre compte et de les inscrire directement aux évènements de type Famille. Vous pouvez aussi demander des justificatifs pour chaque enfant et valider leur compte." - enable_family_account: "Activer l'option Compte Famille" - child_validation_required: "l'option de validation des comptes enfants" - child_validation_required_label: "Activer l'option de validation des comptes enfants" reservation_context_feature_title: Nature de la réservation reservation_context_feature_info: "Si vous activez cette fonctionnalité, les membres devront entrer la nature de leur réservation lors de la réservation." reservation_context_feature: "Activer la fonctionnalité \"Nature de réservation\"" @@ -1862,6 +1857,15 @@ fr: do_you_really_want_to_delete_this_reservation_context: "Êtes-vous sûr de vouloir supprimer cette nature ?" unable_to_delete_reservation_context_already_related_to_reservations: "Impossible de supprimer ce contexte car il est déjà associé à une réservation" unable_to_delete_reservation_context_an_error_occured: "Impossible de supprimer : une erreur est survenue" + projects_list_member_filter_presence: "Presence of member filter on projects list" + projects_list_date_filters_presence: "Presence of date filters on projects list" + project_categories_filter_placeholder: "Placeholder for categories filter in project gallery" + project_categories_wording: "Wording used to replace \"Categories\" on public pages" + family_account: "Compte famille" + family_account_info_html: "Le compte Famille permet à vos membres d'ajouter leurs enfants de moins de 18 ans sur leur propre compte et de les inscrire directement aux évènements de type Famille. Vous pouvez aussi demander des justificatifs pour chaque enfant et valider leur compte." + enable_family_account: "Activer l'option Compte Famille" + child_validation_required: "l'option de validation des comptes enfants" + child_validation_required_label: "Activer l'option de validation des comptes enfants" overlapping_options: training_reservations: "Formations" machine_reservations: "Machines" diff --git a/config/locales/app.shared.en.yml b/config/locales/app.shared.en.yml index 5f2717aab..f9ec42c3a 100644 --- a/config/locales/app.shared.en.yml +++ b/config/locales/app.shared.en.yml @@ -371,13 +371,12 @@ en: slot_tags: "Slot tags" user_tags: "User tags" no_tags: "No tags" - user_validation_required_alert: "Your administrator must validate your account. Then, you'll then be able to access all the booking features." - child_validation_required_alert: "Your administrator must validate your child account. Then, you'll then be able to book the event." - child_birthday_must_be_under_18_years_ago_alert: "Your child must be under 18. Then, you'll then be able to book the event." user_validation_required_alert: "Warning!
Your administrator must validate your account. Then, you'll then be able to access all the booking features." select_the_reservation_context: "Select the context of the reservation" please_select_a_reservation_context: "Please select the context of the reservation first" - #feature-tour modal + child_validation_required_alert: "Your administrator must validate your child account. Then, you'll then be able to book the event." + child_birthday_must_be_under_18_years_ago_alert: "Your child must be under 18. Then, you'll then be able to book the event." + # feature-tour modal tour: previous: "Previous" next: "Next" diff --git a/config/locales/app.shared.fr.yml b/config/locales/app.shared.fr.yml index be9492f7b..a9c433e6c 100644 --- a/config/locales/app.shared.fr.yml +++ b/config/locales/app.shared.fr.yml @@ -372,10 +372,10 @@ fr: user_tags: "Étiquettes de l'utilisateur" no_tags: "Aucune étiquette" user_validation_required_alert: "Attention !
Votre administrateur doit valider votre compte. Vous pourrez alors accéder à l'ensemble des fonctionnalités de réservation." + select_the_reservation_context: "Sélectionnez la nature de la réservation" + please_select_a_reservation_context: "Veuillez d'abord sélectionner la nature de la réservation" child_validation_required_alert: "Attention !
Votre administrateur doit valider votre compte enfant. Vous pourrez alors réserver l'événement." child_birthday_must_be_under_18_years_ago_alert: "Attention !
La date de naissance de l'enfant doit être inférieure à 18 ans. Vous pourrez alors réserver l'événement." - select_the_reservation_context: Sélectionnez la nature de la réservation - please_select_a_reservation_context: "Veuillez tout d'abord sélectionner la nature de la réservation" #feature-tour modal tour: previous: "Précédent" diff --git a/config/locales/en.yml b/config/locales/en.yml index 7596607d5..f69febae3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -740,8 +740,8 @@ en: projects_list_date_filters_presence: "Presence of dates filter on projects list" project_categories_filter_placeholder: "Placeholder for categories filter in project gallery" project_categories_wording: "Wording used to replace \"Categories\" on public pages" - family_account: "Family account" reservation_context_feature: "Force member to select the nature of his reservation when reserving" + family_account: "Family account" #statuses of projects statuses: new: "New" diff --git a/db/seeds/settings.rb b/db/seeds/settings.rb index dabb29607..7962b9194 100644 --- a/db/seeds/settings.rb +++ b/db/seeds/settings.rb @@ -733,7 +733,8 @@ Setting.set('projects_list_member_filter_presence', false) unless Setting.find_b Setting.set('projects_list_date_filters_presence', false) unless Setting.find_by(name: 'projects_list_date_filters_presence') Setting.set('project_categories_filter_placeholder', 'Toutes les catégories') unless Setting.find_by(name: 'project_categories_filter_placeholder').try(:value) Setting.set('project_categories_wording', 'Catégories') unless Setting.find_by(name: 'project_categories_wording').try(:value) -Setting.set('family_account', false) unless Setting.find_by(name: 'family_account').try(:value) -Setting.set('child_validation_required', false) unless Setting.find_by(name: 'child_validation_required').try(:value) Setting.set('reservation_context_feature', false) unless Setting.find_by(name: 'reservation_context_feature') + +Setting.set('family_account', false) unless Setting.find_by(name: 'family_account').try(:value) +Setting.set('child_validation_required', false) unless Setting.find_by(name: 'child_validation_required').try(:value) diff --git a/test/fixtures/history_values.yml b/test/fixtures/history_values.yml index b52666c13..3a378256b 100644 --- a/test/fixtures/history_values.yml +++ b/test/fixtures/history_values.yml @@ -898,3 +898,11 @@ history_value_106: created_at: '2023-03-31 14:38:40.000421' updated_at: '2023-03-31 14:38:40.000421' invoicing_profile_id: 1 + +history_value_107: + id: 107 + setting_id: 106 + value: 'false' + created_at: '2023-03-31 14:38:40.000421' + updated_at: '2023-03-31 14:38:40.000421' + invoicing_profile_id: 1 diff --git a/test/fixtures/settings.yml b/test/fixtures/settings.yml index e63357245..49ed9cbee 100644 --- a/test/fixtures/settings.yml +++ b/test/fixtures/settings.yml @@ -613,18 +613,18 @@ setting_103: setting_104: id: 104 - name: family_account - created_at: 2023-03-31 14:38:40.000421500 Z - updated_at: 2023-03-31 14:38:40.000421500 Z + name: reservation_context_feature + created_at: 2023-04-05 09:16:08.000511500 Z + updated_at: 2023-04-05 09:16:08.000511500 Z setting_105: id: 105 - name: child_validation_required + name: family_account created_at: 2023-03-31 14:38:40.000421500 Z updated_at: 2023-03-31 14:38:40.000421500 Z setting_106: id: 106 - name: reservation_context_feature - created_at: 2023-04-05 09:16:08.000511500 Z - updated_at: 2023-04-05 09:16:08.000511500 Z + name: child_validation_required + created_at: 2023-03-31 14:38:40.000421500 Z + updated_at: 2023-03-31 14:38:40.000421500 Z diff --git a/test/frontend/__fixtures__/settings.ts b/test/frontend/__fixtures__/settings.ts index 96a5de3b4..c43dcf0be 100644 --- a/test/frontend/__fixtures__/settings.ts +++ b/test/frontend/__fixtures__/settings.ts @@ -850,17 +850,17 @@ export const settings: Array = [ last_update: '2022-12-23T14:39:12+0100', localized: 'Project categories overridden name' }, - { - name: 'family_account', - value: 'false', - last_update: '2023-03-31T14:39:12+0100', - localized: 'Family account' - }, { name: 'reservation_context_feature', value: 'false', last_update: '2022-12-23T14:39:12+0100', localized: 'Reservation context feature' + }, + { + name: 'family_account', + value: 'false', + last_update: '2023-03-31T14:39:12+0100', + localized: 'Family account' } ];