# 63 Mail recording/unrecording

* adds mail sending in case of unrecording and recording of data
* adds/updates translations
pull/65/head
mpeltriaux 3 years ago
parent 17dc3f7537
commit 157f05ead6

@ -11,7 +11,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
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
from user.models import User
from django.core.exceptions import ObjectDoesNotExist
from django.http import HttpRequest
@ -218,6 +219,11 @@ class RecordableObjectMixin(models.Model):
self.recorded = None
self.save()
self.log.add(action)
shared_users = self.users.all().values_list("id", flat=True)
for user_id in shared_users:
celery_send_mail_shared_data_unrecorded(self.identifier, user_id)
return action
def set_recorded(self, user: User):
@ -235,6 +241,11 @@ class RecordableObjectMixin(models.Model):
self.recorded = action
self.save()
self.log.add(action)
shared_users = self.users.all().values_list("id", flat=True)
for user_id in shared_users:
celery_send_mail_shared_data_recorded(self.identifier, user_id)
return action
def mark_as_edited(self, performing_user: User, request: HttpRequest = None, edit_comment: str = None):

@ -29,4 +29,18 @@ def celery_send_mail_shared_access_removed(obj_identifier, user_id):
def celery_send_mail_shared_access_given(obj_identifier, user_id):
from user.models import User
user = User.objects.get(id=user_id)
user.send_mail_shared_access_given(obj_identifier)
user.send_mail_shared_access_given(obj_identifier)
@shared_task
def celery_send_mail_shared_data_recorded(obj_identifier, user_id):
from user.models import User
user = User.objects.get(id=user_id)
user.send_mail_shared_data_recorded(obj_identifier)
@shared_task
def celery_send_mail_shared_data_unrecorded(obj_identifier, user_id):
from user.models import User
user = User.objects.get(id=user_id)
user.send_mail_shared_data_unrecorded(obj_identifier)

@ -93,3 +93,47 @@ class Mailer:
msg
)
def send_mail_shared_data_recorded(self, obj_identifier, user):
""" Send a mail if user just got access to the object
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/sharing/shared_data_recorded.html", context)
user_mail_address = [user.email]
self.send(
user_mail_address,
_("{} - Shared data recorded").format(obj_identifier),
msg
)
def send_mail_shared_data_unrecorded(self, obj_identifier, user):
""" Send a mail if user just got access to the object
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/sharing/shared_data_unrecorded.html", context)
user_mail_address = [user.email]
self.send(
user_mail_address,
_("{} - Shared data unrecorded").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 14:31+0100\n"
"POT-Creation-Date: 2022-01-12 15:06+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"
@ -1761,6 +1761,14 @@ msgstr "{} - Zugriff entzogen"
msgid "{} - Shared access given"
msgstr "{} - Zugriff freigegeben"
#: konova/utils/mailer.py:114
msgid "{} - Shared data recorded"
msgstr "{} - Freigegebene Daten verzeichnet"
#: konova/utils/mailer.py:136
msgid "{} - Shared data unrecorded"
msgstr "{} - Freigegebene Daten entzeichnet"
#: konova/utils/message_templates.py:11
msgid "There was an error on this form."
msgstr "Es gab einen Fehler im Formular."
@ -1881,6 +1889,8 @@ msgstr "Zugriff freigegeben"
#: templates/email/sharing/shared_access_given.html:8
#: templates/email/sharing/shared_access_removed.html:8
#: templates/email/sharing/shared_data_recorded.html:8
#: templates/email/sharing/shared_data_unrecorded.html:8
msgid "Hello "
msgstr "Hallo "
@ -1897,20 +1907,24 @@ msgid ""
"The shared dataset appears now by default on your overview for this dataset "
"type."
msgstr ""
"Der freigegebene Datensatz ist nun standardmäßig in Ihrer Übersicht für den Datensatztyp im KSP gelistet."
"Der freigegebene Datensatz ist nun standardmäßig in Ihrer Übersicht für den "
"Datensatztyp im KSP gelistet."
#: templates/email/sharing/shared_access_given.html:18
#: templates/email/sharing/shared_access_removed.html:18
#: templates/email/sharing/shared_data_recorded.html:17
#: templates/email/sharing/shared_data_unrecorded.html:17
msgid "Best regards"
msgstr "Beste Grüße"
#: templates/email/sharing/shared_access_given.html:16
#: templates/email/sharing/shared_access_given.html:25
msgid ""
"Please note: Shared access on an intervention means you automatically have "
"editing access to related compensations."
msgstr ""
"Bitte beachten Sie: Freigegebener Zugriff auf einen Eingriff bedeutet, dass Sie automatisch auch "
"Zugriff auf die zugehörigen Kompensationen erhalten haben."
#: templates/email/sharing/shared_access_given.html:19
#: templates/email/sharing/shared_access_removed.html:18
msgid "Best regards"
msgstr "Beste Grüße"
"Bitte beachten Sie: Freigegebener Zugriff auf einen Eingriff bedeutet, dass "
"Sie automatisch auch Zugriff auf die zugehörigen Kompensationen erhalten "
"haben."
#: templates/email/sharing/shared_access_removed.html:4
msgid "Shared access removed"
@ -1935,6 +1949,48 @@ msgstr ""
"Nutzen Sie hierzu einfach die entsprechenden Suchfilter auf den "
"Übersichtsseiten"
#: templates/email/sharing/shared_data_recorded.html:4
msgid "Shared data recorded"
msgstr "Freigegebene Daten verzeichnet"
#: templates/email/sharing/shared_data_recorded.html:10
msgid "the following dataset has just been recorded"
msgstr "der folgende Datensatz wurde soeben verzeichnet "
#: templates/email/sharing/shared_data_recorded.html:14
msgid "This means the data is now publicly available, e.g. in LANIS"
msgstr ""
"Das bedeutet, dass die Daten nun öffentlich verfügbar sind, z.B. im LANIS."
#: templates/email/sharing/shared_data_recorded.html:24
msgid ""
"Please note: Recorded intervention means the compensations are recorded as "
"well."
msgstr ""
"Bitte beachten Sie: Verzeichnete Eingriffe bedeuten, dass auch die "
"zugehörigen Kompensationen automatisch verzeichnet sind."
#: templates/email/sharing/shared_data_unrecorded.html:4
msgid "Shared data unrecorded"
msgstr "Freigegebene Daten entzeichnet"
#: templates/email/sharing/shared_data_unrecorded.html:10
msgid "the following dataset has just been unrecorded"
msgstr "der folgende Datensatz wurde soeben entzeichnet "
#: templates/email/sharing/shared_data_unrecorded.html:14
msgid "This means the data is no longer publicly available."
msgstr ""
"Das bedeutet, dass die Daten nicht länger öffentlich verfügbar sind."
#: templates/email/sharing/shared_data_unrecorded.html:24
msgid ""
"Please note: Unrecorded intervention means the compensations are unrecorded "
"as well."
msgstr ""
"Bitte beachten Sie: Entzeichnete Eingriffe bedeuten, dass auch die "
"zugehörigen Kompensationen automatisch entzeichnet worden sind."
#: templates/email/signature.html:6
msgid "Please do not reply on this mail."
msgstr "Bitte antworten Sie nicht auf diese Mail."

@ -0,0 +1,31 @@
{% load i18n %}
<div>
<h2>{% trans 'Shared data recorded' %}</h2>
<h4>{{obj_identifier}}</h4>
<hr>
<article>
{% trans 'Hello ' %} {{user.username}},
<br>
{% trans 'the following dataset has just been recorded' %}
<br>
<strong>'{{obj_identifier}}'</strong>
<br>
{% trans 'This means the data is now publicly available, e.g. in LANIS' %}
<br>
<br>
{% trans 'Best regards' %}
<br>
KSP
<br>
<br>
<br>
<small>
{% trans 'Please note: Recorded intervention means the compensations are recorded as well.' %}
</small>
<br>
<br>
{% include 'email/signature.html' %}
</article>
</div>

@ -0,0 +1,31 @@
{% load i18n %}
<div>
<h2>{% trans 'Shared data unrecorded' %}</h2>
<h4>{{obj_identifier}}</h4>
<hr>
<article>
{% trans 'Hello ' %} {{user.username}},
<br>
{% trans 'the following dataset has just been unrecorded' %}
<br>
<strong>'{{obj_identifier}}'</strong>
<br>
{% trans 'This means the data is no longer publicly available.' %}
<br>
<br>
{% trans 'Best regards' %}
<br>
KSP
<br>
<br>
<br>
<small>
{% trans 'Please note: Unrecorded intervention means the compensations are unrecorded as well.' %}
</small>
<br>
<br>
{% include 'email/signature.html' %}
</article>
</div>

@ -25,7 +25,7 @@ class User(AbstractUser):
""" Sends a mail to the user in case of removed shared access
Args:
obj ():
obj_identifier ():
Returns:
@ -36,10 +36,10 @@ class User(AbstractUser):
mailer.send_mail_shared_access_removed(obj_identifier, self)
def send_mail_shared_access_given(self, obj_identifier):
""" Sends a mail to the user in case of removed shared access
""" Sends a mail to the user in case of given shared access
Args:
obj ():
obj_identifier ():
Returns:
@ -48,3 +48,31 @@ class User(AbstractUser):
if notification_set:
mailer = Mailer()
mailer.send_mail_shared_access_given(obj_identifier, self)
def send_mail_shared_data_recorded(self, obj_identifier):
""" Sends a mail to the user in case of shared data has been recorded
Args:
obj_identifier ():
Returns:
"""
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, self)
def send_mail_shared_data_unrecorded(self, obj_identifier):
""" Sends a mail to the user in case of shared data has been unrecorded
Args:
obj_identifier ():
Returns:
"""
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, self)

Loading…
Cancel
Save