1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-30 19:52:20 +01:00

(feat) add child age will be 18 worker

This commit is contained in:
Du Peng 2023-07-12 09:29:16 +02:00
parent 03d71d7a84
commit b6f2187d94
9 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,6 @@
# frozen_string_literal: true
json.title notification.notification_type
json.description t('.child_age_will_be_18_years_ago',
NAME: notification.attached_object.full_name,
DATE: I18n.l(notification.attached_object.birthday, format: :default))

View File

@ -0,0 +1,6 @@
<%= render 'notifications_mailer/shared/hello', recipient: @recipient %>
<%= t('.body.child_age_will_be_18_years_ago', **{
NAME: @attached_object.full_name,
DATE: I18n.l(@attached_object.birthday, format: :default),
}) %>

View File

@ -0,0 +1,15 @@
# frozen_string_literal: true
# send a notification if child age > 18 years ago
class ChildAgeWorker
include Sidekiq::Worker
def perform
children = Child.where('birthday = ?', 18.years.ago + 2.days)
children.each do |child|
NotificationCenter.call type: 'notify_user_when_child_age_will_be_18',
receiver: child.user,
attached_object: child
end
end
end

View File

@ -481,6 +481,8 @@ en:
your_reservation_RESERVABLE_was_invalidated_html: "Your pre-registration of <strong><em>%{RESERVABLE}</em></strong> wasn't validated."
notify_admin_reservation_invalidated:
a_RESERVABLE_reservation_was_invalidated_html: "A <strong><em>%{RESERVABLE}</em></strong> pre-registration of <strong><em>%{USER}</em></strong> was invalidated."
notify_user_when_child_age_will_be_18:
child_age_will_be_18_years_ago: "Your child %{NAME} will turn 18 on %{DATE}, at which point they will be automatically detached from your Family account. They will need to create their own account in order to make reservations."
#statistics tools for admins
statistics:
subscriptions: "Subscriptions"

View File

@ -481,6 +481,8 @@ fr:
your_reservation_RESERVABLE_was_invalidated_html: "Votre demande de pré-inscription de <strong><em>%{RESERVABLE}</em></strong> n'a pas été validée."
notify_admin_reservation_invalidated:
a_RESERVABLE_reservation_was_invalidated_html: "La réservation de <strong><em>%{RESERVABLE}</em></strong> de <strong><em>%{NAME}</em></strong> a été invalidée."
notify_user_when_child_age_will_be_18:
child_age_will_be_18_years_ago: "Votre enfant %{NAME} va avoir 18ans, le %{DATE}, date à laquelle il sera automatiquement détaché de votre compte Famille. Il devra se créer son propre compte pour effectuer ses réservations."
#statistics tools for admins
statistics:
subscriptions: "Abonnements"

View File

@ -479,3 +479,7 @@ en:
subject: "Pre-registration wasn't validated"
body:
reservation_invalidated_html: "<strong><em>%{RESERVABLE}</em></strong> of %{NAME} wasn't validated."
notify_user_when_child_age_will_be_18:
subject: "Your child will be 18 years old"
body:
child_age_will_be_18_years_ago: "Your child %{NAME} will turn 18 on %{DATE}, at which point they will be automatically detached from your Family account. They will need to create their own account in order to make reservations."

View File

@ -479,3 +479,7 @@ fr:
subject: "Demande of pré-inscription n'a pas été validée"
body:
reservation_invalidated_html: "<strong><em>%{RESERVABLE}</em></strong> du membre %{NAME} n'a pas été validée."
notify_user_when_child_age_will_be_18:
subject: "Votre enfant va avoir 18ans"
body:
child_age_will_be_18_years_ago: "Votre enfant %{NAME} va avoir 18ans, le %{DATE}, date à laquelle il sera automatiquement détaché de votre compte Famille. Il devra se créer son propre compte pour effectuer ses réservations."

View File

@ -62,4 +62,9 @@ auto_cancel_authorizations:
class: TrainingAuthorizationWorker
queue: default
child_age_will_be_18:
cron: "0 0 0 * * *" # every day, at midnight
class: ChildAgeWorker
queue: default
<%= PluginRegistry.insert_code('yml.schedule') %>

View File

@ -94,7 +94,8 @@ NOTIFICATIONS_TYPES = [
{ name: 'notify_member_pre_booked_reservation', category: 'agenda', is_configurable: false },
{ name: 'notify_admin_member_pre_booked_reservation', category: 'agenda', is_configurable: true },
{ name: 'notify_member_reservation_invalidated', category: 'agenda', is_configurable: false },
{ name: 'notify_admin_reservation_invalidated', category: 'agenda', is_configurable: true }
{ name: 'notify_admin_reservation_invalidated', category: 'agenda', is_configurable: true },
{ name: 'notify_user_when_child_age_will_be_18', category: 'users_accounts', is_configurable: false },
].freeze
NOTIFICATIONS_TYPES.each do |notification_type|