From 890911c2dc0bc681e2b5b6832d82ceaa257ebfe6 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Wed, 10 Aug 2022 08:59:24 +0200 Subject: [PATCH] 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 --- compensation/models/eco_account.py | 22 ++++++- intervention/forms/modalForms.py | 34 ++++++++--- konova/tasks.py | 14 +++++ konova/utils/mailer.py | 55 ++++++++++++++++++ locale/de/LC_MESSAGES/django.mo | Bin 44182 -> 44532 bytes locale/de/LC_MESSAGES/django.po | 54 +++++++++++++---- templates/email/api/verify_token.html | 1 + .../email/checking/shared_data_checked.html | 1 + .../checking/shared_data_checked_team.html | 1 + .../email/deleting/shared_data_deleted.html | 1 + .../deleting/shared_data_deleted_team.html | 1 + templates/email/other/deduction_changed.html | 50 ++++++++++++++++ .../email/other/deduction_changed_team.html | 50 ++++++++++++++++ .../email/recording/shared_data_recorded.html | 1 + .../recording/shared_data_recorded_team.html | 1 + .../recording/shared_data_unrecorded.html | 1 + .../shared_data_unrecorded_team.html | 1 + .../email/sharing/shared_access_given.html | 1 + .../sharing/shared_access_given_team.html | 1 + .../email/sharing/shared_access_removed.html | 1 + .../sharing/shared_access_removed_team.html | 1 + user/models/team.py | 14 +++++ user/models/user.py | 16 +++++ 23 files changed, 300 insertions(+), 22 deletions(-) create mode 100644 templates/email/other/deduction_changed.html create mode 100644 templates/email/other/deduction_changed_team.html diff --git a/compensation/models/eco_account.py b/compensation/models/eco_account.py index 3d48b691..42a202f7 100644 --- a/compensation/models/eco_account.py +++ b/compensation/models/eco_account.py @@ -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) \ No newline at end of file + super().delete(*args, **kwargs) diff --git a/intervention/forms/modalForms.py b/intervention/forms/modalForms.py index 07911be9..b6445a55 100644 --- a/intervention/forms/modalForms.py +++ b/intervention/forms/modalForms.py @@ -508,28 +508,44 @@ class EditEcoAccountDeductionModalForm(NewDeductionModalForm): deduction = self.deduction form_account = self.cleaned_data.get("account", None) form_intervention = self.cleaned_data.get("intervention", None) - current_account = deduction.account - current_intervention = deduction.intervention - + old_account = deduction.account + old_intervention = deduction.intervention + old_surface = deduction.surface # If account or intervention has been changed, we put that change in the logs just as if the deduction has # been removed for this entry. Act as if the deduction is newly created for the new entries - if current_account != form_account: - current_account.mark_as_edited(self.user, self.request, edit_comment=DEDUCTION_REMOVED) + if old_account != form_account: + old_account.mark_as_edited(self.user, self.request, edit_comment=DEDUCTION_REMOVED) form_account.mark_as_edited(self.user, self.request, edit_comment=DEDUCTION_ADDED) else: - current_account.mark_as_edited(self.user, self.request, edit_comment=DEDUCTION_EDITED) + old_account.mark_as_edited(self.user, self.request, edit_comment=DEDUCTION_EDITED) - if current_intervention != form_intervention: - current_intervention.mark_as_edited(self.user, self.request, edit_comment=DEDUCTION_REMOVED) + if old_intervention != form_intervention: + old_intervention.mark_as_edited(self.user, self.request, edit_comment=DEDUCTION_REMOVED) form_intervention.mark_as_edited(self.user, self.request, edit_comment=DEDUCTION_ADDED) else: - current_intervention.mark_as_edited(self.user, self.request, edit_comment=DEDUCTION_EDITED) + old_intervention.mark_as_edited(self.user, self.request, edit_comment=DEDUCTION_EDITED) deduction.account = form_account deduction.intervention = self.cleaned_data.get("intervention", None) deduction.surface = self.cleaned_data.get("surface", None) deduction.save() + + data_changes = { + "surface": { + "old": old_surface, + "new": deduction.surface, + }, + "intervention": { + "old": old_intervention.identifier, + "new": deduction.intervention.identifier, + }, + "account": { + "old": old_account.identifier, + "new": deduction.account.identifier, + } + } + old_account.send_notification_mail_on_deduction_change(data_changes) return deduction diff --git a/konova/tasks.py b/konova/tasks.py index 798effb4..65801219 100644 --- a/konova/tasks.py +++ b/konova/tasks.py @@ -106,3 +106,17 @@ def celery_send_mail_shared_data_checked_team(obj_identifier, obj_title=None, te from user.models import Team team = Team.objects.get(id=team_id) team.send_mail_shared_data_checked(obj_identifier, obj_title) + + +@shared_task +def celery_send_mail_deduction_changed_team(obj_identifier, obj_title=None, 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) + + +@shared_task +def celery_send_mail_deduction_changed(obj_identifier, obj_title=None, 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) diff --git a/konova/utils/mailer.py b/konova/utils/mailer.py index dd8eef1f..92bd2b60 100644 --- a/konova/utils/mailer.py +++ b/konova/utils/mailer.py @@ -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 diff --git a/locale/de/LC_MESSAGES/django.mo b/locale/de/LC_MESSAGES/django.mo index d1cbdfba463cad7b0e3308a74702bbfb3158c120..6ee76a29ae6b97210a548c54b5f64f6f34f30f49 100644 GIT binary patch delta 12475 zcmZA72YgT0|HttwOAYSWg`)}~5- zwK`~PmDa4%8ZEW@^LxE>PWtcTe;@ti`8ns_d(OG%ocql;9$j$O>(BFE?!^K=^Bs;_ zUXD{7kB2zU1M+cEs&$-pRU9XOF2`w)nUwofb)3AEAK=%Ny{kJ;7d(wASg{7z;$lp| z+c+8P)pVQ)Jb<x9KR&NM1YVFBETd2z2TA45OgfO+tmt-psf;P}wmC=5Z} zHy!ig0_z&oecMsbbimeM#ZdZp{vZkFgnw-s!6K+~Ma+-&u^_g=P)tO1oPp|S5*EU_ z*7aC~@_r1*v#9ItTXWS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55zcJjt%g%tq=IXbTl4S-wfO1bnJrXQD4lenasc5*A|&( zs(WE6%IT;nUvE8xew2U3GWZzvYr6PWvl&~XI+}{QZlW#EL^sMhI+J`r945Y`oChyy z{dMdiMiZ}7IgBXH253t;n209tjyirN!a08#-LN)}L>-!m)8u-;yP!U3I?{=;lnZN9 zar{o`>#4)_1}9R8>qHn8uM&mGa}RB-H7}J_{|Ds>#Af1V?u9QohWh)&AJmoMq5ohz z$~wNmZUn#noo#ym&)E~dSW9!FF`>?mC3H08Tz6s>c>pJx*lYi!+`#5PllLG$jXDOB z_s0(Qy#A%kk9d%CmVY0>XubcwG`Nlvj|i=yju7gOQ2vV0@ivyFZWnn|^8I)f^J2uJf2nRBc`)tN!eZF>rE^Lb>-i%%vD7~7H_DUAgX!%M zJWtG_t{hR7JRhN79#e_A#9Bg!zH*;)?k4dGp<_5v&*tBe7oyEEc*fR|IKH^+ z;KWek}^IH6-3Rw62rFTmnl`vmtBe-S$VGC21rHzMDSM{J$Q z%RRYAm^<_TUv3GP*qmyI-#JbNE*?Mw+lh4I3Uw(&6!rh2j&R#x8_xf2s+>$rqwK-C z_sI*AA0>Vy0*L8^j^2|2;Pkvn`F|gufk4E%L94oWs@y zP#8qrY@z~r3F;4!``Ggr_@PPv?`ITsLnwVk z>?L1{pAsR&6rzmY{{tiwIav?i$Go_g@T6lp@)OIc|CK099*8d==WSs<&ga||;uNuw zawvAeMwok4CGjLW5Fcm`ZgFxJh5q<0>L|v;OPMt1KRkjcM-q3q#>+h`vC2^2tb=jW zyt2ACJnNoSH$FRG)|13@g|nWg^zc|TW1xT5#DNq1v;G@1B2U(|Nwqw)4yMm4kd?H+ RJ0xq)mOtII7H#e0_CI69)-?bC diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index 893d4384..b4b18615 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -26,7 +26,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-08-10 08:01+0200\n" +"POT-Creation-Date: 2022-08-10 08:37+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -241,6 +241,7 @@ msgstr "" #: ema/templates/ema/detail/includes/states-after.html:36 #: ema/templates/ema/detail/includes/states-before.html:36 #: intervention/forms/modalForms.py:364 +#: templates/email/other/deduction_changed.html:29 msgid "Surface" msgstr "Fläche" @@ -307,6 +308,7 @@ msgstr "Typ" #: intervention/forms/modalForms.py:382 intervention/tables.py:87 #: intervention/templates/intervention/detail/view.html:19 #: konova/templates/konova/includes/quickstart/interventions.html:4 +#: templates/email/other/deduction_changed.html:24 #: templates/navbars/navbar.html:22 msgid "Intervention" msgstr "Eingriff" @@ -696,14 +698,14 @@ msgstr "" msgid "Pieces" msgstr "Stück" -#: compensation/models/eco_account.py:55 +#: compensation/models/eco_account.py:56 msgid "" "Deductable surface can not be larger than existing surfaces in after states" msgstr "" "Die abbuchbare Fläche darf die Gesamtfläche der Zielzustände nicht " "überschreiten" -#: compensation/models/eco_account.py:62 +#: compensation/models/eco_account.py:63 msgid "" "Deductable surface can not be smaller than the sum of already existing " "deductions. Please contact the responsible users for the deductions!" @@ -1915,23 +1917,27 @@ msgstr "{} - Zugriff entzogen" msgid "{} - Shared access given" msgstr "{} - Zugriff freigegeben" -#: konova/utils/mailer.py:160 konova/utils/mailer.py:275 +#: konova/utils/mailer.py:160 konova/utils/mailer.py:302 msgid "{} - Shared data unrecorded" msgstr "{} - Freigegebene Daten entzeichnet" -#: konova/utils/mailer.py:183 konova/utils/mailer.py:252 +#: konova/utils/mailer.py:183 konova/utils/mailer.py:279 msgid "{} - Shared data recorded" msgstr "{} - Freigegebene Daten verzeichnet" -#: konova/utils/mailer.py:206 konova/utils/mailer.py:321 +#: konova/utils/mailer.py:206 konova/utils/mailer.py:348 msgid "{} - Shared data checked" msgstr "{} - Freigegebene Daten geprüft" -#: konova/utils/mailer.py:229 konova/utils/mailer.py:298 +#: konova/utils/mailer.py:233 konova/utils/mailer.py:372 +msgid "{} - Deduction changed" +msgstr "{} - Abbuchung geändert" + +#: konova/utils/mailer.py:256 konova/utils/mailer.py:325 msgid "{} - Shared data deleted" msgstr "{} - Freigegebene Daten gelöscht" -#: konova/utils/mailer.py:342 templates/email/api/verify_token.html:4 +#: konova/utils/mailer.py:393 templates/email/api/verify_token.html:4 msgid "Request for new API token" msgstr "Anfrage für neuen API Token" @@ -2235,6 +2241,7 @@ msgstr "" #: templates/email/checking/shared_data_checked_team.html:19 #: templates/email/deleting/shared_data_deleted.html:19 #: templates/email/deleting/shared_data_deleted_team.html:19 +#: templates/email/other/deduction_changed.html:38 #: templates/email/recording/shared_data_recorded.html:19 #: templates/email/recording/shared_data_recorded_team.html:19 #: templates/email/recording/shared_data_unrecorded.html:19 @@ -2253,6 +2260,7 @@ msgstr "Freigegebene Daten geprüft" #: templates/email/checking/shared_data_checked.html:8 #: templates/email/deleting/shared_data_deleted.html:8 +#: templates/email/other/deduction_changed.html:8 #: templates/email/recording/shared_data_recorded.html:8 #: templates/email/recording/shared_data_unrecorded.html:8 #: templates/email/sharing/shared_access_given.html:8 @@ -2295,6 +2303,7 @@ msgstr "der folgende Datensatz wurde soeben gelöscht " #: templates/email/deleting/shared_data_deleted.html:16 #: templates/email/deleting/shared_data_deleted_team.html:16 +#: templates/email/other/deduction_changed.html:35 msgid "" "If this should not have been happened, please contact us. See the signature " "for details." @@ -2302,6 +2311,31 @@ msgstr "" "Falls das nicht hätte passieren dürfen, kontaktieren Sie uns bitte. In der E-" "mail Signatur finden Sie weitere Kontaktinformationen." +#: templates/email/other/deduction_changed.html:4 +msgid "Deduction changed" +msgstr "Abbuchung geändert" + +#: templates/email/other/deduction_changed.html:10 +msgid "a deduction of this eco account has changed:" +msgstr "eine Abbuchung des Ökokontos hat sich geändert:" + +#: templates/email/other/deduction_changed.html:14 +msgid "Attribute" +msgstr "Attribute" + +#: templates/email/other/deduction_changed.html:15 +msgid "Old" +msgstr "Alt" + +#: templates/email/other/deduction_changed.html:16 +#: templates/generic_index.html:43 user/templates/user/team/index.html:22 +msgid "New" +msgstr "Neu" + +#: templates/email/other/deduction_changed.html:19 +msgid "EcoAccount" +msgstr "Ökokonto" + #: templates/email/recording/shared_data_recorded.html:4 #: templates/email/recording/shared_data_recorded_team.html:4 msgid "Shared data recorded" @@ -2499,10 +2533,6 @@ msgstr "* sind Pflichtfelder." msgid "New entry" msgstr "Neuer Eintrag" -#: templates/generic_index.html:43 user/templates/user/team/index.html:22 -msgid "New" -msgstr "Neu" - #: templates/generic_index.html:58 msgid "Search for keywords" msgstr "Nach Schlagwörtern suchen" diff --git a/templates/email/api/verify_token.html b/templates/email/api/verify_token.html index bd12a0fe..355647b2 100644 --- a/templates/email/api/verify_token.html +++ b/templates/email/api/verify_token.html @@ -6,6 +6,7 @@
{% trans 'Hello support' %},
+
{% trans 'you need to verify the API token for user' %}:

diff --git a/templates/email/checking/shared_data_checked.html b/templates/email/checking/shared_data_checked.html index 0b67ecc7..133dae2e 100644 --- a/templates/email/checking/shared_data_checked.html +++ b/templates/email/checking/shared_data_checked.html @@ -7,6 +7,7 @@
{% trans 'Hello ' %} {{user.username}},
+
{% trans 'the following dataset has just been checked' %}
{{obj_identifier}} diff --git a/templates/email/checking/shared_data_checked_team.html b/templates/email/checking/shared_data_checked_team.html index ee813811..6a7a4500 100644 --- a/templates/email/checking/shared_data_checked_team.html +++ b/templates/email/checking/shared_data_checked_team.html @@ -7,6 +7,7 @@
{% trans 'Hello team' %} {{team.name}},
+
{% trans 'the following dataset has just been checked' %}
{{obj_identifier}} diff --git a/templates/email/deleting/shared_data_deleted.html b/templates/email/deleting/shared_data_deleted.html index 272b0fde..7857444c 100644 --- a/templates/email/deleting/shared_data_deleted.html +++ b/templates/email/deleting/shared_data_deleted.html @@ -7,6 +7,7 @@
{% trans 'Hello ' %} {{user.username}},
+
{% trans 'the following dataset has just been deleted' %}
{{obj_identifier}} diff --git a/templates/email/deleting/shared_data_deleted_team.html b/templates/email/deleting/shared_data_deleted_team.html index cedb2a45..0ffa8bbf 100644 --- a/templates/email/deleting/shared_data_deleted_team.html +++ b/templates/email/deleting/shared_data_deleted_team.html @@ -7,6 +7,7 @@
{% trans 'Hello team' %} {{team.name}},
+
{% trans 'the following dataset has just been deleted' %}
{{obj_identifier}} diff --git a/templates/email/other/deduction_changed.html b/templates/email/other/deduction_changed.html new file mode 100644 index 00000000..8129f6b2 --- /dev/null +++ b/templates/email/other/deduction_changed.html @@ -0,0 +1,50 @@ +{% load i18n %} + +
+

{% translate 'Deduction changed' %}

+

{{obj_identifier}}

+
+
+ {% translate 'Hello ' %} {{user.username}}, +
+
+ {% translate 'a deduction of this eco account has changed:' %} +
+
+ + + + + + + + + + + + + + + + + + + + + +
{% translate 'Attribute' %}{% translate 'Old' %}{% translate 'New' %}
{% translate 'EcoAccount' %}{{data_changes.account.old}}{{data_changes.account.new}}
{% translate 'Intervention' %}{{data_changes.intervention.old}}{{data_changes.intervention.new}}
{% translate 'Surface' %}{{data_changes.surface.old}} m²{{data_changes.surface.new}} m²
+
+
+ {% translate 'If this should not have been happened, please contact us. See the signature for details.' %} +
+
+ {% translate 'Best regards' %} +
+ KSP +
+
+
+ {% include 'email/signature.html' %} +
+
+ diff --git a/templates/email/other/deduction_changed_team.html b/templates/email/other/deduction_changed_team.html new file mode 100644 index 00000000..babf36c0 --- /dev/null +++ b/templates/email/other/deduction_changed_team.html @@ -0,0 +1,50 @@ +{% load i18n %} + +
+

{% translate 'Deduction changed' %}

+

{{obj_identifier}}

+
+
+ {% trans 'Hello team' %} {{team.name}}, +
+
+ {% translate 'a deduction of this eco account has changed:' %} +
+
+ + + + + + + + + + + + + + + + + + + + + +
{% translate 'Attribute' %}{% translate 'Old' %}{% translate 'New' %}
{% translate 'EcoAccount' %}{{data_changes.account.old}}{{data_changes.account.new}}
{% translate 'Intervention' %}{{data_changes.intervention.old}}{{data_changes.intervention.new}}
{% translate 'Surface' %}{{data_changes.surface.old}} m²{{data_changes.surface.new}} m²
+
+
+ {% translate 'If this should not have been happened, please contact us. See the signature for details.' %} +
+
+ {% translate 'Best regards' %} +
+ KSP +
+
+
+ {% include 'email/signature.html' %} +
+
+ diff --git a/templates/email/recording/shared_data_recorded.html b/templates/email/recording/shared_data_recorded.html index 6805c928..ccad11e0 100644 --- a/templates/email/recording/shared_data_recorded.html +++ b/templates/email/recording/shared_data_recorded.html @@ -7,6 +7,7 @@
{% trans 'Hello ' %} {{user.username}},
+
{% trans 'the following dataset has just been recorded' %}
{{obj_identifier}} diff --git a/templates/email/recording/shared_data_recorded_team.html b/templates/email/recording/shared_data_recorded_team.html index 12efa8f6..0734bc62 100644 --- a/templates/email/recording/shared_data_recorded_team.html +++ b/templates/email/recording/shared_data_recorded_team.html @@ -7,6 +7,7 @@
{% trans 'Hello team' %} {{team.name}},
+
{% trans 'the following dataset has just been recorded' %}
{{obj_identifier}} diff --git a/templates/email/recording/shared_data_unrecorded.html b/templates/email/recording/shared_data_unrecorded.html index 1e0310ae..3406b750 100644 --- a/templates/email/recording/shared_data_unrecorded.html +++ b/templates/email/recording/shared_data_unrecorded.html @@ -7,6 +7,7 @@
{% trans 'Hello ' %} {{user.username}},
+
{% trans 'the following dataset has just been unrecorded' %}
{{obj_identifier}} diff --git a/templates/email/recording/shared_data_unrecorded_team.html b/templates/email/recording/shared_data_unrecorded_team.html index 64141555..5c0f8560 100644 --- a/templates/email/recording/shared_data_unrecorded_team.html +++ b/templates/email/recording/shared_data_unrecorded_team.html @@ -7,6 +7,7 @@
{% trans 'Hello team' %} {{team.name}},
+
{% trans 'the following dataset has just been unrecorded' %}
{{obj_identifier}} diff --git a/templates/email/sharing/shared_access_given.html b/templates/email/sharing/shared_access_given.html index 140e7a88..6ab759b3 100644 --- a/templates/email/sharing/shared_access_given.html +++ b/templates/email/sharing/shared_access_given.html @@ -7,6 +7,7 @@
{% trans 'Hello ' %} {{user.username}},
+
{% trans 'the following dataset has just been shared with you' %}
{{obj_identifier}} diff --git a/templates/email/sharing/shared_access_given_team.html b/templates/email/sharing/shared_access_given_team.html index 990ba2de..cdf3bb1c 100644 --- a/templates/email/sharing/shared_access_given_team.html +++ b/templates/email/sharing/shared_access_given_team.html @@ -7,6 +7,7 @@
{% trans 'Hello team' %} {{team.name}},
+
{% trans 'the following dataset has just been shared with your team' %}
{{obj_identifier}} diff --git a/templates/email/sharing/shared_access_removed.html b/templates/email/sharing/shared_access_removed.html index d1cbc5bf..b3121117 100644 --- a/templates/email/sharing/shared_access_removed.html +++ b/templates/email/sharing/shared_access_removed.html @@ -7,6 +7,7 @@
{% trans 'Hello ' %} {{user.username}},
+
{% trans 'your shared access, including editing, has been revoked for the dataset ' %}
{{obj_identifier}} diff --git a/templates/email/sharing/shared_access_removed_team.html b/templates/email/sharing/shared_access_removed_team.html index 5472ef73..992f00f8 100644 --- a/templates/email/sharing/shared_access_removed_team.html +++ b/templates/email/sharing/shared_access_removed_team.html @@ -7,6 +7,7 @@
{% trans 'Hello team' %} {{team.name}},
+
{% trans 'your teams shared access, including editing, has been revoked for the dataset ' %}
{{obj_identifier}} diff --git a/user/models/team.py b/user/models/team.py index 5e728e71..7162e977 100644 --- a/user/models/team.py +++ b/user/models/team.py @@ -95,6 +95,20 @@ class Team(UuidModel, DeletableObjectMixin): mailer = Mailer() mailer.send_mail_shared_data_checked_team(obj_identifier, obj_title, self) + def send_mail_deduction_changed(self, obj_identifier, obj_title, 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 + data_changes (dict): Contains the old|new changes of the deduction changes + + Returns: + + """ + mailer = Mailer() + mailer.send_mail_deduction_changed_team(obj_identifier, obj_title, self, data_changes) + def send_mail_shared_data_deleted(self, obj_identifier, obj_title): """ Sends a mail to the team members in case of deleted data diff --git a/user/models/user.py b/user/models/user.py index b40a3b1b..20d3d50b 100644 --- a/user/models/user.py +++ b/user/models/user.py @@ -145,6 +145,22 @@ class User(AbstractUser): mailer = Mailer() mailer.send_mail_shared_data_checked(obj_identifier, obj_title, self) + def send_mail_deduction_changed(self, obj_identifier, obj_title, 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 + data_changes (dict): Contains the old|new changes of the deduction changes + + Returns: + + """ + 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) + def get_API_token(self): """ Getter for an API token