mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-03-15 12:29:16 +01:00
(wip) notify admin on auto cancel
This commit is contained in:
parent
c804c84113
commit
71305bbc8f
@ -73,6 +73,7 @@ class NotificationType
|
||||
notify_user_order_is_canceled
|
||||
notify_user_order_is_refunded
|
||||
notify_admin_low_stock_threshold
|
||||
notify_admin_training_auto_cancelled
|
||||
]
|
||||
# deprecated:
|
||||
# - notify_member_subscribed_plan_is_changed
|
||||
|
@ -25,10 +25,14 @@ class TrainingService
|
||||
training.availabilities
|
||||
.includes(slots: :slots_reservations)
|
||||
.where('availabilities.start_at >= ?', DateTime.current - training.auto_cancel_deadline.hours)
|
||||
.find_each do |a|
|
||||
next if a.reservations.count >= training.auto_cancel_threshold
|
||||
.find_each do |availability|
|
||||
next if availability.reservations.count >= training.auto_cancel_threshold
|
||||
|
||||
a.slots_reservations.find_each do |sr|
|
||||
NotificationCenter.call type: 'notify_admin_training_auto_cancelled',
|
||||
receiver: User.admins_and_managers,
|
||||
attached_object: availability
|
||||
|
||||
availability.slots_reservations.find_each do |sr|
|
||||
sr.update(canceled_at: DateTime.current)
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,4 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
json.title notification.notification_type
|
||||
json.description t('.auto_cancelled_training')
|
@ -0,0 +1,10 @@
|
||||
<%= render 'notifications_mailer/shared/hello', recipient: @recipient %>
|
||||
|
||||
<p>
|
||||
<%= t('.body.cancelled_training', {
|
||||
TRAINING: @attached_object.trainings.first.name,
|
||||
DATE: I18n.l(@attached_object.start_at.to_date),
|
||||
START: I18n.l(@attached_object.start_at, format: :hour_minute),
|
||||
END: I18n.l(@attached_object.end_at, format: :hour_minute)
|
||||
}) %>
|
||||
</p>
|
@ -296,6 +296,8 @@ en:
|
||||
USER_s_subscription_has_expired: "%{USER}'s subscription has expired."
|
||||
notify_admin_subscription_will_expire_in_7_days:
|
||||
USER_s_subscription_will_expire_in_7_days: "%{USER}'s subscription will expire in 7 days."
|
||||
notify_admin_training_auto_cancelled:
|
||||
auto_cancelled_training: "TODO"
|
||||
notify_admin_user_group_changed:
|
||||
user_NAME_changed_his_group_html: "User <strong><em>{NAME}</strong></em> changed group." #messageFormat interpolation
|
||||
notify_admin_user_merged:
|
||||
|
@ -131,6 +131,10 @@ en:
|
||||
your_plan: "you plan"
|
||||
expires_in_7_days: "will expire in 7 days."
|
||||
to_renew_your_plan_follow_the_link: "Please, follow this link to renew your plan"
|
||||
notify_admin_training_auto_cancelled:
|
||||
subject: "A training was automatically cancelled"
|
||||
body:
|
||||
cancelled_training: "The %{TRAINING} training session scheduled for %{DATE}, from %{START} to %{END} has been automatically canceled due to an insufficient number of participants."
|
||||
notify_member_subscription_is_expired:
|
||||
subject: "Your subscription has expired"
|
||||
body:
|
||||
|
Loading…
x
Reference in New Issue
Block a user