# 63 Mail data deleted
* adds mail sending if shared data is deleted * adds/updates translations * refactors recording mails into separate email template folder email/recording
This commit is contained in:
parent
d7a9f72c3e
commit
5295c08d99
@ -12,7 +12,7 @@ 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_recorded, celery_send_mail_shared_data_unrecorded, celery_send_mail_shared_data_deleted
|
||||
from user.models import User
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.http import HttpRequest
|
||||
@ -121,6 +121,12 @@ class BaseObject(BaseResource):
|
||||
action = UserActionLogEntry.get_deleted_action(user)
|
||||
self.deleted = action
|
||||
self.log.add(action)
|
||||
|
||||
# Send mail
|
||||
shared_users = self.users.all().values_list("id", flat=True)
|
||||
for user_id in shared_users:
|
||||
celery_send_mail_shared_data_deleted.delay(self.identifier, user_id)
|
||||
|
||||
self.save()
|
||||
|
||||
def add_log_entry(self, action: UserAction, user: User, comment: str):
|
||||
|
@ -44,3 +44,10 @@ 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)
|
||||
|
||||
|
||||
@shared_task
|
||||
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)
|
||||
|
@ -94,7 +94,7 @@ class Mailer:
|
||||
)
|
||||
|
||||
def send_mail_shared_data_recorded(self, obj_identifier, user):
|
||||
""" Send a mail if user just got access to the object
|
||||
""" Send a mail if the user's shared data has just been unrecorded
|
||||
|
||||
Args:
|
||||
obj_identifier (str): The object identifier
|
||||
@ -107,7 +107,7 @@ class Mailer:
|
||||
"obj_identifier": obj_identifier,
|
||||
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
|
||||
}
|
||||
msg = render_to_string("email/sharing/shared_data_recorded.html", context)
|
||||
msg = render_to_string("email/recording/shared_data_recorded.html", context)
|
||||
user_mail_address = [user.email]
|
||||
self.send(
|
||||
user_mail_address,
|
||||
@ -116,6 +116,28 @@ class Mailer:
|
||||
)
|
||||
|
||||
def send_mail_shared_data_unrecorded(self, obj_identifier, user):
|
||||
""" Send a mail if the user's shared data has just been unrecorded
|
||||
|
||||
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/recording/shared_data_unrecorded.html", context)
|
||||
user_mail_address = [user.email]
|
||||
self.send(
|
||||
user_mail_address,
|
||||
_("{} - Shared data unrecorded").format(obj_identifier),
|
||||
msg
|
||||
)
|
||||
|
||||
def send_mail_shared_data_deleted(self, obj_identifier, user):
|
||||
""" Send a mail if user just got access to the object
|
||||
|
||||
Args:
|
||||
@ -129,11 +151,11 @@ class Mailer:
|
||||
"obj_identifier": obj_identifier,
|
||||
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
|
||||
}
|
||||
msg = render_to_string("email/sharing/shared_data_unrecorded.html", context)
|
||||
msg = render_to_string("email/deleting/shared_data_deleted.html", context)
|
||||
user_mail_address = [user.email]
|
||||
self.send(
|
||||
user_mail_address,
|
||||
_("{} - Shared data unrecorded").format(obj_identifier),
|
||||
_("{} - Shared data deleted").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:06+0100\n"
|
||||
"POT-Creation-Date: 2022-01-12 15:22+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"
|
||||
@ -1762,10 +1762,10 @@ msgid "{} - Shared access given"
|
||||
msgstr "{} - Zugriff freigegeben"
|
||||
|
||||
#: konova/utils/mailer.py:114
|
||||
msgid "{} - Shared data recorded"
|
||||
msgstr "{} - Freigegebene Daten verzeichnet"
|
||||
msgid "{} - Shared data deleted"
|
||||
msgstr "{} - Freigegebene Daten gelöscht"
|
||||
|
||||
#: konova/utils/mailer.py:136
|
||||
#: konova/utils/mailer.py:136 konova/utils/mailer.py:158
|
||||
msgid "{} - Shared data unrecorded"
|
||||
msgstr "{} - Freigegebene Daten entzeichnet"
|
||||
|
||||
@ -1883,17 +1883,83 @@ 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/deleting/shared_data_deleted.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
|
||||
#: templates/email/sharing/shared_access_removed.html:8
|
||||
msgid "Hello "
|
||||
msgstr "Hallo "
|
||||
|
||||
#: templates/email/deleting/shared_data_deleted.html:10
|
||||
msgid "the following dataset has just been deleted"
|
||||
msgstr "der folgende Datensatz wurde soeben gelöscht "
|
||||
|
||||
#: templates/email/deleting/shared_data_deleted.html:14
|
||||
msgid ""
|
||||
"If this should not have been happened, please contact us. See the signature "
|
||||
"for details."
|
||||
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"
|
||||
|
||||
#: templates/email/recording/shared_data_recorded.html:10
|
||||
msgid "the following dataset has just been recorded"
|
||||
msgstr "der folgende Datensatz wurde soeben verzeichnet "
|
||||
|
||||
#: templates/email/recording/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/recording/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/recording/shared_data_unrecorded.html:4
|
||||
msgid "Shared data unrecorded"
|
||||
msgstr "Freigegebene Daten entzeichnet"
|
||||
|
||||
#: templates/email/recording/shared_data_unrecorded.html:10
|
||||
msgid "the following dataset has just been unrecorded"
|
||||
msgstr "der folgende Datensatz wurde soeben entzeichnet "
|
||||
|
||||
#: templates/email/recording/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/recording/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/sharing/shared_access_given.html:4
|
||||
msgid "Access shared"
|
||||
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 "
|
||||
|
||||
#: templates/email/sharing/shared_access_given.html:10
|
||||
msgid "the following dataset has just been shared with you"
|
||||
msgstr "der folgende Datensatz wurde soeben für Sie freigegeben "
|
||||
@ -1910,13 +1976,6 @@ msgstr ""
|
||||
"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:25
|
||||
msgid ""
|
||||
"Please note: Shared access on an intervention means you automatically have "
|
||||
@ -1949,48 +2008,6 @@ 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."
|
||||
@ -3730,6 +3747,9 @@ msgstr ""
|
||||
msgid "Unable to connect to qpid with SASL mechanism %s"
|
||||
msgstr ""
|
||||
|
||||
#~ msgid "{} - Shared data recorded"
|
||||
#~ msgstr "{} - Freigegebene Daten verzeichnet"
|
||||
|
||||
#~ msgid "Not recorded"
|
||||
#~ msgstr "Noch nicht verzeichnet"
|
||||
|
||||
|
26
templates/email/deleting/shared_data_deleted.html
Normal file
26
templates/email/deleting/shared_data_deleted.html
Normal file
@ -0,0 +1,26 @@
|
||||
{% load i18n %}
|
||||
|
||||
<div>
|
||||
<h2>{% trans 'Shared data deleted' %}</h2>
|
||||
<h4>{{obj_identifier}}</h4>
|
||||
<hr>
|
||||
<article>
|
||||
{% trans 'Hello ' %} {{user.username}},
|
||||
<br>
|
||||
{% trans 'the following dataset has just been deleted' %}
|
||||
<br>
|
||||
<strong>'{{obj_identifier}}'</strong>
|
||||
<br>
|
||||
{% trans 'If this should not have been happened, please contact us. See the signature for details.' %}
|
||||
<br>
|
||||
<br>
|
||||
{% trans 'Best regards' %}
|
||||
<br>
|
||||
KSP
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
{% include 'email/signature.html' %}
|
||||
</article>
|
||||
</div>
|
||||
|
@ -76,3 +76,17 @@ class User(AbstractUser):
|
||||
if notification_set:
|
||||
mailer = Mailer()
|
||||
mailer.send_mail_shared_data_unrecorded(obj_identifier, self)
|
||||
|
||||
def send_mail_shared_data_deleted(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_DELETED)
|
||||
if notification_set:
|
||||
mailer = Mailer()
|
||||
mailer.send_mail_shared_data_deleted(obj_identifier, self)
|
||||
|
@ -49,9 +49,6 @@ class UserActionLogEntry(models.Model):
|
||||
"-timestamp",
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return "{} | {} | {}".format(self.user.username, self.timestamp, self.action)
|
||||
|
||||
@property
|
||||
def action_humanize(self):
|
||||
""" Returns humanized version of enum
|
||||
|
Loading…
Reference in New Issue
Block a user