#300 Extend mail templates

* extends all relevant mail templates such that municipals of an entry will be shown in the mail
This commit is contained in:
2023-02-23 10:17:45 +01:00
parent e1259b276c
commit bf41559c56
23 changed files with 383 additions and 158 deletions

View File

@@ -31,12 +31,13 @@ class Team(UuidModel, DeletableObjectMixin):
self.deleted = delete_action
self.save()
def send_mail_shared_access_given_team(self, obj_identifier, obj_title):
def send_mail_shared_access_given_team(self, obj_identifier, obj_title, municipals_names):
""" Sends a mail to the team members in case of given shared access
Args:
obj_identifier ():
obj_title ():
obj_identifier (str): The entry identifier
obj_title (str): The entry title
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -45,14 +46,15 @@ class Team(UuidModel, DeletableObjectMixin):
users_to_notify = self.users.filter(
notifications__in=[UserNotificationEnum.NOTIFY_ON_SHARED_ACCESS_GAINED.value]
)
mailer.send_mail_shared_access_given_team(obj_identifier, obj_title, self, users_to_notify)
mailer.send_mail_shared_access_given_team(obj_identifier, obj_title, self, users_to_notify, municipals_names)
def send_mail_shared_access_removed(self, obj_identifier, obj_title):
def send_mail_shared_access_removed(self, obj_identifier, obj_title, municipals_names):
""" Sends a mail to the team members in case of removed shared access
Args:
obj_identifier ():
obj_title ():
obj_identifier (str): The entry identifier
obj_title (str): The entry title
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -61,14 +63,15 @@ class Team(UuidModel, DeletableObjectMixin):
users_to_notify = self.users.filter(
notifications__in=[UserNotificationEnum.NOTIFY_ON_SHARED_ACCESS_REMOVED.value]
)
mailer.send_mail_shared_access_removed_team(obj_identifier, obj_title, self, users_to_notify)
mailer.send_mail_shared_access_removed_team(obj_identifier, obj_title, self, users_to_notify, municipals_names)
def send_mail_shared_data_unrecorded(self, obj_identifier, obj_title):
def send_mail_shared_data_unrecorded(self, obj_identifier, obj_title, municipals_names):
""" Sends a mail to the team members in case of unrecorded data
Args:
obj_identifier ():
obj_title ():
obj_identifier (str): The entry identifier
obj_title (str): The entry title
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -77,14 +80,15 @@ class Team(UuidModel, DeletableObjectMixin):
users_to_notify = self.users.filter(
notifications__in=[UserNotificationEnum.NOTIFY_ON_SHARED_DATA_RECORDED.value]
)
mailer.send_mail_shared_data_unrecorded_team(obj_identifier, obj_title, self, users_to_notify)
mailer.send_mail_shared_data_unrecorded_team(obj_identifier, obj_title, self, users_to_notify, municipals_names)
def send_mail_shared_data_recorded(self, obj_identifier, obj_title):
def send_mail_shared_data_recorded(self, obj_identifier, obj_title, municipals_names):
""" Sends a mail to the team members in case of unrecorded data
Args:
obj_identifier ():
obj_title ():
obj_identifier (str): The entry identifier
obj_title (str): The entry title
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -93,14 +97,15 @@ class Team(UuidModel, DeletableObjectMixin):
users_to_notify = self.users.filter(
notifications__in=[UserNotificationEnum.NOTIFY_ON_SHARED_DATA_RECORDED.value]
)
mailer.send_mail_shared_data_recorded_team(obj_identifier, obj_title, self, users_to_notify)
mailer.send_mail_shared_data_recorded_team(obj_identifier, obj_title, self, users_to_notify, municipals_names)
def send_mail_shared_data_checked(self, obj_identifier, obj_title):
def send_mail_shared_data_checked(self, obj_identifier, obj_title, municipals_names):
""" Sends a mail to the team members in case of checked data
Args:
obj_identifier ():
obj_title ():
obj_identifier (str): The entry identifier
obj_title (str): The entry title
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -109,7 +114,7 @@ class Team(UuidModel, DeletableObjectMixin):
users_to_notify = self.users.filter(
notifications__in=[UserNotificationEnum.NOTIFY_ON_SHARED_DATA_CHECKED.value]
)
mailer.send_mail_shared_data_checked_team(obj_identifier, obj_title, self, users_to_notify)
mailer.send_mail_shared_data_checked_team(obj_identifier, obj_title, self, users_to_notify, municipals_names)
def send_mail_deduction_changed(self, obj_identifier, obj_title, data_changes):
""" Sends a mail to the team members in case of changed deduction values
@@ -128,12 +133,13 @@ class Team(UuidModel, DeletableObjectMixin):
)
mailer.send_mail_deduction_changed_team(obj_identifier, obj_title, self, data_changes, users_to_notify)
def send_mail_shared_data_deleted(self, obj_identifier, obj_title):
def send_mail_shared_data_deleted(self, obj_identifier, obj_title, municipals_names):
""" Sends a mail to the team members in case of deleted data
Args:
obj_identifier ():
obj_title ():
obj_identifier (str): The entry identifier
obj_title (str): The entry title
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -142,7 +148,7 @@ class Team(UuidModel, DeletableObjectMixin):
users_to_notify = self.users.filter(
notifications__in=[UserNotificationEnum.NOTIFY_ON_SHARED_DATA_DELETED.value]
)
mailer.send_mail_shared_data_deleted_team(obj_identifier, obj_title, self, users_to_notify)
mailer.send_mail_shared_data_deleted_team(obj_identifier, obj_title, self, users_to_notify, municipals_names)
def remove_user(self, user):
""" Removes a user from the team

View File

@@ -60,12 +60,13 @@ class User(AbstractUser):
name=ETS_GROUP
).exists()
def send_mail_shared_access_removed(self, obj_identifier, obj_title):
def send_mail_shared_access_removed(self, obj_identifier, obj_title, municipals_names):
""" Sends a mail to the user in case of removed shared access
Args:
obj_identifier ():
obj_title ():
municipals_names ():
Returns:
@@ -73,13 +74,15 @@ class User(AbstractUser):
notification_set = self.is_notification_setting_set(UserNotificationEnum.NOTIFY_ON_SHARED_ACCESS_REMOVED)
if notification_set:
mailer = Mailer()
mailer.send_mail_shared_access_removed(obj_identifier, obj_title, self)
mailer.send_mail_shared_access_removed(obj_identifier, obj_title, self, municipals_names)
def send_mail_shared_access_given(self, obj_identifier, obj_title):
def send_mail_shared_access_given(self, obj_identifier, obj_title, municipals_names):
""" Sends a mail to the user in case of given shared access
Args:
obj_identifier ():
obj_identifier (str): The entry identifier
obj_title (str): The entry title
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -87,13 +90,15 @@ class User(AbstractUser):
notification_set = self.is_notification_setting_set(UserNotificationEnum.NOTIFY_ON_SHARED_ACCESS_GAINED)
if notification_set:
mailer = Mailer()
mailer.send_mail_shared_access_given(obj_identifier, obj_title, self)
mailer.send_mail_shared_access_given(obj_identifier, obj_title, self, municipals_names)
def send_mail_shared_data_recorded(self, obj_identifier, obj_title):
def send_mail_shared_data_recorded(self, obj_identifier, obj_title, municipals_names):
""" Sends a mail to the user in case of shared data has been recorded
Args:
obj_identifier ():
obj_identifier (str): The entry identifier
obj_title (str): The entry title
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -101,13 +106,15 @@ class User(AbstractUser):
notification_set = self.is_notification_setting_set(UserNotificationEnum.NOTIFY_ON_SHARED_DATA_RECORDED)
if notification_set:
mailer = Mailer()
mailer.send_mail_shared_data_recorded(obj_identifier, obj_title, self)
mailer.send_mail_shared_data_recorded(obj_identifier, obj_title, self, municipals_names)
def send_mail_shared_data_unrecorded(self, obj_identifier, obj_title):
def send_mail_shared_data_unrecorded(self, obj_identifier, obj_title, municipals_names):
""" Sends a mail to the user in case of shared data has been unrecorded
Args:
obj_identifier ():
obj_identifier (str): The entry identifier
obj_title (str): The entry title
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -115,13 +122,15 @@ class User(AbstractUser):
notification_set = self.is_notification_setting_set(UserNotificationEnum.NOTIFY_ON_SHARED_DATA_RECORDED)
if notification_set:
mailer = Mailer()
mailer.send_mail_shared_data_unrecorded(obj_identifier, obj_title, self)
mailer.send_mail_shared_data_unrecorded(obj_identifier, obj_title, self, municipals_names)
def send_mail_shared_data_deleted(self, obj_identifier, obj_title):
def send_mail_shared_data_deleted(self, obj_identifier, obj_title, municipals_names):
""" Sends a mail to the user in case of shared data has been deleted
Args:
obj_identifier ():
obj_identifier (str): The entry identifier
obj_title (str): The entry title
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -129,13 +138,15 @@ class User(AbstractUser):
notification_set = self.is_notification_setting_set(UserNotificationEnum.NOTIFY_ON_SHARED_DATA_DELETED)
if notification_set:
mailer = Mailer()
mailer.send_mail_shared_data_deleted(obj_identifier, obj_title, self)
mailer.send_mail_shared_data_deleted(obj_identifier, obj_title, self, municipals_names)
def send_mail_shared_data_checked(self, obj_identifier, obj_title):
def send_mail_shared_data_checked(self, obj_identifier, obj_title, municipals_names):
""" Sends a mail to the user in case of shared data has been deleted
Args:
obj_identifier ():
obj_identifier (str): The entry identifier
obj_title (str): The entry title
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -143,7 +154,7 @@ class User(AbstractUser):
notification_set = self.is_notification_setting_set(UserNotificationEnum.NOTIFY_ON_SHARED_DATA_CHECKED)
if notification_set:
mailer = Mailer()
mailer.send_mail_shared_data_checked(obj_identifier, obj_title, self)
mailer.send_mail_shared_data_checked(obj_identifier, obj_title, self, municipals_names)
def send_mail_deduction_changed(self, obj_identifier, obj_title, data_changes):
""" Sends a mail to the user in case of a changed deduction