Mail sending

* adds mail sending logic for new notification setting
* adds new templates for user and team based sending
* enhances all email template layout
* adds translations
This commit is contained in:
2022-08-10 08:59:24 +02:00
parent 3d10e84852
commit 890911c2dc
23 changed files with 300 additions and 22 deletions

View File

@@ -207,6 +207,33 @@ class Mailer:
msg
)
def send_mail_deduction_changed_team(self, obj_identifier, obj_title, team, 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
team (Team): Team to be notified
data_changes (dict): Contains the old|new changes of the deduction changes
Returns:
"""
context = {
"team": team,
"obj_identifier": obj_identifier,
"obj_title": obj_title,
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
"data_changes": data_changes,
}
msg = render_to_string("email/other/deduction_changed_team.html", context)
user_mail_address = team.users.values_list("email", flat=True)
self.send(
user_mail_address,
_("{} - Deduction changed").format(obj_identifier),
msg
)
def send_mail_shared_data_deleted_team(self, obj_identifier, obj_title, team):
""" Send a mail if data has just been deleted
@@ -322,6 +349,34 @@ class Mailer:
msg
)
def send_mail_deduction_changed(self, obj_identifier, obj_title, 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
user (User): User to be notified
data_changes (dict): Contains the old|new changes of the deduction changes
Returns:
"""
context = {
"user": user,
"obj_identifier": obj_identifier,
"obj_title": obj_title,
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
"data_changes": data_changes,
}
msg = render_to_string("email/other/deduction_changed.html", context)
user_mail_address = [user.email]
self.send(
user_mail_address,
_("{} - Deduction changed").format(obj_identifier),
msg
)
def send_mail_verify_api_token(self, user):
""" Send a mail if a user creates a new token