-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Booking notfications refactor + reminders * Some fixes and removed old appIO field (#142) * remove unused field for appIO * fix some logic and typos * Update sms limit * Refactoring * Refactoring * Notifications labels fix (#145) * initial fixes * fix labels * improved email notifications labels and default values * handle missing config * fix labels and translations * fix labels * Revert "initial fixes" This reverts commit cb95522. * fix translations * fix fieldsets * Refactoring * Update readme * Fix readme * Update schema * Fux AppIO call * Fix AppIO call * Fix AppIO subscription check * Fix AppIO call * Use the logstorage for appio api call * Update notification_sms.py * Update locales * Update locales * Fix notifications supervisor logics * Fix * Update messages * Fix * Fix code * Fix locales * Remove sms max length * Fix * Fix locales * Force booking notification to managers * Turn off the AppIO notifications integration by default * Fix naming * Fix naming * Fix namin g * Update readme * Update readme * typo * version * fix tests * fix tests * cleanup * fix readme + demo profile * locales * zpretty * logging * fix demo + readme * sms_locales * remove unused content rules * rename * add sms notify tests * rename * zpretty * fix notifiche sms move * changelog * black --------- Co-authored-by: Andrea Cecchi <[email protected]> Co-authored-by: Mauro Amico <[email protected]>
- Loading branch information
1 parent
af35c5d
commit adcde26
Showing
82 changed files
with
4,631 additions
and
2,465 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/redturtle/prenotazioni/behaviors/booking_folder/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# -*- coding: utf-8 -*- | ||
from .appio.adapters import app_io_allowed_for | ||
|
||
|
||
def get_booking_folder_notification_flags(booking_folder): | ||
return { | ||
i: getattr(booking_folder, f"notify_on_{i}", False) | ||
for i in ("confirm", "submit", "refuse") | ||
} | ||
|
||
|
||
class BookingNotificationSupervisorUtility: | ||
"""Supervisor to allow/deny the specific | ||
notification type according to business logic""" | ||
|
||
def is_email_message_allowed(self, booking): | ||
if getattr( | ||
booking.getPrenotazioniFolder(), "notifications_email_enabled", False | ||
) and getattr(booking, "email", None): | ||
return True | ||
|
||
return False | ||
|
||
# NOTE: Will be extended in the future | ||
def is_appio_message_allowed(self, booking): | ||
if not getattr( | ||
booking.getPrenotazioniFolder(), "notifications_appio_enabled", False | ||
): | ||
return False | ||
|
||
if not booking.fiscalcode: | ||
return False | ||
|
||
return True | ||
|
||
def app_io_allowed_for(sefl, fiscalcode, service_code): | ||
return app_io_allowed_for(fiscalcode, service_code=service_code) | ||
|
||
def is_sms_message_allowed(self, booking): | ||
if not getattr( | ||
booking.getPrenotazioniFolder(), "notifications_sms_enabled", False | ||
): | ||
return False | ||
|
||
if not booking.phone: | ||
return False | ||
|
||
if self.is_email_message_allowed(booking): | ||
return False | ||
|
||
# if user is potentially notified by App IO, do not send sms | ||
if self.is_appio_message_allowed(booking): | ||
# XXX: questo sarebbe dovuto essere nell'adapter per App IO, ma l'adapter | ||
# richiede a suo volta un message_adapter ... | ||
booking_type = booking.get_booking_type() | ||
service_code = getattr(booking_type, "service_code", None) | ||
fiscalcode = getattr(booking, "fiscalcode", None) | ||
if ( | ||
fiscalcode | ||
and service_code | ||
and self.app_io_allowed_for(fiscalcode, service_code) | ||
): | ||
return False | ||
|
||
return True |
Oops, something went wrong.