diff options
author | Andrea Lepori <alepori@student.ethz.ch> | 2021-07-23 17:34:07 +0200 |
---|---|---|
committer | Andrea Lepori <alepori@student.ethz.ch> | 2021-07-23 17:34:35 +0200 |
commit | 1cc9fbd3bf0652439dc6722a810543c065ce223b (patch) | |
tree | 092a7abd89ab8182273802e6521a485d93dfd3cd | |
parent | users of group capi can optionally view documents (diff) | |
download | scout-subs-1cc9fbd3bf0652439dc6722a810543c065ce223b.tar.gz scout-subs-1cc9fbd3bf0652439dc6722a810543c065ce223b.zip |
add notification if user of group capi views document
Diffstat (limited to '')
-rw-r--r-- | client/templates/client/index.html | 12 | ||||
-rw-r--r-- | server/views.py | 18 | ||||
-rw-r--r-- | templates/registration/base_client.html | 8 | ||||
-rw-r--r-- | version.txt | 2 |
4 files changed, 35 insertions, 5 deletions
diff --git a/client/templates/client/index.html b/client/templates/client/index.html index 932af1c..7d001ec 100644 --- a/client/templates/client/index.html +++ b/client/templates/client/index.html @@ -17,6 +17,18 @@ {% if user.is_authenticated %} {% if user.is_staff or perms.client.approved %} + <div id="modal_capi" class="modal"> + <div class="modal-content"> + <h4>Attenzione</h4> + <p>Il tuo capo branca verrà notificato dell'accesso alla pagina dei documenti.<br> + Sei sicuro di voler continuare? + </p> + </div> + <div class="modal-footer"> + <a style="color:red" href="#!" class="modal-close waves-effect waves-green btn-flat">Annulla</a> + <a href="{% url 'doclistro' %}" class="modal-close waves-effect waves-green btn-flat">Continua</a> + </div> + </div> {% if not empty %} <ul class="collapsible"> {% for doc in docs %} 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') diff --git a/templates/registration/base_client.html b/templates/registration/base_client.html index 945ac99..edf4d2b 100644 --- a/templates/registration/base_client.html +++ b/templates/registration/base_client.html @@ -86,8 +86,8 @@ {% endblock %} <ul class="right"> {% if user.is_authenticated %} - {% if group_view %} - <li class="hide-on-small-only"><a href="{% url 'doclistro' %}">Lista documenti</a></li> + {% if group_view and not user.is_staff %} + <li class="hide-on-small-only"><a class="modal-trigger" href="#modal_capi">Lista documenti</a></li> {% endif %} {% if user.is_staff or perms.client.staff %} <li class="hide-on-small-only"><a href="{% url 'server' %}">Pannello Admin</a></li> @@ -97,8 +97,8 @@ {% if user.is_staff or perms.client.staff %} <li class="tooltipped hide-on-med-and-up" data-position="bottom" data-tooltip="Pannello Admin" class="hide-on-med-and-up"><a href="{% url 'server' %}"><i class="material-icons">build</i></a></li> {% endif %} - {% if group_view %} - <li class="tooltipped hide-on-med-and-up" data-position="bottom" data-tooltip="Lista documenti" class="hide-on-med-and-up"><a href="{% url 'doclistro' %}"><i class="material-icons">list</i></a></li> + {% if group_view and not user.is_staff %} + <li class="tooltipped hide-on-med-and-up" data-position="bottom" data-tooltip="Lista documenti" class="hide-on-med-and-up"><a class="modal-trigger" href="#modal_capi"><i class="material-icons">list</i></a></li> {% endif %} <li class="tooltipped" data-position="bottom" data-tooltip="Informazioni"><a href="{% url 'about' %}"><i class="material-icons">info_outline</i></a></li> <li class="tooltipped" data-position="bottom" data-tooltip="Logout"><a href="{% url 'logout' %}"><i class="material-icons">exit_to_app</i></a></li> diff --git a/version.txt b/version.txt index b64ad0e..7655692 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ version=0.2 -rev=2 +rev=3 |