diff --git a/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/appio/__init__.py b/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/appio/__init__.py
index 64ab14eb..e6249a55 100644
--- a/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/appio/__init__.py
+++ b/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/appio/__init__.py
@@ -95,6 +95,26 @@ def notify_on_refuse_appio_message_default_factory(context):
)
+@provider(IContextAwareDefaultFactory)
+def notify_on_cancel_appio_subject_default_factory(context):
+ return api.portal.translate(
+ _(
+ "notify_on_cancel_appio_subject_default_value",
+ "[${prenotazioni_folder_title}] Booking canceled for ${title}",
+ )
+ )
+
+
+@provider(IContextAwareDefaultFactory)
+def notify_on_cancel_appio_message_default_factory(context):
+ return api.portal.translate(
+ _(
+ "notify_on_cancel_appio_message_default_value",
+ "The booking ${booking_type} of ${booking_date} at ${booking_time} was canceled.",
+ )
+ )
+
+
@provider(IContextAwareDefaultFactory)
def notify_as_reminder_appio_subject_default_factory(context):
return api.portal.translate(
@@ -223,6 +243,30 @@ class INotificationAppIO(model.Schema):
defaultFactory=notify_on_refuse_appio_message_default_factory,
required=False,
)
+ notify_on_cancel_appio_subject = schema.Text(
+ title=_(
+ "notify_on_cancel_subject",
+ default="[Cancel] subject",
+ ),
+ description=_(
+ "notify_on_cancel_subject_help",
+ default="The message subject when a booking has been canceled.",
+ ),
+ defaultFactory=notify_on_cancel_appio_subject_default_factory,
+ required=False,
+ )
+ notify_on_cancel_appio_message = schema.Text(
+ title=_(
+ "notify_on_cancel_message",
+ default="[Cancel] message",
+ ),
+ description=_(
+ "notify_on_cancel_message_help",
+ default="The message text when a booking has been canceled.",
+ ),
+ defaultFactory=notify_on_cancel_appio_message_default_factory,
+ required=False,
+ )
notify_as_reminder_appio_subject = schema.Text(
title=_(
"notify_as_reminder_subject",
@@ -268,6 +312,8 @@ class INotificationAppIO(model.Schema):
"notify_on_move_appio_message",
"notify_on_refuse_appio_subject",
"notify_on_refuse_appio_message",
+ "notify_on_cancel_appio_subject",
+ "notify_on_cancel_appio_message",
"notify_as_reminder_appio_subject",
"notify_as_reminder_appio_message",
],
diff --git a/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/appio/adapters.py b/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/appio/adapters.py
index 44467414..2ab5614e 100644
--- a/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/appio/adapters.py
+++ b/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/appio/adapters.py
@@ -47,6 +47,9 @@ def __init__(self, message_adapter, booking, request) -> None:
self.request = request
def send(self) -> bool:
+ import pdb
+
+ pdb.set_trace()
from .. import write_message_to_object_history
supervisor = getUtility(IBookingNotificatorSupervisorUtility)
diff --git a/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/email/__init__.py b/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/email/__init__.py
index 7dc3a96c..d724419c 100644
--- a/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/email/__init__.py
+++ b/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/email/__init__.py
@@ -95,6 +95,26 @@ def notify_on_refuse_message_default_factory(context):
)
+@provider(IContextAwareDefaultFactory)
+def notify_on_cancel_subject_default_factory(context):
+ return api.portal.translate(
+ _(
+ "notify_on_cancel_subject_default_value",
+ "[${prenotazioni_folder_title}] Booking canceled for ${title}",
+ )
+ )
+
+
+@provider(IContextAwareDefaultFactory)
+def notify_on_cancel_message_default_factory(context):
+ return api.portal.translate(
+ _(
+ "notify_on_cancel_message_default_value",
+ "The booking ${booking_type} of ${booking_date} at ${booking_time} was canceled.",
+ )
+ )
+
+
@provider(IContextAwareDefaultFactory)
def notify_as_reminder_subject_default_factory(context):
return api.portal.translate(
@@ -232,6 +252,30 @@ class INotificationEmail(model.Schema):
defaultFactory=notify_on_refuse_message_default_factory,
required=False,
)
+ notify_on_cancel_subject = schema.TextLine(
+ title=_(
+ "notify_on_cancel_subject",
+ default="[Cancel] subject",
+ ),
+ description=_(
+ "notify_on_cancel_subject_help",
+ default="The message subject when a booking has been canceled.",
+ ),
+ defaultFactory=notify_on_cancel_subject_default_factory,
+ required=False,
+ )
+ notify_on_cancel_message = schema.Text(
+ title=_(
+ "notify_on_cancel_message",
+ default="[Cancel] message",
+ ),
+ description=_(
+ "notify_on_cancel_message_help",
+ default="The message text when a booking has been canceled.",
+ ),
+ defaultFactory=notify_on_cancel_message_default_factory,
+ required=False,
+ )
notify_as_reminder_subject = schema.TextLine(
title=_(
"notify_as_reminder_subject",
@@ -278,6 +322,8 @@ class INotificationEmail(model.Schema):
"notify_on_move_message",
"notify_on_refuse_subject",
"notify_on_refuse_message",
+ "notify_on_cancel_subject",
+ "notify_on_cancel_message",
"notify_as_reminder_subject",
"notify_as_reminder_message",
],
diff --git a/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/email/adapters.py b/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/email/adapters.py
index 87c80dce..a7ba909b 100644
--- a/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/email/adapters.py
+++ b/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/email/adapters.py
@@ -28,6 +28,9 @@ def send(self, force=False):
If True, the message will be sent even if the email is not allowed
(ie. for operator notifications)
"""
+ import pdb
+
+ pdb.set_trace()
message = self.message_adapter.message
if force or getUtility(
diff --git a/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/email/configure.zcml b/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/email/configure.zcml
index 673151bb..4fddc230 100644
--- a/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/email/configure.zcml
+++ b/src/redturtle/prenotazioni/behaviors/booking_folder/notifications/email/configure.zcml
@@ -31,11 +31,6 @@
redturtle.prenotazioni.interfaces.IBookingReminderEvent"
handler=".events.send_booking_reminder"
/>
-
None:
self.request = request
def send(self):
+ import pdb
+
+ pdb.set_trace()
if self.is_notification_allowed():
# dont foget to write the history log about sending
# self.write_message_to_booking_history(self.booking, self.message_adapter.message_history)
diff --git a/src/redturtle/prenotazioni/content/prenotazioni_folder.py b/src/redturtle/prenotazioni/content/prenotazioni_folder.py
index 65c4745a..def41f69 100644
--- a/src/redturtle/prenotazioni/content/prenotazioni_folder.py
+++ b/src/redturtle/prenotazioni/content/prenotazioni_folder.py
@@ -468,6 +468,15 @@ def data_validation(data):
default=False,
required=False,
)
+ notify_on_cancel = schema.Bool(
+ title=_("notify_on_cancel", default="Notify when canceled."),
+ description=_(
+ "notify_on_cancel_help",
+ default="Notify via mail the user when his booking has been canceled.",
+ ),
+ default=False,
+ required=False,
+ )
max_bookings_allowed = schema.Int(
title=_(
"max_bookings_allowed_label",
@@ -540,6 +549,7 @@ def data_validation(data):
"notify_on_confirm",
"notify_on_move",
"notify_on_refuse",
+ "notify_on_cancel",
],
)
@@ -582,7 +592,7 @@ def get_booking_types(self) -> Generator[PrenotazioneType, None, None]:
def get_notification_flags(self):
return {
action: getattr(self, f"notify_on_{action}", False)
- for action in ("confirm", "submit", "refuse")
+ for action in ("confirm", "submit", "refuse", "cancel")
}
# BBB: compatibility with old code (booking_types was a List of IBookingTypeRow)