aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorAndrea Lepori <alepori@student.ethz.ch>2021-07-23 17:34:07 +0200
committerAndrea Lepori <alepori@student.ethz.ch>2021-07-23 17:34:35 +0200
commit1cc9fbd3bf0652439dc6722a810543c065ce223b (patch)
tree092a7abd89ab8182273802e6521a485d93dfd3cd /server
parentusers of group capi can optionally view documents (diff)
downloadscout-subs-1cc9fbd3bf0652439dc6722a810543c065ce223b.tar.gz
scout-subs-1cc9fbd3bf0652439dc6722a810543c065ce223b.zip
add notification if user of group capi views document
Diffstat (limited to '')
-rw-r--r--server/views.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/server/views.py b/server/views.py
index b65b2ea..8dfa6a6 100644
--- a/server/views.py
+++ b/server/views.py
@@ -1,4 +1,6 @@
from django.shortcuts import render
+from django.conf import settings
+from django.core.mail import send_mail
from client.models import GroupSettings, UserCode, Keys, DocumentType, Document, KeyVal
from django.contrib.auth.models import Group, Permission, User
from django.db.models import Q
@@ -1008,6 +1010,22 @@ def doclist_readonly(request):
0]
group = Group.objects.get(name=parent_group)
+ # send alert
+ users = User.objects.filter(groups__name=parent_group).filter(is_staff=True)
+ user_emails = []
+
+ for i in users:
+ user_emails.append(i.email)
+
+ send_mail(
+ 'Attenzione! ' + request.user.username + ' ha visionato i documenti della branca',
+ "Questo messaggio è stato inviato automaticamente dal sistema di iscrizioni digitali. Ti è arrivata questa mail perchè hai abilitato la possibilità ai tuoi aggiunti di visionare i documenti e un tuo aggiunto ha visionato dei documenti. L'utente con username " + request.user.username + " e con nome registrato " + request.user.first_name + " " + request.user.last_name + " ha visionato dei documenti.",
+ settings.DEFAULT_FROM_EMAIL,
+ user_emails,
+ fail_silently=False,
+ )
+
+
# create typezone
zurich = pytz.timezone('Europe/Zurich')