Object mailing restructred

* restructures object info mail sending
This commit is contained in:
2023-12-11 12:06:33 +01:00
parent 75ab281799
commit 743bb320d7
21 changed files with 196 additions and 224 deletions

View File

@@ -45,12 +45,11 @@ class Mailer:
auth_password=self.auth_password
)
def send_mail_shared_access_removed(self, obj_identifier, obj_title, user, municipals_names):
def send_mail_shared_access_removed(self, obj, user, municipals_names):
""" Send a mail if user has no access to the object anymore
Args:
obj_identifier (str): The object identifier
obj_title (str): The object title
obj (): The object
user (User): Related user
municipals_names (iterable): List of municipals of the entry
@@ -59,8 +58,7 @@ class Mailer:
"""
context = {
"user": user,
"obj_identifier": obj_identifier,
"obj_title": obj_title,
"obj": obj,
"municipals_names": municipals_names,
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
}
@@ -68,16 +66,15 @@ class Mailer:
user_mail_address = [user.email]
self.send(
user_mail_address,
_("{} - Shared access removed").format(obj_identifier),
_("{} - Shared access removed").format(obj.identifier),
msg
)
def send_mail_shared_access_given(self, obj_identifier, obj_title, user, municipals_names):
def send_mail_shared_access_given(self, obj, user, municipals_names):
""" Send a mail if user just got access to the object
Args:
obj_identifier (str): The object identifier
obj_title (str): The object title
obj (): The object
user (User): The related user
municipals_names (iterable): List of municipals for this entry
@@ -86,8 +83,7 @@ class Mailer:
"""
context = {
"user": user,
"obj_identifier": obj_identifier,
"obj_title": obj_title,
"obj": obj,
"municipals_names": municipals_names,
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
}
@@ -95,16 +91,15 @@ class Mailer:
user_mail_address = [user.email]
self.send(
user_mail_address,
_("{} - Shared access given").format(obj_identifier),
_("{} - Shared access given").format(obj.identifier),
msg
)
def send_mail_shared_access_given_team(self, obj_identifier, obj_title, team, users_to_notify, municipals_names):
def send_mail_shared_access_given_team(self, obj, team, users_to_notify, municipals_names):
""" Send a mail if a team just got access to the object
Args:
obj_identifier (str): The object identifier
obj_title (str): Title of the main object
obj (): The object
team (Team): Team to be notified
users_to_notify (QueryDict): Contains the team users which should be notified
municipals_names (iterable): List of municipals for this entry
@@ -114,8 +109,7 @@ class Mailer:
"""
context = {
"team": team,
"obj_identifier": obj_identifier,
"obj_title": obj_title,
"obj": obj,
"municipals_names": municipals_names,
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
}
@@ -123,16 +117,15 @@ class Mailer:
user_mail_address = users_to_notify.values_list("email", flat=True)
self.send(
user_mail_address,
_("{} - Shared access given").format(obj_identifier),
_("{} - Shared access given").format(obj.identifier),
msg
)
def send_mail_shared_access_removed_team(self, obj_identifier, obj_title, team, users_to_notify, municipals_names):
def send_mail_shared_access_removed_team(self, obj, team, users_to_notify, municipals_names):
""" Send a mail if a team just lost access to the object
Args:
obj_identifier (str): The object identifier
obj_title (str): Title of the main object
obj (): The object
team (Team): Team to be notified
users_to_notify (QueryDict): Contains the team users which should be notified
municipals_names (iterable): List of municipals for this entry
@@ -142,8 +135,7 @@ class Mailer:
"""
context = {
"team": team,
"obj_identifier": obj_identifier,
"obj_title": obj_title,
"obj": obj,
"municipals_names": municipals_names,
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
}
@@ -151,16 +143,15 @@ class Mailer:
user_mail_address = users_to_notify.values_list("email", flat=True)
self.send(
user_mail_address,
_("{} - Shared access removed").format(obj_identifier),
_("{} - Shared access removed").format(obj.identifier),
msg
)
def send_mail_shared_data_unrecorded_team(self, obj_identifier, obj_title, team, users_to_notify, municipals_names):
def send_mail_shared_data_unrecorded_team(self,obj, team, users_to_notify, municipals_names):
""" Send a mail if data has just been unrecorded
Args:
obj_identifier (str): The object identifier
obj_title (str): Title of the main object
obj (): The object
team (Team): Team to be notified
users_to_notify (QueryDict): Contains the team users which should be notified
municipals_names (iterable): List of municipals for this entry
@@ -170,8 +161,7 @@ class Mailer:
"""
context = {
"team": team,
"obj_identifier": obj_identifier,
"obj_title": obj_title,
"obj": obj,
"municipals_names": municipals_names,
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
}
@@ -179,16 +169,15 @@ class Mailer:
user_mail_address = users_to_notify.values_list("email", flat=True)
self.send(
user_mail_address,
_("{} - Shared data unrecorded").format(obj_identifier),
_("{} - Shared data unrecorded").format(obj.identifier),
msg
)
def send_mail_shared_data_recorded_team(self, obj_identifier, obj_title, team, users_to_notify, municipals_names):
def send_mail_shared_data_recorded_team(self, obj, team, users_to_notify, municipals_names):
""" Send a mail if data has just been recorded
Args:
obj_identifier (str): The object identifier
obj_title (str): Title of the main object
obj (): The object
team (Team): Team to be notified
users_to_notify (QueryDict): Contains the team users which should be notified
municipals_names (iterable): List of municipals for this entry
@@ -198,8 +187,7 @@ class Mailer:
"""
context = {
"team": team,
"obj_identifier": obj_identifier,
"obj_title": obj_title,
"obj": obj,
"municipals_names": municipals_names,
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
}
@@ -207,16 +195,15 @@ class Mailer:
user_mail_address = users_to_notify.values_list("email", flat=True)
self.send(
user_mail_address,
_("{} - Shared data recorded").format(obj_identifier),
_("{} - Shared data recorded").format(obj.identifier),
msg
)
def send_mail_shared_data_checked_team(self, obj_identifier, obj_title, team, users_to_notify, municipals_names):
def send_mail_shared_data_checked_team(self, obj, team, users_to_notify, municipals_names):
""" Send a mail if data has just been checked
Args:
obj_identifier (str): The object identifier
obj_title (str): Title of the main object
obj (): The object
team (Team): Team to be notified
users_to_notify (QueryDict): Contains the team users which should be notified
municipals_names (iterable): List of municipals for this entry
@@ -226,8 +213,7 @@ class Mailer:
"""
context = {
"team": team,
"obj_identifier": obj_identifier,
"obj_title": obj_title,
"obj": obj,
"municipals_names": municipals_names,
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
}
@@ -235,16 +221,15 @@ class Mailer:
user_mail_address = users_to_notify.values_list("email", flat=True)
self.send(
user_mail_address,
_("{} - Shared data checked").format(obj_identifier),
_("{} - Shared data checked").format(obj.identifier),
msg
)
def send_mail_deduction_changed_team(self, obj_identifier, obj_title, team, data_changes, users_to_notify):
def send_mail_deduction_changed_team(self, obj, team, data_changes, users_to_notify):
""" Send a mail if deduction has been changed
Args:
obj_identifier (str): Identifier of the main object
obj_title (str): Title of the main object
obj (): The object
team (Team): Team to be notified
data_changes (dict): Contains the old|new changes of the deduction changes
users_to_notify (QueryDict): Contains the team users which should be notified
@@ -253,8 +238,7 @@ class Mailer:
"""
context = {
"team": team,
"obj_identifier": obj_identifier,
"obj_title": obj_title,
"obj": obj,
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
"data_changes": data_changes,
}
@@ -262,16 +246,15 @@ class Mailer:
user_mail_address = users_to_notify.values_list("email", flat=True)
self.send(
user_mail_address,
_("{} - Deduction changed").format(obj_identifier),
_("{} - Deduction changed").format(obj.identifier),
msg
)
def send_mail_shared_data_deleted_team(self, obj_identifier, obj_title, team, users_to_notify, municipals_names):
def send_mail_shared_data_deleted_team(self, obj, team, users_to_notify, municipals_names):
""" Send a mail if data has just been deleted
Args:
obj_identifier (str): The object identifier
obj_title (str): The object title
obj (): The object
team (Team): The related team
users_to_notify (QuerySet): Contains team users who want to be notified
municipals_names (iterable): List of municipals for the entry
@@ -281,8 +264,7 @@ class Mailer:
"""
context = {
"team": team,
"obj_identifier": obj_identifier,
"obj_title": obj_title,
"obj": obj,
"municipals_names": municipals_names,
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
}
@@ -290,16 +272,15 @@ class Mailer:
user_mail_address = users_to_notify.values_list("email", flat=True)
self.send(
user_mail_address,
_("{} - Shared data deleted").format(obj_identifier),
_("{} - Shared data deleted").format(obj.identifier),
msg
)
def send_mail_shared_data_recorded(self, obj_identifier, obj_title, user, municipals_names):
def send_mail_shared_data_recorded(self, obj, user, municipals_names):
""" Send a mail if the user's shared data has just been unrecorded
Args:
obj_identifier (str): The object identifier
obj_title (str): The object title
obj (): The object
user (User): The related user
municipals_names (iterable): List of municipals for this entry
@@ -308,8 +289,7 @@ class Mailer:
"""
context = {
"user": user,
"obj_identifier": obj_identifier,
"obj_title": obj_title,
"obj": obj,
"municipals_names": municipals_names,
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
}
@@ -317,16 +297,15 @@ class Mailer:
user_mail_address = [user.email]
self.send(
user_mail_address,
_("{} - Shared data recorded").format(obj_identifier),
_("{} - Shared data recorded").format(obj.identifier),
msg
)
def send_mail_shared_data_unrecorded(self, obj_identifier, obj_title, user, municipals_names):
def send_mail_shared_data_unrecorded(self, obj, user, municipals_names):
""" Send a mail if the user's shared data has just been unrecorded
Args:
obj_identifier (str): The object identifier
obj_title (str): The object title
obj (): The object
user (User): The related user
municipals_names (iterable): List of municipals for this entry
@@ -335,8 +314,7 @@ class Mailer:
"""
context = {
"user": user,
"obj_identifier": obj_identifier,
"obj_title": obj_title,
"obj": obj,
"municipals_names": municipals_names,
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
}
@@ -344,16 +322,15 @@ class Mailer:
user_mail_address = [user.email]
self.send(
user_mail_address,
_("{} - Shared data unrecorded").format(obj_identifier),
_("{} - Shared data unrecorded").format(obj.identifier),
msg
)
def send_mail_shared_data_deleted(self, obj_identifier, obj_title, user, municipals_names):
def send_mail_shared_data_deleted(self, obj, user, municipals_names):
""" Send a mail if shared data has just been deleted
Args:
obj_identifier (str): The object identifier
obj_title (str): The object title
obj (): The object
user (User): The related user
municipals_names (iterable): List of municipals for this entry
@@ -362,8 +339,7 @@ class Mailer:
"""
context = {
"user": user,
"obj_identifier": obj_identifier,
"obj_title": obj_title,
"obj": obj,
"municipals_names": municipals_names,
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
}
@@ -371,16 +347,15 @@ class Mailer:
user_mail_address = [user.email]
self.send(
user_mail_address,
_("{} - Shared data deleted").format(obj_identifier),
_("{} - Shared data deleted").format(obj.identifier),
msg
)
def send_mail_shared_data_checked(self, obj_identifier, obj_title, user, municipals_names):
def send_mail_shared_data_checked(self, obj, user, municipals_names):
""" Send a mail if shared data just has been checked
Args:
obj_identifier (str): The object identifier
obj_title (str): The object title
obj (): The object
user (User): The related user
municipals_names (iterable): List of municipals for this entry
@@ -389,8 +364,7 @@ class Mailer:
"""
context = {
"user": user,
"obj_identifier": obj_identifier,
"obj_title": obj_title,
"obj": obj,
"municipals_names": municipals_names,
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
}
@@ -398,16 +372,15 @@ class Mailer:
user_mail_address = [user.email]
self.send(
user_mail_address,
_("{} - Shared data checked").format(obj_identifier),
_("{} - Shared data checked").format(obj.identifier),
msg
)
def send_mail_deduction_changed(self, obj_identifier, obj_title, user, data_changes):
def send_mail_deduction_changed(self, obj, user, data_changes):
""" Send a mail if deduction has been changed
Args:
obj_identifier (str): Identifier of the main object
obj_title (str): Title of the main object
obj (): The object
user (User): User to be notified
data_changes (dict): Contains the old|new changes of the deduction changes
@@ -417,8 +390,7 @@ class Mailer:
"""
context = {
"user": user,
"obj_identifier": obj_identifier,
"obj_title": obj_title,
"obj": obj,
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
"data_changes": data_changes,
}
@@ -426,7 +398,7 @@ class Mailer:
user_mail_address = [user.email]
self.send(
user_mail_address,
_("{} - Deduction changed").format(obj_identifier),
_("{} - Deduction changed").format(obj.identifier),
msg
)
@@ -451,11 +423,11 @@ class Mailer:
msg
)
def send_mail_resubmission(self, obj_identifier, resubmission, municipals_names):
def send_mail_resubmission(self, obj, resubmission, municipals_names):
""" Send a resubmission mail for a user
Args:
obj_identifier (str): The (resubmitted) object's identifier
obj (): The (resubmitted) object
resubmission (Resubmission): The resubmission
municipals_names (iterable): List of municipals for this entry
@@ -463,7 +435,7 @@ class Mailer:
"""
context = {
"obj_identifier": obj_identifier,
"obj": obj,
"resubmission": resubmission,
"municipals_names": municipals_names,
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
@@ -472,7 +444,7 @@ class Mailer:
user_mail_address = [resubmission.user.email]
self.send(
user_mail_address,
_("Resubmission - {}").format(obj_identifier),
_("Resubmission - {}").format(obj.identifier),
msg
)