mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-19 13:54:25 +01:00
[not tested] send reminder notification every hours for upcoming reservations
This commit is contained in:
parent
b166d6abc6
commit
cc1d6e4f21
@ -41,5 +41,6 @@ class NotificationType
|
|||||||
notify_admin_user_wallet_is_credited
|
notify_admin_user_wallet_is_credited
|
||||||
notify_admin_export_complete
|
notify_admin_export_complete
|
||||||
notify_member_about_coupon
|
notify_member_about_coupon
|
||||||
|
notify_member_reservation_reminder
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
json.title notification.notification_type
|
||||||
|
json.description t('.reminder_you_have_a_reservation_RESERVABLE_to_be_held_on_DATE_html',
|
||||||
|
RESERVABLE: notification.attached_object.reservable.name,
|
||||||
|
DATE: I18n.l(notification.attached_object.slots.order(:start_at).first.start_at, format: :long))
|
||||||
|
json.url notification_url(notification, format: :json)
|
@ -0,0 +1,18 @@
|
|||||||
|
<%= render 'notifications_mailer/shared/hello', recipient: @recipient %>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<%= t('.body.this_is_a_reminder_about_your_reservation_RESERVABLE_to_be_held_on_DATE_html',
|
||||||
|
RESERVABLE: @attached_object.reservable.name,
|
||||||
|
DATE: I18n.l(@attached_object.slots.order(:start_at).first.start_at, format: :long)
|
||||||
|
)
|
||||||
|
%>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<%= t('.body.this_reservation_concerns_the_following_slots') %>
|
||||||
|
<ul>
|
||||||
|
<% @attached_object.slots.order(:start_at).each do |slot| %>
|
||||||
|
<li><%= "#{I18n.l slot.start_at, format: :long} - #{I18n.l slot.end_at, format: :hour_minute}" %></li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</p>
|
22
app/workers/reservation_reminder_worker.rb
Normal file
22
app/workers/reservation_reminder_worker.rb
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
class ReservationReminderWorker
|
||||||
|
include Sidekiq::Worker
|
||||||
|
|
||||||
|
## In case the reminder is enabled but no delay were configured, we use this default value
|
||||||
|
DEFAULT_REMINDER_DELAY = 24.hours
|
||||||
|
|
||||||
|
def perform
|
||||||
|
enabled = Setting.find_by(name: 'reminder_enable').try(:value)
|
||||||
|
if enabled == 'true'
|
||||||
|
delay = Setting.find_by(name: 'reminder_delay').try(:value).try(:to_i).try(:hours) || DEFAULT_REMINDER_DELAY
|
||||||
|
|
||||||
|
starting = Time.now.beginning_of_hour + delay
|
||||||
|
ending = starting + 1.hour
|
||||||
|
|
||||||
|
Reservation.includes(:slots).where('slots.start_at >= ? AND slots.start_at <= ?', starting, ending).each do |r|
|
||||||
|
NotificationCenter.call type: 'notify_member_reservation_reminder',
|
||||||
|
receiver: r.user,
|
||||||
|
attached_object: r
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -213,6 +213,8 @@ en:
|
|||||||
a_new_user_account_has_been_imported_from_PROVIDER_(UID)_html: "A new user account has been imported from: <strong><em>%{PROVIDER}</strong> (%{UID})</em>."
|
a_new_user_account_has_been_imported_from_PROVIDER_(UID)_html: "A new user account has been imported from: <strong><em>%{PROVIDER}</strong> (%{UID})</em>."
|
||||||
notify_member_create_reservation:
|
notify_member_create_reservation:
|
||||||
your_reservation_RESERVABLE_was_successfully_saved_html: "Your reservation <strong><em>%{RESERVABLE}</em></strong> was successfully saved."
|
your_reservation_RESERVABLE_was_successfully_saved_html: "Your reservation <strong><em>%{RESERVABLE}</em></strong> was successfully saved."
|
||||||
|
notify_member_reservation_reminder:
|
||||||
|
reminder_you_have_a_reservation_RESERVABLE_to_be_held_on_DATE_html: "Reminder: You have a reservation <strong>%{RESERVABLE}</strong> to be held on <em>%{DATE}</em>"
|
||||||
notify_member_slot_is_canceled:
|
notify_member_slot_is_canceled:
|
||||||
your_reservation_RESERVABLE_of_DATE_was_successfully_cancelled: "Your reservation %{RESERVABLE} of %{DATE} was successfully cancelled."
|
your_reservation_RESERVABLE_of_DATE_was_successfully_cancelled: "Your reservation %{RESERVABLE} of %{DATE} was successfully cancelled."
|
||||||
notify_member_slot_is_modified:
|
notify_member_slot_is_modified:
|
||||||
|
@ -213,6 +213,8 @@ fr:
|
|||||||
a_new_user_account_has_been_imported_from_PROVIDER_(UID)_html: "Un nouveau compte utilisateur vient d'être importé depuis : <strong><em>%{PROVIDER}</strong> (%{UID})</em>."
|
a_new_user_account_has_been_imported_from_PROVIDER_(UID)_html: "Un nouveau compte utilisateur vient d'être importé depuis : <strong><em>%{PROVIDER}</strong> (%{UID})</em>."
|
||||||
notify_member_create_reservation:
|
notify_member_create_reservation:
|
||||||
your_reservation_RESERVABLE_was_successfully_saved_html: "Votre réservation <strong><em>%{RESERVABLE}</em></strong> a bien été enregistrée."
|
your_reservation_RESERVABLE_was_successfully_saved_html: "Votre réservation <strong><em>%{RESERVABLE}</em></strong> a bien été enregistrée."
|
||||||
|
notify_member_reservation_reminder:
|
||||||
|
reminder_you_have_a_reservation_RESERVABLE_to_be_held_on_DATE_html: "Rappel : Vous avez une réservation <strong>%{RESERVABLE}</strong> qui aura lieu le <em>%{DATE}</em>"
|
||||||
notify_member_slot_is_canceled:
|
notify_member_slot_is_canceled:
|
||||||
your_reservation_RESERVABLE_of_DATE_was_successfully_cancelled: "Votre réservation %{RESERVABLE} du %{DATE} a bien été annulée."
|
your_reservation_RESERVABLE_of_DATE_was_successfully_cancelled: "Votre réservation %{RESERVABLE} du %{DATE} a bien été annulée."
|
||||||
notify_member_slot_is_modified:
|
notify_member_slot_is_modified:
|
||||||
|
@ -131,6 +131,12 @@ en:
|
|||||||
invoice_in_your_dashboard_html: "You can access your invoice in %{DASHBOARD} on the Fab Lab website."
|
invoice_in_your_dashboard_html: "You can access your invoice in %{DASHBOARD} on the Fab Lab website."
|
||||||
your_dashboard: "your dashboard"
|
your_dashboard: "your dashboard"
|
||||||
|
|
||||||
|
notify_member_reservation_reminder:
|
||||||
|
subject: "Reservation reminder"
|
||||||
|
body:
|
||||||
|
this_is_a_reminder_about_your_reservation_RESERVABLE_to_be_held_on_DATE_html: "This is a reminder about your reservation <strong>%{RESERVABLE}</strong> to be held on <em>%{DATE}</em>"
|
||||||
|
this_reservation_concerns_the_following_slots: "This reservation concerns the following slots:"
|
||||||
|
|
||||||
notify_member_avoir_ready:
|
notify_member_avoir_ready:
|
||||||
subject: "Your FabLab's refund invoice"
|
subject: "Your FabLab's refund invoice"
|
||||||
body:
|
body:
|
||||||
|
@ -131,6 +131,12 @@ fr:
|
|||||||
invoice_in_your_dashboard_html: "Vous pouvez à tout moment retrouver votre facture dans %{DASHBOARD} sur le site du Fab Lab."
|
invoice_in_your_dashboard_html: "Vous pouvez à tout moment retrouver votre facture dans %{DASHBOARD} sur le site du Fab Lab."
|
||||||
your_dashboard: "votre tableau de bord"
|
your_dashboard: "votre tableau de bord"
|
||||||
|
|
||||||
|
notify_member_reservation_reminder:
|
||||||
|
subject: "Rappel de réservation"
|
||||||
|
body:
|
||||||
|
this_is_a_reminder_about_your_reservation_RESERVABLE_to_be_held_on_DATE_html: "Ceci est un rappel concernant votre réservation <strong>%{RESERVABLE}</strong> qui aura lieu le <em>%{DATE}</em>"
|
||||||
|
this_reservation_concerns_the_following_slots: "Cette réservation concerne les créneaux suivants :"
|
||||||
|
|
||||||
notify_member_avoir_ready:
|
notify_member_avoir_ready:
|
||||||
subject: "Votre facture d'avoir du FabLab"
|
subject: "Votre facture d'avoir du FabLab"
|
||||||
body:
|
body:
|
||||||
|
@ -19,4 +19,9 @@ open_api_trace_calls_count:
|
|||||||
cron: "0 4 * * 0" # every sunday at 4am
|
cron: "0 4 * * 0" # every sunday at 4am
|
||||||
class: "OpenAPITraceCallsCountWorker"
|
class: "OpenAPITraceCallsCountWorker"
|
||||||
|
|
||||||
|
reservation_reminder:
|
||||||
|
cron: "1 * * * *"
|
||||||
|
class: "ReservationReminderWorker"
|
||||||
|
queue: default
|
||||||
|
|
||||||
<%= PluginRegistry.insert_code('yml.schedule') %>
|
<%= PluginRegistry.insert_code('yml.schedule') %>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user