191_Deduction_change_notification #195

Merged
mpeltriaux merged 3 commits from 191_Deduction_change_notification into master 2022-08-10 09:04:30 +02:00
26 changed files with 348 additions and 62 deletions

View File

@ -21,6 +21,7 @@ from compensation.models.compensation import AbstractCompensation, PikMixin
from compensation.utils.quality import EcoAccountQualityChecker from compensation.utils.quality import EcoAccountQualityChecker
from konova.models import ShareableObjectMixin, RecordableObjectMixin, AbstractDocument, BaseResource, \ from konova.models import ShareableObjectMixin, RecordableObjectMixin, AbstractDocument, BaseResource, \
generate_document_file_upload_path 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): 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)) 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): class EcoAccountDocument(AbstractDocument):
""" """
@ -251,4 +271,4 @@ class EcoAccountDeduction(BaseResource):
if user is not None: if user is not None:
self.intervention.mark_as_edited(user, edit_comment=DEDUCTION_REMOVED) self.intervention.mark_as_edited(user, edit_comment=DEDUCTION_REMOVED)
self.account.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)

View File

@ -508,28 +508,44 @@ class EditEcoAccountDeductionModalForm(NewDeductionModalForm):
deduction = self.deduction deduction = self.deduction
form_account = self.cleaned_data.get("account", None) form_account = self.cleaned_data.get("account", None)
form_intervention = self.cleaned_data.get("intervention", None) form_intervention = self.cleaned_data.get("intervention", None)
current_account = deduction.account old_account = deduction.account
current_intervention = deduction.intervention 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 # 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 # been removed for this entry. Act as if the deduction is newly created for the new entries
if current_account != form_account: if old_account != form_account:
current_account.mark_as_edited(self.user, self.request, edit_comment=DEDUCTION_REMOVED) 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) form_account.mark_as_edited(self.user, self.request, edit_comment=DEDUCTION_ADDED)
else: 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: if old_intervention != form_intervention:
current_intervention.mark_as_edited(self.user, self.request, edit_comment=DEDUCTION_REMOVED) 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) form_intervention.mark_as_edited(self.user, self.request, edit_comment=DEDUCTION_ADDED)
else: 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.account = form_account
deduction.intervention = self.cleaned_data.get("intervention", None) deduction.intervention = self.cleaned_data.get("intervention", None)
deduction.surface = self.cleaned_data.get("surface", None) deduction.surface = self.cleaned_data.get("surface", None)
deduction.save() 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 return deduction

View File

@ -28,4 +28,5 @@ USER_NOTIFICATIONS_NAMES = {
"NOTIFY_ON_SHARED_DATA_RECORDED": _("On shared data recorded"), "NOTIFY_ON_SHARED_DATA_RECORDED": _("On shared data recorded"),
"NOTIFY_ON_SHARED_DATA_DELETED": _("On shared data deleted"), "NOTIFY_ON_SHARED_DATA_DELETED": _("On shared data deleted"),
"NOTIFY_ON_SHARED_DATA_CHECKED": _("On shared data checked"), "NOTIFY_ON_SHARED_DATA_CHECKED": _("On shared data checked"),
} "NOTIFY_ON_DEDUCTION_CHANGES": _("On deduction changes"),
}

View File

@ -106,3 +106,17 @@ def celery_send_mail_shared_data_checked_team(obj_identifier, obj_title=None, te
from user.models import Team from user.models import Team
team = Team.objects.get(id=team_id) team = Team.objects.get(id=team_id)
team.send_mail_shared_data_checked(obj_identifier, obj_title) 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)

View File

@ -207,6 +207,33 @@ class Mailer:
msg 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): def send_mail_shared_data_deleted_team(self, obj_identifier, obj_title, team):
""" Send a mail if data has just been deleted """ Send a mail if data has just been deleted
@ -322,6 +349,34 @@ class Mailer:
msg 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): def send_mail_verify_api_token(self, user):
""" Send a mail if a user creates a new token """ Send a mail if a user creates a new token

Binary file not shown.

View File

@ -26,7 +26,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-08-08 14:39+0200\n" "POT-Creation-Date: 2022-08-10 08:37+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -55,7 +55,7 @@ msgstr "Einträge erstellt bis..."
#: analysis/forms.py:49 compensation/forms/forms.py:77 #: analysis/forms.py:49 compensation/forms/forms.py:77
#: compensation/templates/compensation/detail/eco_account/view.html:59 #: compensation/templates/compensation/detail/eco_account/view.html:59
#: compensation/templates/compensation/report/eco_account/report.html:16 #: compensation/templates/compensation/report/eco_account/report.html:16
#: compensation/utils/quality.py:113 ema/templates/ema/detail/view.html:49 #: compensation/utils/quality.py:111 ema/templates/ema/detail/view.html:49
#: ema/templates/ema/report/report.html:16 ema/utils/quality.py:26 #: ema/templates/ema/report/report.html:16 ema/utils/quality.py:26
#: intervention/forms/forms.py:102 #: intervention/forms/forms.py:102
#: intervention/templates/intervention/detail/view.html:56 #: intervention/templates/intervention/detail/view.html:56
@ -241,6 +241,7 @@ msgstr ""
#: ema/templates/ema/detail/includes/states-after.html:36 #: ema/templates/ema/detail/includes/states-after.html:36
#: ema/templates/ema/detail/includes/states-before.html:36 #: ema/templates/ema/detail/includes/states-before.html:36
#: intervention/forms/modalForms.py:364 #: intervention/forms/modalForms.py:364
#: templates/email/other/deduction_changed.html:29
msgid "Surface" msgid "Surface"
msgstr "Fläche" msgstr "Fläche"
@ -297,8 +298,8 @@ msgstr "Gesetz"
#: analysis/templates/analysis/reports/includes/old_data/amount.html:17 #: analysis/templates/analysis/reports/includes/old_data/amount.html:17
#: compensation/templates/compensation/detail/compensation/includes/deadlines.html:33 #: compensation/templates/compensation/detail/compensation/includes/deadlines.html:33
#: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:28 #: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:33
#: ema/templates/ema/detail/includes/deadlines.html:28 #: ema/templates/ema/detail/includes/deadlines.html:33
msgid "Type" msgid "Type"
msgstr "Typ" msgstr "Typ"
@ -307,6 +308,7 @@ msgstr "Typ"
#: intervention/forms/modalForms.py:382 intervention/tables.py:87 #: intervention/forms/modalForms.py:382 intervention/tables.py:87
#: intervention/templates/intervention/detail/view.html:19 #: intervention/templates/intervention/detail/view.html:19
#: konova/templates/konova/includes/quickstart/interventions.html:4 #: konova/templates/konova/includes/quickstart/interventions.html:4
#: templates/email/other/deduction_changed.html:24
#: templates/navbars/navbar.html:22 #: templates/navbars/navbar.html:22
msgid "Intervention" msgid "Intervention"
msgstr "Eingriff" msgstr "Eingriff"
@ -378,10 +380,10 @@ msgstr "Kompensation XY; Flur ABC"
#: compensation/templates/compensation/detail/compensation/includes/deadlines.html:39 #: compensation/templates/compensation/detail/compensation/includes/deadlines.html:39
#: compensation/templates/compensation/detail/compensation/includes/documents.html:34 #: compensation/templates/compensation/detail/compensation/includes/documents.html:34
#: compensation/templates/compensation/detail/eco_account/includes/actions.html:34 #: compensation/templates/compensation/detail/eco_account/includes/actions.html:34
#: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:34 #: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:39
#: compensation/templates/compensation/detail/eco_account/includes/documents.html:34 #: compensation/templates/compensation/detail/eco_account/includes/documents.html:34
#: ema/templates/ema/detail/includes/actions.html:34 #: ema/templates/ema/detail/includes/actions.html:34
#: ema/templates/ema/detail/includes/deadlines.html:34 #: ema/templates/ema/detail/includes/deadlines.html:39
#: ema/templates/ema/detail/includes/documents.html:34 #: ema/templates/ema/detail/includes/documents.html:34
#: intervention/forms/forms.py:198 intervention/forms/modalForms.py:175 #: intervention/forms/forms.py:198 intervention/forms/modalForms.py:175
#: intervention/templates/intervention/detail/includes/documents.html:34 #: intervention/templates/intervention/detail/includes/documents.html:34
@ -399,7 +401,7 @@ msgstr "Zusätzlicher Kommentar"
#: compensation/forms/forms.py:93 #: compensation/forms/forms.py:93
#: compensation/templates/compensation/detail/eco_account/view.html:63 #: compensation/templates/compensation/detail/eco_account/view.html:63
#: compensation/templates/compensation/report/eco_account/report.html:20 #: compensation/templates/compensation/report/eco_account/report.html:20
#: compensation/utils/quality.py:115 ema/templates/ema/detail/view.html:53 #: compensation/utils/quality.py:113 ema/templates/ema/detail/view.html:53
#: ema/templates/ema/report/report.html:20 ema/utils/quality.py:28 #: ema/templates/ema/report/report.html:20 ema/utils/quality.py:28
#: intervention/forms/forms.py:130 #: intervention/forms/forms.py:130
#: intervention/templates/intervention/detail/view.html:60 #: intervention/templates/intervention/detail/view.html:60
@ -485,7 +487,7 @@ msgstr "Neue Kompensation"
msgid "Edit compensation" msgid "Edit compensation"
msgstr "Bearbeite Kompensation" msgstr "Bearbeite Kompensation"
#: compensation/forms/forms.py:356 compensation/utils/quality.py:97 #: compensation/forms/forms.py:356 compensation/utils/quality.py:95
msgid "Available Surface" msgid "Available Surface"
msgstr "Verfügbare Fläche" msgstr "Verfügbare Fläche"
@ -495,7 +497,7 @@ msgstr "Die für Abbuchungen zur Verfügung stehende Menge"
#: compensation/forms/forms.py:368 #: compensation/forms/forms.py:368
#: compensation/templates/compensation/detail/eco_account/view.html:67 #: compensation/templates/compensation/detail/eco_account/view.html:67
#: compensation/utils/quality.py:85 #: compensation/utils/quality.py:83
msgid "Agreement date" msgid "Agreement date"
msgstr "Vereinbarungsdatum" msgstr "Vereinbarungsdatum"
@ -598,8 +600,8 @@ msgstr "Fristart wählen"
#: compensation/forms/modalForms.py:345 #: compensation/forms/modalForms.py:345
#: compensation/templates/compensation/detail/compensation/includes/deadlines.html:36 #: compensation/templates/compensation/detail/compensation/includes/deadlines.html:36
#: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:31 #: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:36
#: ema/templates/ema/detail/includes/deadlines.html:31 #: ema/templates/ema/detail/includes/deadlines.html:36
#: intervention/forms/modalForms.py:149 #: intervention/forms/modalForms.py:149
msgid "Date" msgid "Date"
msgstr "Datum" msgstr "Datum"
@ -618,8 +620,8 @@ msgstr "Geben Sie die Daten der neuen Frist ein"
#: compensation/forms/modalForms.py:389 #: compensation/forms/modalForms.py:389
#: compensation/templates/compensation/detail/compensation/includes/deadlines.html:64 #: compensation/templates/compensation/detail/compensation/includes/deadlines.html:64
#: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:57 #: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:62
#: ema/templates/ema/detail/includes/deadlines.html:57 #: ema/templates/ema/detail/includes/deadlines.html:62
msgid "Edit deadline" msgid "Edit deadline"
msgstr "Frist/Termin bearbeiten" msgstr "Frist/Termin bearbeiten"
@ -696,14 +698,14 @@ msgstr ""
msgid "Pieces" msgid "Pieces"
msgstr "Stück" msgstr "Stück"
#: compensation/models/eco_account.py:55 #: compensation/models/eco_account.py:56
msgid "" msgid ""
"Deductable surface can not be larger than existing surfaces in after states" "Deductable surface can not be larger than existing surfaces in after states"
msgstr "" msgstr ""
"Die abbuchbare Fläche darf die Gesamtfläche der Zielzustände nicht " "Die abbuchbare Fläche darf die Gesamtfläche der Zielzustände nicht "
"überschreiten" "überschreiten"
#: compensation/models/eco_account.py:62 #: compensation/models/eco_account.py:63
msgid "" msgid ""
"Deductable surface can not be smaller than the sum of already existing " "Deductable surface can not be smaller than the sum of already existing "
"deductions. Please contact the responsible users for the deductions!" "deductions. Please contact the responsible users for the deductions!"
@ -803,13 +805,13 @@ msgstr "Menge"
#: compensation/templates/compensation/detail/compensation/includes/states-after.html:41 #: compensation/templates/compensation/detail/compensation/includes/states-after.html:41
#: compensation/templates/compensation/detail/compensation/includes/states-before.html:41 #: compensation/templates/compensation/detail/compensation/includes/states-before.html:41
#: compensation/templates/compensation/detail/eco_account/includes/actions.html:39 #: compensation/templates/compensation/detail/eco_account/includes/actions.html:39
#: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:38 #: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:43
#: compensation/templates/compensation/detail/eco_account/includes/deductions.html:41 #: compensation/templates/compensation/detail/eco_account/includes/deductions.html:41
#: compensation/templates/compensation/detail/eco_account/includes/documents.html:38 #: compensation/templates/compensation/detail/eco_account/includes/documents.html:38
#: compensation/templates/compensation/detail/eco_account/includes/states-after.html:41 #: compensation/templates/compensation/detail/eco_account/includes/states-after.html:41
#: compensation/templates/compensation/detail/eco_account/includes/states-before.html:41 #: compensation/templates/compensation/detail/eco_account/includes/states-before.html:41
#: ema/templates/ema/detail/includes/actions.html:38 #: ema/templates/ema/detail/includes/actions.html:38
#: ema/templates/ema/detail/includes/deadlines.html:38 #: ema/templates/ema/detail/includes/deadlines.html:43
#: ema/templates/ema/detail/includes/documents.html:38 #: ema/templates/ema/detail/includes/documents.html:38
#: ema/templates/ema/detail/includes/states-after.html:40 #: ema/templates/ema/detail/includes/states-after.html:40
#: ema/templates/ema/detail/includes/states-before.html:40 #: ema/templates/ema/detail/includes/states-before.html:40
@ -883,12 +885,14 @@ msgid "Add new deadline"
msgstr "Frist/Termin hinzufügen" msgstr "Frist/Termin hinzufügen"
#: compensation/templates/compensation/detail/compensation/includes/deadlines.html:25 #: compensation/templates/compensation/detail/compensation/includes/deadlines.html:25
#: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:25
#: ema/templates/ema/detail/includes/deadlines.html:25
msgid "Missing finished deadline " msgid "Missing finished deadline "
msgstr "Umsetzungstermin fehlt" msgstr "Umsetzungstermin fehlt"
#: compensation/templates/compensation/detail/compensation/includes/deadlines.html:67 #: compensation/templates/compensation/detail/compensation/includes/deadlines.html:67
#: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:60 #: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:65
#: ema/templates/ema/detail/includes/deadlines.html:60 #: ema/templates/ema/detail/includes/deadlines.html:65
msgid "Remove deadline" msgid "Remove deadline"
msgstr "Frist löschen" msgstr "Frist löschen"
@ -932,7 +936,7 @@ msgstr "Dokument löschen"
#: compensation/templates/compensation/detail/compensation/includes/states-after.html:8 #: compensation/templates/compensation/detail/compensation/includes/states-after.html:8
#: compensation/templates/compensation/detail/eco_account/includes/states-after.html:8 #: compensation/templates/compensation/detail/eco_account/includes/states-after.html:8
#: compensation/utils/quality.py:42 #: compensation/utils/quality.py:40
#: ema/templates/ema/detail/includes/states-after.html:8 #: ema/templates/ema/detail/includes/states-after.html:8
msgid "States after" msgid "States after"
msgstr "Zielzustand" msgstr "Zielzustand"
@ -978,7 +982,7 @@ msgstr "Zustand entfernen"
#: compensation/templates/compensation/detail/compensation/includes/states-before.html:8 #: compensation/templates/compensation/detail/compensation/includes/states-before.html:8
#: compensation/templates/compensation/detail/eco_account/includes/states-before.html:8 #: compensation/templates/compensation/detail/eco_account/includes/states-before.html:8
#: compensation/utils/quality.py:40 #: compensation/utils/quality.py:38
#: ema/templates/ema/detail/includes/states-before.html:8 #: ema/templates/ema/detail/includes/states-before.html:8
msgid "States before" msgid "States before"
msgstr "Ausgangszustand" msgstr "Ausgangszustand"
@ -1188,25 +1192,25 @@ msgstr "Abbuchungen für"
msgid "None" msgid "None"
msgstr "-" msgstr "-"
#: compensation/utils/quality.py:37 #: compensation/utils/quality.py:35
msgid "States unequal" msgid "States unequal"
msgstr "Ungleiche Zustandsflächenmengen" msgstr "Ungleiche Zustandsflächenmengen"
#: compensation/utils/quality.py:61 #: compensation/utils/quality.py:59
msgid "Finished deadlines" msgid "Finished deadlines"
msgstr "Umsetzungstermin" msgstr "Umsetzungstermin"
#: compensation/utils/quality.py:87 intervention/utils/quality.py:84 #: compensation/utils/quality.py:85 intervention/utils/quality.py:84
msgid "Legal data" msgid "Legal data"
msgstr "Rechtliche Daten" msgstr "Rechtliche Daten"
#: compensation/utils/quality.py:101 #: compensation/utils/quality.py:99
msgid "Deductable surface can not be larger than state surface" msgid "Deductable surface can not be larger than state surface"
msgstr "" msgstr ""
"Die abbuchbare Fläche darf die Gesamtfläche der Zielzustände nicht " "Die abbuchbare Fläche darf die Gesamtfläche der Zielzustände nicht "
"überschreiten" "überschreiten"
#: compensation/utils/quality.py:117 ema/utils/quality.py:30 #: compensation/utils/quality.py:115 ema/utils/quality.py:30
#: intervention/utils/quality.py:55 #: intervention/utils/quality.py:55
msgid "Responsible data" msgid "Responsible data"
msgstr "Daten zu den verantwortlichen Stellen" msgstr "Daten zu den verantwortlichen Stellen"
@ -1220,17 +1224,17 @@ msgid "Compensation {} edited"
msgstr "Kompensation {} bearbeitet" msgstr "Kompensation {} bearbeitet"
#: compensation/views/compensation.py:182 compensation/views/eco_account.py:173 #: compensation/views/compensation.py:182 compensation/views/eco_account.py:173
#: ema/views.py:240 intervention/views.py:338 #: ema/views.py:241 intervention/views.py:338
msgid "Edit {}" msgid "Edit {}"
msgstr "Bearbeite {}" msgstr "Bearbeite {}"
#: compensation/views/compensation.py:269 compensation/views/eco_account.py:359 #: compensation/views/compensation.py:269 compensation/views/eco_account.py:360
#: ema/views.py:194 intervention/views.py:542 #: ema/views.py:195 intervention/views.py:542
msgid "Log" msgid "Log"
msgstr "Log" msgstr "Log"
#: compensation/views/compensation.py:613 compensation/views/eco_account.py:727 #: compensation/views/compensation.py:613 compensation/views/eco_account.py:728
#: ema/views.py:558 intervention/views.py:688 #: ema/views.py:559 intervention/views.py:688
msgid "Report {}" msgid "Report {}"
msgstr "Bericht {}" msgstr "Bericht {}"
@ -1246,36 +1250,36 @@ msgstr "Ökokonto {} hinzugefügt"
msgid "Eco-Account {} edited" msgid "Eco-Account {} edited"
msgstr "Ökokonto {} bearbeitet" msgstr "Ökokonto {} bearbeitet"
#: compensation/views/eco_account.py:276 #: compensation/views/eco_account.py:277
msgid "Eco-account removed" msgid "Eco-account removed"
msgstr "Ökokonto entfernt" msgstr "Ökokonto entfernt"
#: compensation/views/eco_account.py:380 ema/views.py:282 #: compensation/views/eco_account.py:381 ema/views.py:283
#: intervention/views.py:641 #: intervention/views.py:641
msgid "{} unrecorded" msgid "{} unrecorded"
msgstr "{} entzeichnet" msgstr "{} entzeichnet"
#: compensation/views/eco_account.py:380 ema/views.py:282 #: compensation/views/eco_account.py:381 ema/views.py:283
#: intervention/views.py:641 #: intervention/views.py:641
msgid "{} recorded" msgid "{} recorded"
msgstr "{} verzeichnet" msgstr "{} verzeichnet"
#: compensation/views/eco_account.py:804 ema/views.py:628 #: compensation/views/eco_account.py:805 ema/views.py:629
#: intervention/views.py:439 #: intervention/views.py:439
msgid "{} has already been shared with you" msgid "{} has already been shared with you"
msgstr "{} wurde bereits für Sie freigegeben" msgstr "{} wurde bereits für Sie freigegeben"
#: compensation/views/eco_account.py:809 ema/views.py:633 #: compensation/views/eco_account.py:810 ema/views.py:634
#: intervention/views.py:444 #: intervention/views.py:444
msgid "{} has been shared with you" msgid "{} has been shared with you"
msgstr "{} ist nun für Sie freigegeben" msgstr "{} ist nun für Sie freigegeben"
#: compensation/views/eco_account.py:816 ema/views.py:640 #: compensation/views/eco_account.py:817 ema/views.py:641
#: intervention/views.py:451 #: intervention/views.py:451
msgid "Share link invalid" msgid "Share link invalid"
msgstr "Freigabelink ungültig" msgstr "Freigabelink ungültig"
#: compensation/views/eco_account.py:839 ema/views.py:663 #: compensation/views/eco_account.py:840 ema/views.py:664
#: intervention/views.py:474 #: intervention/views.py:474
msgid "Share settings updated" msgid "Share settings updated"
msgstr "Freigabe Einstellungen aktualisiert" msgstr "Freigabe Einstellungen aktualisiert"
@ -1316,11 +1320,11 @@ msgstr "EMAs - Übersicht"
msgid "EMA {} added" msgid "EMA {} added"
msgstr "EMA {} hinzugefügt" msgstr "EMA {} hinzugefügt"
#: ema/views.py:230 #: ema/views.py:231
msgid "EMA {} edited" msgid "EMA {} edited"
msgstr "EMA {} bearbeitet" msgstr "EMA {} bearbeitet"
#: ema/views.py:263 #: ema/views.py:264
msgid "EMA removed" msgid "EMA removed"
msgstr "EMA entfernt" msgstr "EMA entfernt"
@ -1799,6 +1803,10 @@ msgstr "Wenn meine freigegebenen Daten gelöscht wurden"
msgid "On shared data checked" msgid "On shared data checked"
msgstr "Wenn meine freigegebenen Daten geprüft wurden" msgstr "Wenn meine freigegebenen Daten geprüft wurden"
#: konova/management/commands/setup_data.py:31
msgid "On deduction changes"
msgstr "Wenn eine Abbuchung zu meinem Ökokonto verändert wird"
#: konova/models/deadline.py:18 #: konova/models/deadline.py:18
msgid "Finished" msgid "Finished"
msgstr "Umgesetzt bis" msgstr "Umgesetzt bis"
@ -1909,23 +1917,27 @@ msgstr "{} - Zugriff entzogen"
msgid "{} - Shared access given" msgid "{} - Shared access given"
msgstr "{} - Zugriff freigegeben" 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" msgid "{} - Shared data unrecorded"
msgstr "{} - Freigegebene Daten entzeichnet" 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" msgid "{} - Shared data recorded"
msgstr "{} - Freigegebene Daten verzeichnet" 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" msgid "{} - Shared data checked"
msgstr "{} - Freigegebene Daten geprüft" 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" msgid "{} - Shared data deleted"
msgstr "{} - Freigegebene Daten gelöscht" 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" msgid "Request for new API token"
msgstr "Anfrage für neuen API Token" msgstr "Anfrage für neuen API Token"
@ -2229,6 +2241,7 @@ msgstr ""
#: templates/email/checking/shared_data_checked_team.html:19 #: templates/email/checking/shared_data_checked_team.html:19
#: templates/email/deleting/shared_data_deleted.html:19 #: templates/email/deleting/shared_data_deleted.html:19
#: templates/email/deleting/shared_data_deleted_team.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.html:19
#: templates/email/recording/shared_data_recorded_team.html:19 #: templates/email/recording/shared_data_recorded_team.html:19
#: templates/email/recording/shared_data_unrecorded.html:19 #: templates/email/recording/shared_data_unrecorded.html:19
@ -2247,6 +2260,7 @@ msgstr "Freigegebene Daten geprüft"
#: templates/email/checking/shared_data_checked.html:8 #: templates/email/checking/shared_data_checked.html:8
#: templates/email/deleting/shared_data_deleted.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_recorded.html:8
#: templates/email/recording/shared_data_unrecorded.html:8 #: templates/email/recording/shared_data_unrecorded.html:8
#: templates/email/sharing/shared_access_given.html:8 #: templates/email/sharing/shared_access_given.html:8
@ -2289,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.html:16
#: templates/email/deleting/shared_data_deleted_team.html:16 #: templates/email/deleting/shared_data_deleted_team.html:16
#: templates/email/other/deduction_changed.html:35
msgid "" msgid ""
"If this should not have been happened, please contact us. See the signature " "If this should not have been happened, please contact us. See the signature "
"for details." "for details."
@ -2296,6 +2311,31 @@ msgstr ""
"Falls das nicht hätte passieren dürfen, kontaktieren Sie uns bitte. In der E-" "Falls das nicht hätte passieren dürfen, kontaktieren Sie uns bitte. In der E-"
"mail Signatur finden Sie weitere Kontaktinformationen." "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.html:4
#: templates/email/recording/shared_data_recorded_team.html:4 #: templates/email/recording/shared_data_recorded_team.html:4
msgid "Shared data recorded" msgid "Shared data recorded"
@ -2493,10 +2533,6 @@ msgstr "* sind Pflichtfelder."
msgid "New entry" msgid "New entry"
msgstr "Neuer Eintrag" msgstr "Neuer Eintrag"
#: templates/generic_index.html:43 user/templates/user/team/index.html:22
msgid "New"
msgstr "Neu"
#: templates/generic_index.html:58 #: templates/generic_index.html:58
msgid "Search for keywords" msgid "Search for keywords"
msgstr "Nach Schlagwörtern suchen" msgstr "Nach Schlagwörtern suchen"

View File

@ -6,6 +6,7 @@
<article> <article>
{% trans 'Hello support' %}, {% trans 'Hello support' %},
<br> <br>
<br>
{% trans 'you need to verify the API token for user' %}: {% trans 'you need to verify the API token for user' %}:
<br> <br>
<br> <br>

View File

@ -7,6 +7,7 @@
<article> <article>
{% trans 'Hello ' %} {{user.username}}, {% trans 'Hello ' %} {{user.username}},
<br> <br>
<br>
{% trans 'the following dataset has just been checked' %} {% trans 'the following dataset has just been checked' %}
<br> <br>
<strong>{{obj_identifier}}</strong> <strong>{{obj_identifier}}</strong>

View File

@ -7,6 +7,7 @@
<article> <article>
{% trans 'Hello team' %} {{team.name}}, {% trans 'Hello team' %} {{team.name}},
<br> <br>
<br>
{% trans 'the following dataset has just been checked' %} {% trans 'the following dataset has just been checked' %}
<br> <br>
<strong>{{obj_identifier}}</strong> <strong>{{obj_identifier}}</strong>

View File

@ -7,6 +7,7 @@
<article> <article>
{% trans 'Hello ' %} {{user.username}}, {% trans 'Hello ' %} {{user.username}},
<br> <br>
<br>
{% trans 'the following dataset has just been deleted' %} {% trans 'the following dataset has just been deleted' %}
<br> <br>
<strong>{{obj_identifier}}</strong> <strong>{{obj_identifier}}</strong>

View File

@ -7,6 +7,7 @@
<article> <article>
{% trans 'Hello team' %} {{team.name}}, {% trans 'Hello team' %} {{team.name}},
<br> <br>
<br>
{% trans 'the following dataset has just been deleted' %} {% trans 'the following dataset has just been deleted' %}
<br> <br>
<strong>{{obj_identifier}}</strong> <strong>{{obj_identifier}}</strong>

View File

@ -0,0 +1,50 @@
{% load i18n %}
<div>
<h2>{% translate 'Deduction changed' %}</h2>
<h4>{{obj_identifier}}</h4>
<hr>
<article>
{% translate 'Hello ' %} {{user.username}},
<br>
<br>
{% translate 'a deduction of this eco account has changed:' %}
<br>
<br>
<table>
<tr>
<th scope="col">{% translate 'Attribute' %}</th>
<th scope="col">{% translate 'Old' %}</th>
<th scope="col">{% translate 'New' %}</th>
</tr>
<tr>
<td>{% translate 'EcoAccount' %}</td>
<td>{{data_changes.account.old}}</td>
<td>{{data_changes.account.new}}</td>
</tr>
<tr>
<td>{% translate 'Intervention' %}</td>
<td>{{data_changes.intervention.old}}</td>
<td>{{data_changes.intervention.new}}</td>
</tr>
<tr>
<td>{% translate 'Surface' %}</td>
<td>{{data_changes.surface.old}} m²</td>
<td>{{data_changes.surface.new}} m²</td>
</tr>
</table>
<br>
<br>
{% translate 'If this should not have been happened, please contact us. See the signature for details.' %}
<br>
<br>
{% translate 'Best regards' %}
<br>
KSP
<br>
<br>
<br>
{% include 'email/signature.html' %}
</article>
</div>

View File

@ -0,0 +1,50 @@
{% load i18n %}
<div>
<h2>{% translate 'Deduction changed' %}</h2>
<h4>{{obj_identifier}}</h4>
<hr>
<article>
{% trans 'Hello team' %} {{team.name}},
<br>
<br>
{% translate 'a deduction of this eco account has changed:' %}
<br>
<br>
<table>
<tr>
<th scope="col">{% translate 'Attribute' %}</th>
<th scope="col">{% translate 'Old' %}</th>
<th scope="col">{% translate 'New' %}</th>
</tr>
<tr>
<td>{% translate 'EcoAccount' %}</td>
<td>{{data_changes.account.old}}</td>
<td>{{data_changes.account.new}}</td>
</tr>
<tr>
<td>{% translate 'Intervention' %}</td>
<td>{{data_changes.intervention.old}}</td>
<td>{{data_changes.intervention.new}}</td>
</tr>
<tr>
<td>{% translate 'Surface' %}</td>
<td>{{data_changes.surface.old}} m²</td>
<td>{{data_changes.surface.new}} m²</td>
</tr>
</table>
<br>
<br>
{% translate 'If this should not have been happened, please contact us. See the signature for details.' %}
<br>
<br>
{% translate 'Best regards' %}
<br>
KSP
<br>
<br>
<br>
{% include 'email/signature.html' %}
</article>
</div>

View File

@ -7,6 +7,7 @@
<article> <article>
{% trans 'Hello ' %} {{user.username}}, {% trans 'Hello ' %} {{user.username}},
<br> <br>
<br>
{% trans 'the following dataset has just been recorded' %} {% trans 'the following dataset has just been recorded' %}
<br> <br>
<strong>{{obj_identifier}}</strong> <strong>{{obj_identifier}}</strong>

View File

@ -7,6 +7,7 @@
<article> <article>
{% trans 'Hello team' %} {{team.name}}, {% trans 'Hello team' %} {{team.name}},
<br> <br>
<br>
{% trans 'the following dataset has just been recorded' %} {% trans 'the following dataset has just been recorded' %}
<br> <br>
<strong>{{obj_identifier}}</strong> <strong>{{obj_identifier}}</strong>

View File

@ -7,6 +7,7 @@
<article> <article>
{% trans 'Hello ' %} {{user.username}}, {% trans 'Hello ' %} {{user.username}},
<br> <br>
<br>
{% trans 'the following dataset has just been unrecorded' %} {% trans 'the following dataset has just been unrecorded' %}
<br> <br>
<strong>{{obj_identifier}}</strong> <strong>{{obj_identifier}}</strong>

View File

@ -7,6 +7,7 @@
<article> <article>
{% trans 'Hello team' %} {{team.name}}, {% trans 'Hello team' %} {{team.name}},
<br> <br>
<br>
{% trans 'the following dataset has just been unrecorded' %} {% trans 'the following dataset has just been unrecorded' %}
<br> <br>
<strong>{{obj_identifier}}</strong> <strong>{{obj_identifier}}</strong>

View File

@ -7,6 +7,7 @@
<article> <article>
{% trans 'Hello ' %} {{user.username}}, {% trans 'Hello ' %} {{user.username}},
<br> <br>
<br>
{% trans 'the following dataset has just been shared with you' %} {% trans 'the following dataset has just been shared with you' %}
<br> <br>
<strong>{{obj_identifier}}</strong> <strong>{{obj_identifier}}</strong>

View File

@ -7,6 +7,7 @@
<article> <article>
{% trans 'Hello team' %} {{team.name}}, {% trans 'Hello team' %} {{team.name}},
<br> <br>
<br>
{% trans 'the following dataset has just been shared with your team' %} {% trans 'the following dataset has just been shared with your team' %}
<br> <br>
<strong>{{obj_identifier}}</strong> <strong>{{obj_identifier}}</strong>

View File

@ -7,6 +7,7 @@
<article> <article>
{% trans 'Hello ' %} {{user.username}}, {% trans 'Hello ' %} {{user.username}},
<br> <br>
<br>
{% trans 'your shared access, including editing, has been revoked for the dataset ' %} {% trans 'your shared access, including editing, has been revoked for the dataset ' %}
<br> <br>
<strong>{{obj_identifier}}</strong> <strong>{{obj_identifier}}</strong>

View File

@ -7,6 +7,7 @@
<article> <article>
{% trans 'Hello team' %} {{team.name}}, {% trans 'Hello team' %} {{team.name}},
<br> <br>
<br>
{% trans 'your teams shared access, including editing, has been revoked for the dataset ' %} {% trans 'your teams shared access, including editing, has been revoked for the dataset ' %}
<br> <br>
<strong>{{obj_identifier}}</strong> <strong>{{obj_identifier}}</strong>

View File

@ -13,4 +13,5 @@ class UserNotificationEnum(BaseEnum):
NOTIFY_ON_SHARED_DATA_RECORDED = "NOTIFY_ON_SHARED_DATA_RECORDED" # notifies in case data has been "verzeichnet" NOTIFY_ON_SHARED_DATA_RECORDED = "NOTIFY_ON_SHARED_DATA_RECORDED" # notifies in case data has been "verzeichnet"
NOTIFY_ON_SHARED_DATA_DELETED = "NOTIFY_ON_SHARED_DATA_DELETED" # notifies in case data has been deleted NOTIFY_ON_SHARED_DATA_DELETED = "NOTIFY_ON_SHARED_DATA_DELETED" # notifies in case data has been deleted
NOTIFY_ON_SHARED_DATA_CHECKED = "NOTIFY_ON_SHARED_DATA_CHECKED" # notifies in case shared data has been checked NOTIFY_ON_SHARED_DATA_CHECKED = "NOTIFY_ON_SHARED_DATA_CHECKED" # notifies in case shared data has been checked
NOTIFY_ON_SHARED_ACCESS_GAINED = "NOTIFY_ON_SHARED_ACCESS_GAINED" # notifies in case new access has been gained NOTIFY_ON_SHARED_ACCESS_GAINED = "NOTIFY_ON_SHARED_ACCESS_GAINED" # notifies in case new access has been gained
NOTIFY_ON_DEDUCTION_CHANGES = "NOTIFY_ON_DEDUCTION_CHANGES" # notifies in case any changes (edit|remove) have been performed on a deduction of the user's ecoaccounts

View File

@ -7,7 +7,7 @@ Created on: 08.07.21
""" """
from dal import autocomplete from dal import autocomplete
from django import forms from django import forms
from django.db import IntegrityError, transaction from django.db import transaction
from django.urls import reverse, reverse_lazy from django.urls import reverse, reverse_lazy
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _

View File

@ -95,6 +95,20 @@ class Team(UuidModel, DeletableObjectMixin):
mailer = Mailer() mailer = Mailer()
mailer.send_mail_shared_data_checked_team(obj_identifier, obj_title, self) 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): def send_mail_shared_data_deleted(self, obj_identifier, obj_title):
""" Sends a mail to the team members in case of deleted data """ Sends a mail to the team members in case of deleted data

View File

@ -145,6 +145,22 @@ class User(AbstractUser):
mailer = Mailer() mailer = Mailer()
mailer.send_mail_shared_data_checked(obj_identifier, obj_title, self) 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): def get_API_token(self):
""" Getter for an API token """ Getter for an API token