Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
folix-01 committed May 21, 2024
1 parent 3fb7fef commit ccf61d9
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,24 @@ def send_booking_reminder(context, event):
name="booking_transition_appio_sender",
)
sender_adapter.send()


@handle_exception_by_log
@notify_the_message_failure
def send_booking_removed(context, event):
if not booking_folder_provides_current_behavior(context):
return

message_adapter = getMultiAdapter(
(context, event),
IBookingAPPIoMessage,
name="removed_notification_appio_message",
)

if message_adapter and message_adapter.message:
sender_adapter = getMultiAdapter(
(message_adapter, context, getRequest()),
IBookingNotificationSender,
name="booking_transition_appio_sender",
)
sender_adapter.send()
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,27 @@ def subject(self) -> str:
"",
)
)


@implementer(IBookingAPPIoMessage)
@adapter(IPrenotazione, IBookingReminderEvent)
class PrenotazioneRemovedAppIOMessage(PrenotazioneAPPIoMessage):
@property
def message(self) -> str:
return IStringInterpolator(IContextWrapper(self.prenotazione)())(
getattr(
self.prenotazione.getPrenotazioniFolder(),
"notify_as_removed_appio_message",
"",
)
)

@property
def subject(self) -> str:
return IStringInterpolator(IContextWrapper(self.prenotazione)())(
getattr(
self.prenotazione.getPrenotazioniFolder(),
"notify_as_removed_appio_subject",
"",
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
redturtle.prenotazioni.interfaces.IBookingReminderEvent"
handler=".events.send_booking_reminder"
/>
<subscriber
for="redturtle.prenotazioni.content.prenotazione.IPrenotazione
zope.lifecycleevent.IObjectRemovedEvent"
handler=".events.send_booking_removed"
/>
<subscriber
for="redturtle.prenotazioni.content.prenotazione.IPrenotazione
Products.DCWorkflow.interfaces.IAfterTransitionEvent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,25 @@ def send_booking_reminder(context, event):
sender_adapter.send()


@notify_the_message_failure
def send_booking_removed(context, event):
if not booking_folder_provides_current_behavior(context):
return

message_adapter = getMultiAdapter(
(context, event),
IBookingEmailMessage,
name="removed_notification_email_message",
)
sender_adapter = getMultiAdapter(
(message_adapter, context, getRequest()),
IBookingNotificationSender,
name="booking_transition_email_sender",
)

sender_adapter.send()


def send_booking_canceled_to_managers(booking, event):
"""
Send email notification for managers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,3 +391,25 @@ def message(self) -> MIMEMultipart:
msg["Bcc"] = bcc

return msg


@implementer(IBookingEmailMessage)
@adapter(IPrenotazione, IBookingReminderEvent)
class PrenotazioneRemovedEmailMessage(PrenotazioneEmailMessage):
@property
def message_subject(self) -> str:
return IStringInterpolator(IContextWrapper(self.prenotazione)())(
getattr(self.prenotazioni_folder, "notify_as_removed_subject", "")
)

@property
def message_text(self) -> MIMEText:
text = IStringInterpolator(IContextWrapper(self.prenotazione)())(
getattr(self.prenotazioni_folder, "notify_as_removed_message", None),
)
if CTE:
cs = Charset("utf-8")
cs.body_encoding = CTE # e.g. 'base64'
return MIMEText(text, "html", cs)
else:
return MIMEText(text, "html")
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,23 @@ def send_booking_reminder(context, event):
name="booking_transition_sms_sender",
)
sender_adapter.send()


@handle_exception_by_log
@notify_the_message_failure
def send_booking_removed(context, event):
if not booking_folder_provides_current_behavior(context):
return

message_adapter = getMultiAdapter(
(context, event),
IBookingSMSMessage,
name="removed_notification_sms_message",
)
if message_adapter and message_adapter.message:
sender_adapter = getMultiAdapter(
(message_adapter, context, getRequest()),
IBookingNotificationSender,
name="booking_transition_sms_sender",
)
sender_adapter.send()
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,23 @@ def message_history(self) -> str:
return api.portal.translate(
_("history_sms_reminder_sent", default="SMS reminder was sent")
)


@implementer(IBookingSMSMessage)
@adapter(IPrenotazione, IBookingReminderEvent)
class PrenotazioneRemovedSMSMessage(PrenotazioneSMSMessage):
@property
def message(self) -> str:
return IStringInterpolator(IContextWrapper(self.prenotazione)())(
getattr(
self.prenotazione.getPrenotazioniFolder(),
"notify_as_removed_sms_message",
"",
)
)

@property
def message_history(self) -> str:
return api.portal.translate(
_("history_sms_removed_sent", default="SMS removed notification was sent")
)

0 comments on commit ccf61d9

Please sign in to comment.