# 63 Mail recording/unrecording
* adds mail sending in case of unrecording and recording of data * adds/updates translations
This commit is contained in:
parent
17dc3f7537
commit
157f05ead6
@ -11,7 +11,8 @@ from abc import abstractmethod
|
|||||||
|
|
||||||
from django.contrib import messages
|
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 user.models import User
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.http import HttpRequest
|
from django.http import HttpRequest
|
||||||
@ -218,6 +219,11 @@ class RecordableObjectMixin(models.Model):
|
|||||||
self.recorded = None
|
self.recorded = None
|
||||||
self.save()
|
self.save()
|
||||||
self.log.add(action)
|
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
|
return action
|
||||||
|
|
||||||
def set_recorded(self, user: User):
|
def set_recorded(self, user: User):
|
||||||
@ -235,6 +241,11 @@ class RecordableObjectMixin(models.Model):
|
|||||||
self.recorded = action
|
self.recorded = action
|
||||||
self.save()
|
self.save()
|
||||||
self.log.add(action)
|
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
|
return action
|
||||||
|
|
||||||
def mark_as_edited(self, performing_user: User, request: HttpRequest = None, edit_comment: str = None):
|
def mark_as_edited(self, performing_user: User, request: HttpRequest = None, edit_comment: str = None):
|
||||||
|
@ -30,3 +30,17 @@ def celery_send_mail_shared_access_given(obj_identifier, user_id):
|
|||||||
from user.models import User
|
from user.models import User
|
||||||
user = User.objects.get(id=user_id)
|
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
|
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 ""
|
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-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"
|
"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"
|
||||||
@ -1761,6 +1761,14 @@ msgstr "{} - Zugriff entzogen"
|
|||||||
msgid "{} - Shared access given"
|
msgid "{} - Shared access given"
|
||||||
msgstr "{} - Zugriff freigegeben"
|
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
|
#: konova/utils/message_templates.py:11
|
||||||
msgid "There was an error on this form."
|
msgid "There was an error on this form."
|
||||||
msgstr "Es gab einen Fehler im Formular."
|
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_given.html:8
|
||||||
#: templates/email/sharing/shared_access_removed.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 "
|
msgid "Hello "
|
||||||
msgstr "Hallo "
|
msgstr "Hallo "
|
||||||
|
|
||||||
@ -1897,20 +1907,24 @@ msgid ""
|
|||||||
"The shared dataset appears now by default on your overview for this dataset "
|
"The shared dataset appears now by default on your overview for this dataset "
|
||||||
"type."
|
"type."
|
||||||
msgstr ""
|
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:16
|
#: 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:25
|
||||||
msgid ""
|
msgid ""
|
||||||
"Please note: Shared access on an intervention means you automatically have "
|
"Please note: Shared access on an intervention means you automatically have "
|
||||||
"editing access to related compensations."
|
"editing access to related compensations."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Bitte beachten Sie: Freigegebener Zugriff auf einen Eingriff bedeutet, dass Sie automatisch auch "
|
"Bitte beachten Sie: Freigegebener Zugriff auf einen Eingriff bedeutet, dass "
|
||||||
"Zugriff auf die zugehörigen Kompensationen erhalten haben."
|
"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"
|
|
||||||
|
|
||||||
#: templates/email/sharing/shared_access_removed.html:4
|
#: templates/email/sharing/shared_access_removed.html:4
|
||||||
msgid "Shared access removed"
|
msgid "Shared access removed"
|
||||||
@ -1935,6 +1949,48 @@ msgstr ""
|
|||||||
"Nutzen Sie hierzu einfach die entsprechenden Suchfilter auf den "
|
"Nutzen Sie hierzu einfach die entsprechenden Suchfilter auf den "
|
||||||
"Übersichtsseiten"
|
"Ü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
|
#: templates/email/signature.html:6
|
||||||
msgid "Please do not reply on this mail."
|
msgid "Please do not reply on this mail."
|
||||||
msgstr "Bitte antworten Sie nicht auf diese Mail."
|
msgstr "Bitte antworten Sie nicht auf diese Mail."
|
||||||
|
31
templates/email/sharing/shared_data_recorded.html
Normal file
31
templates/email/sharing/shared_data_recorded.html
Normal file
@ -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>
|
||||||
|
|
31
templates/email/sharing/shared_data_unrecorded.html
Normal file
31
templates/email/sharing/shared_data_unrecorded.html
Normal file
@ -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
|
""" Sends a mail to the user in case of removed shared access
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
obj ():
|
obj_identifier ():
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
@ -36,10 +36,10 @@ class User(AbstractUser):
|
|||||||
mailer.send_mail_shared_access_removed(obj_identifier, self)
|
mailer.send_mail_shared_access_removed(obj_identifier, self)
|
||||||
|
|
||||||
def send_mail_shared_access_given(self, obj_identifier):
|
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:
|
Args:
|
||||||
obj ():
|
obj_identifier ():
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
@ -48,3 +48,31 @@ class User(AbstractUser):
|
|||||||
if notification_set:
|
if notification_set:
|
||||||
mailer = Mailer()
|
mailer = Mailer()
|
||||||
mailer.send_mail_shared_access_given(obj_identifier, self)
|
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…
Reference in New Issue
Block a user