# 63 Mail data checked
* adds mail sending if shared data is checked * adds/updates translations
This commit is contained in:
parent
dcc4e2fdc8
commit
1de3792d98
@ -12,7 +12,8 @@ from abc import abstractmethod
|
||||
from django.contrib import messages
|
||||
|
||||
from konova.tasks import celery_send_mail_shared_access_removed, celery_send_mail_shared_access_given, \
|
||||
celery_send_mail_shared_data_recorded, celery_send_mail_shared_data_unrecorded, celery_send_mail_shared_data_deleted
|
||||
celery_send_mail_shared_data_recorded, celery_send_mail_shared_data_unrecorded, \
|
||||
celery_send_mail_shared_data_deleted, celery_send_mail_shared_data_checked
|
||||
from user.models import User
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.http import HttpRequest
|
||||
@ -324,6 +325,12 @@ class CheckableObjectMixin(models.Model):
|
||||
action = UserActionLogEntry.get_checked_action(user)
|
||||
self.checked = action
|
||||
self.save()
|
||||
|
||||
# Send mail
|
||||
shared_users = self.users.all().values_list("id", flat=True)
|
||||
for user_id in shared_users:
|
||||
celery_send_mail_shared_data_checked.delay(self.identifier, user_id)
|
||||
|
||||
self.log.add(action)
|
||||
return action
|
||||
|
||||
|
@ -51,3 +51,10 @@ def celery_send_mail_shared_data_deleted(obj_identifier, user_id):
|
||||
from user.models import User
|
||||
user = User.objects.get(id=user_id)
|
||||
user.send_mail_shared_data_deleted(obj_identifier)
|
||||
|
||||
|
||||
@shared_task
|
||||
def celery_send_mail_shared_data_checked(obj_identifier, user_id):
|
||||
from user.models import User
|
||||
user = User.objects.get(id=user_id)
|
||||
user.send_mail_shared_data_checked(obj_identifier)
|
||||
|
@ -138,7 +138,7 @@ class Mailer:
|
||||
)
|
||||
|
||||
def send_mail_shared_data_deleted(self, obj_identifier, user):
|
||||
""" Send a mail if user just got access to the object
|
||||
""" Send a mail if shared data has just been deleted
|
||||
|
||||
Args:
|
||||
obj_identifier (str): The object identifier
|
||||
@ -159,3 +159,25 @@ class Mailer:
|
||||
msg
|
||||
)
|
||||
|
||||
def send_mail_shared_data_checked(self, obj_identifier, user):
|
||||
""" Send a mail if shared data just has been checked
|
||||
|
||||
Args:
|
||||
obj_identifier (str): The object identifier
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
context = {
|
||||
"user": user,
|
||||
"obj_identifier": obj_identifier,
|
||||
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
|
||||
}
|
||||
msg = render_to_string("email/checking/shared_data_checked.html", context)
|
||||
user_mail_address = [user.email]
|
||||
self.send(
|
||||
user_mail_address,
|
||||
_("{} - Shared data checked").format(obj_identifier),
|
||||
msg
|
||||
)
|
||||
|
||||
|
Binary file not shown.
@ -26,7 +26,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-01-12 15:36+0100\n"
|
||||
"POT-Creation-Date: 2022-01-12 15:43+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -1773,6 +1773,10 @@ msgstr "{} - Freigegebene Daten entzeichnet"
|
||||
msgid "{} - Shared data deleted"
|
||||
msgstr "{} - Freigegebene Daten gelöscht"
|
||||
|
||||
#: konova/utils/mailer.py:180
|
||||
msgid "{} - Shared data checked"
|
||||
msgstr "{} - Freigegebene Daten geprüft"
|
||||
|
||||
#: konova/utils/message_templates.py:11
|
||||
msgid "There was an error on this form."
|
||||
msgstr "Es gab einen Fehler im Formular."
|
||||
@ -1887,10 +1891,11 @@ msgstr "Alle"
|
||||
msgid "News"
|
||||
msgstr "Neuigkeiten"
|
||||
|
||||
#: templates/email/deleting/shared_data_deleted.html:4
|
||||
msgid "Shared data deleted"
|
||||
msgstr "Freigegebene Daten gelöscht"
|
||||
#: templates/email/checking/shared_data_checked.html:4
|
||||
msgid "Shared data checked"
|
||||
msgstr "Freigegebene Daten geprüft"
|
||||
|
||||
#: templates/email/checking/shared_data_checked.html:8
|
||||
#: templates/email/deleting/shared_data_deleted.html:8
|
||||
#: templates/email/recording/shared_data_recorded.html:8
|
||||
#: templates/email/recording/shared_data_unrecorded.html:8
|
||||
@ -1899,6 +1904,31 @@ msgstr "Freigegebene Daten gelöscht"
|
||||
msgid "Hello "
|
||||
msgstr "Hallo "
|
||||
|
||||
#: templates/email/checking/shared_data_checked.html:10
|
||||
msgid "the following dataset has just been checked"
|
||||
msgstr "der folgende Datensatz wurde soeben geprüft "
|
||||
|
||||
#: templates/email/checking/shared_data_checked.html:14
|
||||
msgid ""
|
||||
"This means, the responsible registration office just confirmed the "
|
||||
"correctness of this dataset."
|
||||
msgstr ""
|
||||
"Das bedeutet, dass die zuständige Zulassungsbehörde die Korrektheit des Datensatzes "
|
||||
"soeben bestätigt hat."
|
||||
|
||||
#: templates/email/checking/shared_data_checked.html:17
|
||||
#: templates/email/deleting/shared_data_deleted.html:17
|
||||
#: templates/email/recording/shared_data_recorded.html:17
|
||||
#: templates/email/recording/shared_data_unrecorded.html:17
|
||||
#: templates/email/sharing/shared_access_given.html:18
|
||||
#: templates/email/sharing/shared_access_removed.html:18
|
||||
msgid "Best regards"
|
||||
msgstr "Beste Grüße"
|
||||
|
||||
#: templates/email/deleting/shared_data_deleted.html:4
|
||||
msgid "Shared data deleted"
|
||||
msgstr "Freigegebene Daten gelöscht"
|
||||
|
||||
#: templates/email/deleting/shared_data_deleted.html:10
|
||||
msgid "the following dataset has just been deleted"
|
||||
msgstr "der folgende Datensatz wurde soeben gelöscht "
|
||||
@ -1911,14 +1941,6 @@ msgstr ""
|
||||
"Falls das nicht hätte passieren dürfen, kontaktieren Sie uns bitte. In der E-"
|
||||
"mail Signatur finden Sie weitere Kontaktinformationen."
|
||||
|
||||
#: templates/email/deleting/shared_data_deleted.html:17
|
||||
#: templates/email/recording/shared_data_recorded.html:17
|
||||
#: templates/email/recording/shared_data_unrecorded.html:17
|
||||
#: templates/email/sharing/shared_access_given.html:18
|
||||
#: templates/email/sharing/shared_access_removed.html:18
|
||||
msgid "Best regards"
|
||||
msgstr "Beste Grüße"
|
||||
|
||||
#: templates/email/recording/shared_data_recorded.html:4
|
||||
msgid "Shared data recorded"
|
||||
msgstr "Freigegebene Daten verzeichnet"
|
||||
|
26
templates/email/checking/shared_data_checked.html
Normal file
26
templates/email/checking/shared_data_checked.html
Normal file
@ -0,0 +1,26 @@
|
||||
{% load i18n %}
|
||||
|
||||
<div>
|
||||
<h2>{% trans 'Shared data checked' %}</h2>
|
||||
<h4>{{obj_identifier}}</h4>
|
||||
<hr>
|
||||
<article>
|
||||
{% trans 'Hello ' %} {{user.username}},
|
||||
<br>
|
||||
{% trans 'the following dataset has just been checked' %}
|
||||
<br>
|
||||
<strong>'{{obj_identifier}}'</strong>
|
||||
<br>
|
||||
{% trans 'This means, the responsible registration office just confirmed the correctness of this dataset.' %}
|
||||
<br>
|
||||
<br>
|
||||
{% trans 'Best regards' %}
|
||||
<br>
|
||||
KSP
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
{% include 'email/signature.html' %}
|
||||
</article>
|
||||
</div>
|
||||
|
@ -90,3 +90,17 @@ class User(AbstractUser):
|
||||
if notification_set:
|
||||
mailer = Mailer()
|
||||
mailer.send_mail_shared_data_deleted(obj_identifier, self)
|
||||
|
||||
def send_mail_shared_data_checked(self, obj_identifier):
|
||||
""" Sends a mail to the user in case of shared data has been deleted
|
||||
|
||||
Args:
|
||||
obj_identifier ():
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
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, self)
|
||||
|
Loading…
Reference in New Issue
Block a user