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:
@@ -21,6 +21,7 @@ from compensation.models.compensation import AbstractCompensation, PikMixin
|
||||
from compensation.utils.quality import EcoAccountQualityChecker
|
||||
from konova.models import ShareableObjectMixin, RecordableObjectMixin, AbstractDocument, BaseResource, \
|
||||
generate_document_file_upload_path
|
||||
from konova.tasks import celery_send_mail_deduction_changed, celery_send_mail_deduction_changed_team
|
||||
|
||||
|
||||
class EcoAccount(AbstractCompensation, ShareableObjectMixin, RecordableObjectMixin, PikMixin):
|
||||
@@ -161,6 +162,25 @@ class EcoAccount(AbstractCompensation, ShareableObjectMixin, RecordableObjectMix
|
||||
"""
|
||||
return reverse("compensation:acc:share", args=(self.id, self.access_token))
|
||||
|
||||
def send_notification_mail_on_deduction_change(self, data_change: dict):
|
||||
""" Sends notification mails for changes on the deduction
|
||||
|
||||
Args:
|
||||
data_change ():
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
# 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)
|
||||
|
||||
# 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)
|
||||
|
||||
|
||||
class EcoAccountDocument(AbstractDocument):
|
||||
"""
|
||||
@@ -251,4 +271,4 @@ class EcoAccountDeduction(BaseResource):
|
||||
if user is not None:
|
||||
self.intervention.mark_as_edited(user, edit_comment=DEDUCTION_REMOVED)
|
||||
self.account.mark_as_edited(user, edit_comment=DEDUCTION_REMOVED)
|
||||
super().delete(*args, **kwargs)
|
||||
super().delete(*args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user