diff --git a/compensation/models/eco_account.py b/compensation/models/eco_account.py
index afebfbe0..a321ff99 100644
--- a/compensation/models/eco_account.py
+++ b/compensation/models/eco_account.py
@@ -161,12 +161,12 @@ class EcoAccount(AbstractCompensation, ShareableObjectMixin, RecordableObjectMix
# Send mail
shared_users = self.shared_users.values_list("id", flat=True)
for user_id in shared_users:
- celery_send_mail_deduction_changed.delay(self.identifier, self.title, user_id, data_change)
+ celery_send_mail_deduction_changed.delay(self.id, self.__class__, user_id, data_change)
# Send mail
shared_teams = self.shared_teams.values_list("id", flat=True)
for team_id in shared_teams:
- celery_send_mail_deduction_changed_team.delay(self.identifier, self.title, team_id, data_change)
+ celery_send_mail_deduction_changed_team.delay(self.id, self.__class__, team_id, data_change)
def update_deductable_rest(self):
"""
diff --git a/konova/models/object.py b/konova/models/object.py
index 52732a8c..6665dd35 100644
--- a/konova/models/object.py
+++ b/konova/models/object.py
@@ -123,7 +123,7 @@ class DeletableObjectMixin(models.Model):
# 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, municipals_names)
+ celery_send_mail_shared_data_deleted_team.delay(self.id, self.__class__, team_id, municipals_names)
self.save()
@@ -256,10 +256,10 @@ class RecordableObjectMixin(models.Model):
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, municipals_names)
+ celery_send_mail_shared_data_unrecorded.delay(self.id, self.__class__, user_id, municipals_names)
for team_id in shared_teams:
- celery_send_mail_shared_data_unrecorded_team.delay(self.identifier, self.title, team_id, municipals_names)
+ celery_send_mail_shared_data_unrecorded_team.delay(self.id, self.__class__, team_id, municipals_names)
return action
@@ -287,10 +287,10 @@ class RecordableObjectMixin(models.Model):
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, municipals_names)
+ celery_send_mail_shared_data_recorded.delay(self.id, self.__class__, user_id, municipals_names)
for team_id in shared_teams:
- celery_send_mail_shared_data_recorded_team.delay(self.identifier, self.title, team_id, municipals_names)
+ celery_send_mail_shared_data_recorded_team.delay(self.id, self.__class__, team_id, municipals_names)
return action
@@ -366,12 +366,12 @@ class CheckableObjectMixin(models.Model):
# 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, municipals_names)
+ celery_send_mail_shared_data_checked.delay(self.id, self.__class__, 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, municipals_names)
+ celery_send_mail_shared_data_checked_team.delay(self.id, self.__class__, team_id, municipals_names)
self.log.add(action)
return action
@@ -556,9 +556,9 @@ class ShareableObjectMixin(models.Model):
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, municipals_names)
+ celery_send_mail_shared_access_given_team.delay(self.id, self.__class__, team_id, municipals_names)
for team_id in removed_teams:
- celery_send_mail_shared_access_removed_team.delay(self.identifier, self.title, team_id, municipals_names)
+ celery_send_mail_shared_access_removed_team.delay(self.id, self.__class__, team_id, municipals_names)
self.share_with_team_list(accessing_teams)
@@ -586,9 +586,9 @@ class ShareableObjectMixin(models.Model):
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, municipals_names)
+ celery_send_mail_shared_access_removed(self.id, self.__class__, user_id, municipals_names)
for user_id in new_users:
- celery_send_mail_shared_access_given.delay(self.identifier, self.title, user_id, municipals_names)
+ celery_send_mail_shared_access_given(self.id, self.__class__, user_id, municipals_names)
# Set new shared users
self.share_with_user_list(accessing_users)
diff --git a/konova/tasks.py b/konova/tasks.py
index ab9e6af3..417f5ca2 100644
--- a/konova/tasks.py
+++ b/konova/tasks.py
@@ -25,101 +25,115 @@ def celery_update_parcels(geometry_id: str, recheck: bool = True):
@shared_task
-def celery_send_mail_shared_access_removed(obj_identifier, obj_title=None, user_id=None, municipals_names=[]):
+def celery_send_mail_shared_access_removed(obj_id, obj_class, user_id=None, municipals_names=[]):
from user.models import User
user = User.objects.get(id=user_id)
- user.send_mail_shared_access_removed(obj_identifier, obj_title, municipals_names)
+ obj = obj_class.objects.get(id=obj_id)
+ user.send_mail_shared_access_removed(obj, municipals_names)
@shared_task
-def celery_send_mail_shared_access_given(obj_identifier, obj_title=None, user_id=None, municipals_names=[]):
+def celery_send_mail_shared_access_given(obj_id, obj_class, user_id=None, municipals_names=[]):
from user.models import User
user = User.objects.get(id=user_id)
- user.send_mail_shared_access_given(obj_identifier, obj_title, municipals_names)
+ obj = obj_class.objects.get(id=obj_id)
+ user.send_mail_shared_access_given(obj, municipals_names)
@shared_task
-def celery_send_mail_shared_access_removed_team(obj_identifier, obj_title=None, team_id=None, municipals_names=[]):
+def celery_send_mail_shared_access_removed_team(obj_id, obj_class, team_id=None, municipals_names=[]):
from user.models import Team
team = Team.objects.get(id=team_id)
- team.send_mail_shared_access_removed(obj_identifier, obj_title, municipals_names)
+ obj = obj_class.objects.get(id=obj_id)
+ team.send_mail_shared_access_removed(obj, municipals_names)
@shared_task
-def celery_send_mail_shared_access_given_team(obj_identifier, obj_title=None, team_id=None, municipals_names=[]):
+def celery_send_mail_shared_access_given_team(obj_id, obj_class, team_id=None, municipals_names=[]):
from user.models import Team
team = Team.objects.get(id=team_id)
- team.send_mail_shared_access_given_team(obj_identifier, obj_title, municipals_names)
+ obj = obj_class.objects.get(id=obj_id)
+ team.send_mail_shared_access_given_team(obj, municipals_names)
@shared_task
-def celery_send_mail_shared_data_recorded(obj_identifier, obj_title=None, user_id=None, municipals_names=[]):
+def celery_send_mail_shared_data_recorded(obj_id, obj_class, user_id=None, municipals_names=[]):
from user.models import User
user = User.objects.get(id=user_id)
- user.send_mail_shared_data_recorded(obj_identifier, obj_title, municipals_names)
+ obj = obj_class.objects.get(id=obj_id)
+ user.send_mail_shared_data_recorded(obj, municipals_names)
@shared_task
-def celery_send_mail_shared_data_unrecorded(obj_identifier, obj_title=None, user_id=None, municipals_names=[]):
+def celery_send_mail_shared_data_unrecorded(obj_id, obj_class, user_id=None, municipals_names=[]):
from user.models import User
user = User.objects.get(id=user_id)
- user.send_mail_shared_data_unrecorded(obj_identifier, obj_title, municipals_names)
+ obj = obj_class.objects.get(id=obj_id)
+ user.send_mail_shared_data_unrecorded(obj, municipals_names)
@shared_task
-def celery_send_mail_shared_data_recorded_team(obj_identifier, obj_title=None, team_id=None, municipals_names=[]):
+def celery_send_mail_shared_data_recorded_team(obj_id, obj_class, team_id=None, municipals_names=[]):
from user.models import Team
team = Team.objects.get(id=team_id)
- team.send_mail_shared_data_recorded(obj_identifier, obj_title, municipals_names)
+ obj = obj_class.objects.get(id=obj_id)
+ team.send_mail_shared_data_recorded(obj, municipals_names)
@shared_task
-def celery_send_mail_shared_data_unrecorded_team(obj_identifier, obj_title=None, team_id=None, municipals_names=[]):
+def celery_send_mail_shared_data_unrecorded_team(obj_id, obj_class, team_id=None, municipals_names=[]):
from user.models import Team
team = Team.objects.get(id=team_id)
- team.send_mail_shared_data_unrecorded(obj_identifier, obj_title, municipals_names)
+ obj = obj_class.objects.get(id=obj_id)
+ team.send_mail_shared_data_unrecorded(obj, municipals_names)
@shared_task
-def celery_send_mail_shared_data_deleted(obj_identifier, obj_title=None, user_id=None, municipals_names=[]):
+def celery_send_mail_shared_data_deleted(obj_id, obj_class, user_id=None, municipals_names=[]):
from user.models import User
user = User.objects.get(id=user_id)
- user.send_mail_shared_data_deleted(obj_identifier, obj_title, municipals_names)
+ obj = obj_class.objects.get(id=obj_id)
+ user.send_mail_shared_data_deleted(obj, municipals_names)
@shared_task
-def celery_send_mail_shared_data_checked(obj_identifier, obj_title=None, user_id=None, municipals_names=[]):
+def celery_send_mail_shared_data_checked(obj_id, obj_class, user_id=None, municipals_names=[]):
from user.models import User
user = User.objects.get(id=user_id)
- user.send_mail_shared_data_checked(obj_identifier, obj_title, municipals_names)
+ obj = obj_class.objects.get(id=obj_id)
+ user.send_mail_shared_data_checked(obj, municipals_names)
@shared_task
-def celery_send_mail_shared_data_deleted_team(obj_identifier, obj_title=None, team_id=None, municipals_names=[]):
+def celery_send_mail_shared_data_deleted_team(obj_id, obj_class, team_id=None, municipals_names=[]):
from user.models import Team
team = Team.objects.get(id=team_id)
- team.send_mail_shared_data_deleted(obj_identifier, obj_title, municipals_names)
+ obj = obj_class.objects.get(id=obj_id)
+ team.send_mail_shared_data_deleted(obj, municipals_names)
@shared_task
-def celery_send_mail_shared_data_checked_team(obj_identifier, obj_title=None, team_id=None, municipals_names=[]):
+def celery_send_mail_shared_data_checked_team(obj_id, obj_class, team_id=None, municipals_names=[]):
from user.models import Team
team = Team.objects.get(id=team_id)
- team.send_mail_shared_data_checked(obj_identifier, obj_title, municipals_names)
+ obj = obj_class.objects.get(id=obj_id)
+ team.send_mail_shared_data_checked(obj, municipals_names)
@shared_task
-def celery_send_mail_deduction_changed_team(obj_identifier, obj_title=None, team_id=None, data_changes=None):
+def celery_send_mail_deduction_changed_team(obj_id, obj_class, team_id=None, data_changes=None):
from user.models import Team
team = Team.objects.get(id=team_id)
- team.send_mail_deduction_changed(obj_identifier, obj_title, data_changes)
+ obj = obj_class.objects.get(id=obj_id)
+ team.send_mail_deduction_changed(obj, data_changes)
@shared_task
-def celery_send_mail_deduction_changed(obj_identifier, obj_title=None, user_id=None, data_changes=None):
+def celery_send_mail_deduction_changed(obj_id, obj_class, user_id=None, data_changes=None):
from user.models import User
user = User.objects.get(id=user_id)
- user.send_mail_deduction_changed(obj_identifier, obj_title, data_changes)
+ obj = obj_class.objects.get(id=obj_id)
+ user.send_mail_deduction_changed(obj, data_changes)
@shared_task
diff --git a/konova/utils/mailer.py b/konova/utils/mailer.py
index faf21fd1..d60f3b9a 100644
--- a/konova/utils/mailer.py
+++ b/konova/utils/mailer.py
@@ -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
)
diff --git a/templates/email/checking/shared_data_checked.html b/templates/email/checking/shared_data_checked.html
index 258315d2..665a2a2f 100644
--- a/templates/email/checking/shared_data_checked.html
+++ b/templates/email/checking/shared_data_checked.html
@@ -2,7 +2,7 @@
{% trans 'Shared data checked' %}
-
{{obj_identifier}}
+
{{obj.identifier}}
{% trans 'Hello ' %} {{user.username}},
@@ -10,9 +10,9 @@
{% trans 'the following dataset has just been checked' %}
- {{obj_identifier}}
+ {{obj.identifier}}
- {{obj_title}}
+ {{obj.title}}
{% trans 'This entry is located in' %}
diff --git a/templates/email/checking/shared_data_checked_team.html b/templates/email/checking/shared_data_checked_team.html
index 6d02df52..a92f4334 100644
--- a/templates/email/checking/shared_data_checked_team.html
+++ b/templates/email/checking/shared_data_checked_team.html
@@ -2,7 +2,7 @@
{% trans 'Shared data checked' %}
-
{{obj_identifier}}
+
{{obj.identifier}}
{% trans 'Hello team' %} {{team.name}},
@@ -10,9 +10,9 @@
{% trans 'the following dataset has just been checked' %}
- {{obj_identifier}}
+ {{obj.identifier}}
- {{obj_title}}
+ {{obj.title}}
{% trans 'This entry is located in' %}
diff --git a/templates/email/deleting/shared_data_deleted.html b/templates/email/deleting/shared_data_deleted.html
index 491e70b4..243a3e2b 100644
--- a/templates/email/deleting/shared_data_deleted.html
+++ b/templates/email/deleting/shared_data_deleted.html
@@ -2,7 +2,7 @@
{% trans 'Shared data deleted' %}
-
{{obj_identifier}}
+
{{obj.identifier}}
{% trans 'Hello ' %} {{user.username}},
@@ -10,9 +10,9 @@
{% trans 'the following dataset has just been deleted' %}
- {{obj_identifier}}
+ {{obj.identifier}}
- "{{obj_title}}"
+ "{{obj.title}}"
{% trans 'This entry is located in' %}
diff --git a/templates/email/deleting/shared_data_deleted_team.html b/templates/email/deleting/shared_data_deleted_team.html
index ba1328d3..c546c318 100644
--- a/templates/email/deleting/shared_data_deleted_team.html
+++ b/templates/email/deleting/shared_data_deleted_team.html
@@ -2,7 +2,7 @@
{% trans 'Shared data deleted' %}
-
{{obj_identifier}}
+
{{obj.identifier}}
{% trans 'Hello team' %} {{team.name}},
@@ -10,9 +10,9 @@
{% trans 'the following dataset has just been deleted' %}
- {{obj_identifier}}
+ {{obj.identifier}}
- "{{obj_title}}"
+ "{{obj.title}}"
{% trans 'This entry is located in' %}
diff --git a/templates/email/other/deduction_changed.html b/templates/email/other/deduction_changed.html
index 8129f6b2..f9762ef8 100644
--- a/templates/email/other/deduction_changed.html
+++ b/templates/email/other/deduction_changed.html
@@ -2,7 +2,7 @@
{% translate 'Deduction changed' %}
-
{{obj_identifier}}
+
{{obj.identifier}}
{% translate 'Hello ' %} {{user.username}},
diff --git a/templates/email/other/deduction_changed_team.html b/templates/email/other/deduction_changed_team.html
index babf36c0..75b39324 100644
--- a/templates/email/other/deduction_changed_team.html
+++ b/templates/email/other/deduction_changed_team.html
@@ -2,7 +2,7 @@
{% translate 'Deduction changed' %}
-
{{obj_identifier}}
+
{{obj.identifier}}
{% trans 'Hello team' %} {{team.name}},
diff --git a/templates/email/recording/shared_data_recorded.html b/templates/email/recording/shared_data_recorded.html
index 71f92f7d..4b18e3ee 100644
--- a/templates/email/recording/shared_data_recorded.html
+++ b/templates/email/recording/shared_data_recorded.html
@@ -2,7 +2,7 @@
{% trans 'Shared data recorded' %}
-
{{obj_identifier}}
+
{{obj.identifier}}
{% trans 'Hello ' %} {{user.username}},
@@ -10,9 +10,9 @@
{% trans 'the following dataset has just been recorded' %}
- {{obj_identifier}}
+ {{obj.identifier}}
- "{{obj_title}}"
+ "{{obj.title}}"
{% trans 'This entry is located in' %}
diff --git a/templates/email/recording/shared_data_recorded_team.html b/templates/email/recording/shared_data_recorded_team.html
index 1c84674b..3f508c47 100644
--- a/templates/email/recording/shared_data_recorded_team.html
+++ b/templates/email/recording/shared_data_recorded_team.html
@@ -2,7 +2,7 @@
{% trans 'Shared data recorded' %}
-
{{obj_identifier}}
+
{{obj.identifier}}
{% trans 'Hello team' %} {{team.name}},
@@ -10,9 +10,9 @@
{% trans 'the following dataset has just been recorded' %}
- {{obj_identifier}}
+ {{obj.identifier}}
- "{{obj_title}}"
+ "{{obj.title}}"
{% trans 'This entry is located in' %}
diff --git a/templates/email/recording/shared_data_unrecorded.html b/templates/email/recording/shared_data_unrecorded.html
index c6c7b0c3..77300f97 100644
--- a/templates/email/recording/shared_data_unrecorded.html
+++ b/templates/email/recording/shared_data_unrecorded.html
@@ -2,7 +2,7 @@
{% trans 'Shared data unrecorded' %}
-
{{obj_identifier}}
+
{{obj.identifier}}
{% trans 'Hello ' %} {{user.username}},
@@ -10,9 +10,9 @@
{% trans 'the following dataset has just been unrecorded' %}
- {{obj_identifier}}
+ {{obj.identifier}}
- "{{obj_title}}"
+ "{{obj.title}}"
{% trans 'This entry is located in' %}
diff --git a/templates/email/recording/shared_data_unrecorded_team.html b/templates/email/recording/shared_data_unrecorded_team.html
index 6ac1d75b..c4aaaf97 100644
--- a/templates/email/recording/shared_data_unrecorded_team.html
+++ b/templates/email/recording/shared_data_unrecorded_team.html
@@ -2,7 +2,7 @@
{% trans 'Shared data unrecorded' %}
-
{{obj_identifier}}
+
{{obj.identifier}}
{% trans 'Hello team' %} {{team.name}},
@@ -10,9 +10,9 @@
{% trans 'the following dataset has just been unrecorded' %}
- {{obj_identifier}}
+ {{obj.identifier}}
- "{{obj_title}}"
+ "{{obj.title}}"
{% trans 'This entry is located in' %}
diff --git a/templates/email/resubmission/resubmission.html b/templates/email/resubmission/resubmission.html
index 0dcc32ce..09b40e77 100644
--- a/templates/email/resubmission/resubmission.html
+++ b/templates/email/resubmission/resubmission.html
@@ -2,7 +2,7 @@
{% trans 'Resubmission' %}
-
{{obj_identifier}}
+
{{obj.identifier}}
{% trans 'Hello ' %} {{resubmission.user.username}},
diff --git a/templates/email/sharing/shared_access_given.html b/templates/email/sharing/shared_access_given.html
index 785e602c..472d3c9e 100644
--- a/templates/email/sharing/shared_access_given.html
+++ b/templates/email/sharing/shared_access_given.html
@@ -2,7 +2,7 @@
{% trans 'Access shared' %}
-
{{obj_identifier}}
+
{{obj.identifier}}
{% trans 'Hello ' %} {{user.username}},
@@ -10,9 +10,9 @@
{% trans 'the following dataset has just been shared with you' %}
- {{obj_identifier}}
+ {{obj.identifier}}
- "{{obj_title}}"
+ "{{obj.title}}"
{% trans 'This entry is located in' %}
diff --git a/templates/email/sharing/shared_access_given_team.html b/templates/email/sharing/shared_access_given_team.html
index 0f23bc57..608f27f9 100644
--- a/templates/email/sharing/shared_access_given_team.html
+++ b/templates/email/sharing/shared_access_given_team.html
@@ -2,7 +2,7 @@
{% trans 'Access shared' %}
-
{{obj_identifier}}
+
{{obj.identifier}}
{% trans 'Hello team' %} {{team.name}},
@@ -10,9 +10,9 @@
{% trans 'the following dataset has just been shared with your team' %}
- {{obj_identifier}}
+ {{obj.identifier}}
- "{{obj_title}}"
+ "{{obj.title}}"
{% trans 'This entry is located in' %}
diff --git a/templates/email/sharing/shared_access_removed.html b/templates/email/sharing/shared_access_removed.html
index f1845a3e..2dde1492 100644
--- a/templates/email/sharing/shared_access_removed.html
+++ b/templates/email/sharing/shared_access_removed.html
@@ -2,7 +2,7 @@
{% trans 'Shared access removed' %}
-
{{obj_identifier}}
+
{{obj.identifier}}
{% trans 'Hello ' %} {{user.username}},
@@ -10,9 +10,9 @@
{% trans 'your shared access, including editing, has been revoked for the dataset ' %}
- {{obj_identifier}}
+ {{obj.identifier}}
- "{{obj_title}}"
+ "{{obj.title}}"
{% trans 'This entry is located in' %}
diff --git a/templates/email/sharing/shared_access_removed_team.html b/templates/email/sharing/shared_access_removed_team.html
index ede05202..76afa230 100644
--- a/templates/email/sharing/shared_access_removed_team.html
+++ b/templates/email/sharing/shared_access_removed_team.html
@@ -2,7 +2,7 @@
{% trans 'Shared access removed' %}
-
{{obj_identifier}}
+
{{obj.identifier}}
{% trans 'Hello team' %} {{team.name}},
@@ -10,9 +10,9 @@
{% trans 'your teams shared access, including editing, has been revoked for the dataset ' %}
- {{obj_identifier}}
+ {{obj.identifier}}
- "{{obj_title}}"
+ "{{obj.title}}"
{% trans 'This entry is located in' %}
diff --git a/user/models/team.py b/user/models/team.py
index 0ff18a85..335e8944 100644
--- a/user/models/team.py
+++ b/user/models/team.py
@@ -31,12 +31,11 @@ class Team(UuidModel, DeletableObjectMixin):
self.deleted = delete_action
self.save()
- def send_mail_shared_access_given_team(self, obj_identifier, obj_title, municipals_names):
+ def send_mail_shared_access_given_team(self, obj, municipals_names):
""" Sends a mail to the team members in case of given shared access
Args:
- obj_identifier (str): The entry identifier
- obj_title (str): The entry title
+ obj (str): The entry
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -46,14 +45,13 @@ 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, municipals_names)
+ mailer.send_mail_shared_access_given_team(obj, self, users_to_notify, municipals_names)
- def send_mail_shared_access_removed(self, obj_identifier, obj_title, municipals_names):
+ def send_mail_shared_access_removed(self, obj, municipals_names):
""" Sends a mail to the team members in case of removed shared access
Args:
- obj_identifier (str): The entry identifier
- obj_title (str): The entry title
+ obj (): The entry
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -63,14 +61,13 @@ 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, municipals_names)
+ mailer.send_mail_shared_access_removed_team(obj, self, users_to_notify, municipals_names)
- def send_mail_shared_data_unrecorded(self, obj_identifier, obj_title, municipals_names):
+ def send_mail_shared_data_unrecorded(self, obj, municipals_names):
""" Sends a mail to the team members in case of unrecorded data
Args:
- obj_identifier (str): The entry identifier
- obj_title (str): The entry title
+ obj (): The entry
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -80,14 +77,13 @@ 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, municipals_names)
+ mailer.send_mail_shared_data_unrecorded_team(obj, self, users_to_notify, municipals_names)
- def send_mail_shared_data_recorded(self, obj_identifier, obj_title, municipals_names):
+ def send_mail_shared_data_recorded(self, obj, municipals_names):
""" Sends a mail to the team members in case of unrecorded data
Args:
- obj_identifier (str): The entry identifier
- obj_title (str): The entry title
+ obj (): The entry
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -97,14 +93,13 @@ 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, municipals_names)
+ mailer.send_mail_shared_data_recorded_team(obj, self, users_to_notify, municipals_names)
- def send_mail_shared_data_checked(self, obj_identifier, obj_title, municipals_names):
+ def send_mail_shared_data_checked(self, obj, municipals_names):
""" Sends a mail to the team members in case of checked data
Args:
- obj_identifier (str): The entry identifier
- obj_title (str): The entry title
+ obj (): The entry
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -114,14 +109,13 @@ 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, municipals_names)
+ mailer.send_mail_shared_data_checked_team(obj, self, users_to_notify, municipals_names)
- def send_mail_deduction_changed(self, obj_identifier, obj_title, data_changes):
+ def send_mail_deduction_changed(self, obj, data_changes):
""" Sends a mail to the team members in case of changed deduction values
Args:
- obj_identifier (str): Identifier of the main object
- obj_title (str): Title of the main object
+ obj (): The main object
data_changes (dict): Contains the old|new changes of the deduction changes
Returns:
@@ -131,14 +125,13 @@ class Team(UuidModel, DeletableObjectMixin):
users_to_notify = self.users.filter(
notifications__in=[UserNotificationEnum.NOTIFY_ON_DEDUCTION_CHANGES.value]
)
- mailer.send_mail_deduction_changed_team(obj_identifier, obj_title, self, data_changes, users_to_notify)
+ mailer.send_mail_deduction_changed_team(obj, self, data_changes, users_to_notify)
- def send_mail_shared_data_deleted(self, obj_identifier, obj_title, municipals_names):
+ def send_mail_shared_data_deleted(self, obj, municipals_names):
""" Sends a mail to the team members in case of deleted data
Args:
- obj_identifier (str): The entry identifier
- obj_title (str): The entry title
+ obj (): The entry
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -148,7 +141,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, municipals_names)
+ mailer.send_mail_shared_data_deleted_team(obj, self, users_to_notify, municipals_names)
def remove_user(self, user):
""" Removes a user from the team
diff --git a/user/models/user.py b/user/models/user.py
index c01dbc48..dde88dcd 100644
--- a/user/models/user.py
+++ b/user/models/user.py
@@ -83,12 +83,11 @@ class User(AbstractUser):
name=group
)
- def send_mail_shared_access_removed(self, obj_identifier, obj_title, municipals_names):
+ def send_mail_shared_access_removed(self, obj, municipals_names):
""" Sends a mail to the user in case of removed shared access
Args:
- obj_identifier ():
- obj_title ():
+ obj ():
municipals_names ():
Returns:
@@ -97,14 +96,13 @@ 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, municipals_names)
+ mailer.send_mail_shared_access_removed(obj, self, municipals_names)
- def send_mail_shared_access_given(self, obj_identifier, obj_title, municipals_names):
+ def send_mail_shared_access_given(self, obj, municipals_names):
""" Sends a mail to the user in case of given shared access
Args:
- obj_identifier (str): The entry identifier
- obj_title (str): The entry title
+ obj (): The entry
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -113,14 +111,13 @@ 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, municipals_names)
+ mailer.send_mail_shared_access_given(obj, self, municipals_names)
- def send_mail_shared_data_recorded(self, obj_identifier, obj_title, municipals_names):
+ def send_mail_shared_data_recorded(self, obj, municipals_names):
""" Sends a mail to the user in case of shared data has been recorded
Args:
- obj_identifier (str): The entry identifier
- obj_title (str): The entry title
+ obj (): The entry
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -129,14 +126,13 @@ 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, municipals_names)
+ mailer.send_mail_shared_data_recorded(obj, self, municipals_names)
- def send_mail_shared_data_unrecorded(self, obj_identifier, obj_title, municipals_names):
+ def send_mail_shared_data_unrecorded(self, obj, municipals_names):
""" Sends a mail to the user in case of shared data has been unrecorded
Args:
- obj_identifier (str): The entry identifier
- obj_title (str): The entry title
+ obj (): The entry
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -145,14 +141,13 @@ 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, municipals_names)
+ mailer.send_mail_shared_data_unrecorded(obj, self, municipals_names)
- def send_mail_shared_data_deleted(self, obj_identifier, obj_title, municipals_names):
+ def send_mail_shared_data_deleted(self, obj, municipals_names):
""" Sends a mail to the user in case of shared data has been deleted
Args:
- obj_identifier (str): The entry identifier
- obj_title (str): The entry title
+ obj (): The entry
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -161,14 +156,13 @@ 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, municipals_names)
+ mailer.send_mail_shared_data_deleted(obj, self, municipals_names)
- def send_mail_shared_data_checked(self, obj_identifier, obj_title, municipals_names):
+ def send_mail_shared_data_checked(self, obj, municipals_names):
""" Sends a mail to the user in case of shared data has been deleted
Args:
- obj_identifier (str): The entry identifier
- obj_title (str): The entry title
+ obj (): The entry
municipals_names (iterable): List of municipals for this entry
Returns:
@@ -177,14 +171,13 @@ 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, municipals_names)
+ mailer.send_mail_shared_data_checked(obj, self, municipals_names)
- def send_mail_deduction_changed(self, obj_identifier, obj_title, data_changes):
+ def send_mail_deduction_changed(self, obj, data_changes):
""" Sends a mail to the user in case of a changed deduction
Args:
- obj_identifier (str): Identifier of the main object
- obj_title (str): Title of the main object
+ obj (): The object
data_changes (dict): Contains the old|new changes of the deduction changes
Returns:
@@ -193,7 +186,7 @@ class User(AbstractUser):
notification_set = self.is_notification_setting_set(UserNotificationEnum.NOTIFY_ON_DEDUCTION_CHANGES)
if notification_set:
mailer = Mailer()
- mailer.send_mail_deduction_changed(obj_identifier, obj_title, self, data_changes)
+ mailer.send_mail_deduction_changed(obj, self, data_changes)
def get_API_token(self):
""" Getter for an API token