#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

@@ -120,13 +120,14 @@ class DeletableObjectMixin(models.Model):
if send_mail:
# Send mail
shared_users = self.shared_users.values_list("id", flat=True)
municipals_names = list(self.geometry.get_underlying_municipals().values_list("name", flat=True))
for user_id in shared_users:
celery_send_mail_shared_data_deleted.delay(self.identifier, self.title, user_id)
celery_send_mail_shared_data_deleted.delay(self.identifier, self.title, user_id, municipals_names)
# Send mail
shared_teams = self.shared_teams.values_list("id", flat=True)
for team_id in shared_teams:
celery_send_mail_shared_data_deleted_team.delay(self.identifier, self.title, team_id)
celery_send_mail_shared_data_deleted_team.delay(self.identifier, self.title, team_id, municipals_names)
self.save()
@@ -277,12 +278,13 @@ class RecordableObjectMixin(models.Model):
shared_users = self.shared_users.values_list("id", flat=True)
shared_teams = self.shared_teams.values_list("id", flat=True)
municipals_names = list(self.geometry.get_underlying_municipals().values_list("name", flat=True))
for user_id in shared_users:
celery_send_mail_shared_data_unrecorded.delay(self.identifier, self.title, user_id)
celery_send_mail_shared_data_unrecorded.delay(self.identifier, self.title, user_id, municipals_names)
for team_id in shared_teams:
celery_send_mail_shared_data_unrecorded_team.delay(self.identifier, self.title, team_id)
celery_send_mail_shared_data_unrecorded_team.delay(self.identifier, self.title, team_id, municipals_names)
return action
@@ -307,12 +309,13 @@ class RecordableObjectMixin(models.Model):
shared_users = self.shared_users.values_list("id", flat=True)
shared_teams = self.shared_teams.values_list("id", flat=True)
municipals_names = list(self.geometry.get_underlying_municipals().values_list("name", flat=True))
for user_id in shared_users:
celery_send_mail_shared_data_recorded.delay(self.identifier, self.title, user_id)
celery_send_mail_shared_data_recorded.delay(self.identifier, self.title, user_id, municipals_names)
for team_id in shared_teams:
celery_send_mail_shared_data_recorded_team.delay(self.identifier, self.title, team_id)
celery_send_mail_shared_data_recorded_team.delay(self.identifier, self.title, team_id, municipals_names)
return action
@@ -404,15 +407,17 @@ class CheckableObjectMixin(models.Model):
self.checked = action
self.save()
municipals_names = list(self.geometry.get_underlying_municipals().values_list("name", flat=True))
# Send mail
shared_users = self.shared_users.values_list("id", flat=True)
for user_id in shared_users:
celery_send_mail_shared_data_checked.delay(self.identifier, self.title, user_id)
celery_send_mail_shared_data_checked.delay(self.identifier, self.title, user_id, municipals_names)
# Send mail
shared_teams = self.shared_teams.values_list("id", flat=True)
for team_id in shared_teams:
celery_send_mail_shared_data_checked_team.delay(self.identifier, self.title, team_id)
celery_send_mail_shared_data_checked_team.delay(self.identifier, self.title, team_id, municipals_names)
self.log.add(action)
return action
@@ -574,10 +579,11 @@ class ShareableObjectMixin(models.Model):
id__in=shared_teams
).values_list("id", flat=True)
municipals_names = list(self.geometry.get_underlying_municipals().values_list("name", flat=True))
for team_id in new_teams:
celery_send_mail_shared_access_given_team.delay(self.identifier, self.title, team_id)
celery_send_mail_shared_access_given_team.delay(self.identifier, self.title, team_id, municipals_names)
for team_id in removed_teams:
celery_send_mail_shared_access_removed_team.delay(self.identifier, self.title, team_id)
celery_send_mail_shared_access_removed_team.delay(self.identifier, self.title, team_id, municipals_names)
self.share_with_team_list(accessing_teams)
@@ -602,11 +608,12 @@ class ShareableObjectMixin(models.Model):
id__in=shared_users
).values_list("id", flat=True)
municipals_names = list(self.geometry.get_underlying_municipals().values_list("name", flat=True))
# Send mails
for user_id in removed_users:
celery_send_mail_shared_access_removed.delay(self.identifier, self.title, user_id)
celery_send_mail_shared_access_removed.delay(self.identifier, self.title, user_id, municipals_names)
for user_id in new_users:
celery_send_mail_shared_access_given.delay(self.identifier, self.title, user_id)
celery_send_mail_shared_access_given.delay(self.identifier, self.title, user_id, municipals_names)
# Set new shared users
self.share_with_user_list(accessing_users)
@@ -669,8 +676,9 @@ class ShareableObjectMixin(models.Model):
default_users.append(user)
self.share_with_user_list(cleaned_users)
municipals_names = list(self.geometry.get_underlying_municipals().values_list("name", flat=True))
for user in default_users:
celery_send_mail_shared_access_removed.delay(self.identifier, self.title, user.id)
celery_send_mail_shared_access_removed.delay(self.identifier, self.title, user.id, municipals_names)
class GeoReferencedMixin(models.Model):
@@ -767,5 +775,6 @@ class ResubmitableObjectMixin(models.Model):
"""
resubmissions = self.resubmissions.all()
municipal_names = list(self.geometry.get_underlying_municipals().values_list("name", flat=True))
for resubmission in resubmissions:
resubmission.send_resubmission_mail(self.identifier)
resubmission.send_resubmission_mail(self.identifier, municipal_names)