aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Lepori <alepori@student.ethz.ch>2020-06-23 19:05:09 +0200
committerAndrea Lepori <alepori@student.ethz.ch>2020-06-23 19:05:09 +0200
commit684c019daf76b499417c85e4ea5877a96b0ddb0e (patch)
treea87fbd3ed23d41dfc1a0a1996803a1e6a6e5541a
parentDownload docs, better preview (diff)
downloadscout-subs-684c019daf76b499417c85e4ea5877a96b0ddb0e.tar.gz
scout-subs-684c019daf76b499417c85e4ea5877a96b0ddb0e.zip
Nicer user list, multi group support
-rw-r--r--accounts/views.py9
-rw-r--r--client/migrations/0025_documenttype_custom_group.py18
-rw-r--r--client/models.py1
-rw-r--r--client/templates/client/approve_doc_pdf.html113
-rw-r--r--client/views.py4
-rw-r--r--server/templates/server/doc_create.html22
-rw-r--r--server/templates/server/doc_list.html87
-rw-r--r--server/templates/server/doc_type.html30
-rw-r--r--server/templates/server/download_doc.html2
-rw-r--r--server/templates/server/index.html10
-rw-r--r--server/templates/server/user_list.html263
-rw-r--r--server/views.py136
12 files changed, 490 insertions, 205 deletions
diff --git a/accounts/views.py b/accounts/views.py
index 9c2efeb..7b40c05 100644
--- a/accounts/views.py
+++ b/accounts/views.py
@@ -81,10 +81,11 @@ def personal(request):
medic.misc = request.POST["misc"]
medic.save()
- if request.POST["branca"] != "":
- request.user.groups.clear()
- request.user.groups.add(
- Group.objects.get(name=request.POST["branca"]))
+ if "branca" in request.POST:
+ if request.POST["branca"] != "":
+ request.user.groups.clear()
+ request.user.groups.add(
+ Group.objects.get(name=request.POST["branca"]))
if "vac_certificate" in request.FILES:
myfile = request.FILES['vac_certificate']
diff --git a/client/migrations/0025_documenttype_custom_group.py b/client/migrations/0025_documenttype_custom_group.py
new file mode 100644
index 0000000..56c77f9
--- /dev/null
+++ b/client/migrations/0025_documenttype_custom_group.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.0.7 on 2020-06-23 14:16
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('client', '0024_auto_20200622_1930'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='documenttype',
+ name='custom_group',
+ field=models.BooleanField(default=False),
+ ),
+ ]
diff --git a/client/models.py b/client/models.py
index 105165b..4d8ae83 100644
--- a/client/models.py
+++ b/client/models.py
@@ -10,6 +10,7 @@ class DocumentType(models.Model):
auto_sign = models.BooleanField(default=False)
group_private = models.BooleanField(default=False)
group = models.ForeignKey(Group, default=None, on_delete=models.CASCADE)
+ custom_group = models.BooleanField(default=False)
personal_data = models.BooleanField(default=False)
medical_data = models.BooleanField(default=False)
custom_data = models.BooleanField(default=False)
diff --git a/client/templates/client/approve_doc_pdf.html b/client/templates/client/approve_doc_pdf.html
index 4b7df8b..deabd99 100644
--- a/client/templates/client/approve_doc_pdf.html
+++ b/client/templates/client/approve_doc_pdf.html
@@ -2,98 +2,47 @@
<html>
<head>
<meta charset="utf-8">
+ <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<title></title>
-<style>
-.center {
- text-align: center;
-}
-.left {
- text-align: left;
-}
-.right {
- text-align: right;
-}
-
-h1, h2, h3, h4, h5, h6 {
- font-weight: 400;
- line-height: 1.3;
-}
-
-h1 {
- font-size: 4.2rem;
- line-height: 110%;
- margin: 2.8rem 0 1.68rem 0;
-}
-
-h2 {
- font-size: 3.56rem;
- line-height: 110%;
- margin: 2.3733333333rem 0 1.424rem 0;
-}
-
-h3 {
- font-size: 2.92rem;
- line-height: 110%;
- margin: 1.9466666667rem 0 1.168rem 0;
-}
-
-h4 {
- font-size: 2.28rem;
- line-height: 110%;
- margin: 1.52rem 0 0.912rem 0;
-}
-
-h5 {
- font-size: 1.64rem;
- line-height: 110%;
- margin: 1.0933333333rem 0 0.656rem 0;
-}
-
-h6 {
- font-size: 1.15rem;
- line-height: 110%;
- margin: 0.7666666667rem 0 0.46rem 0;
-}
-
-.footer {
-}
-
-.content {
- margin-left: 25%;
- width: 50%;
-}
-
-table {
- border-collapse:collapse;
- margin:0px;
- padding:0;
- width:100%;
-}
-
-</style>
</head>
<body>
<main style="margin-left: 10px;margin-right: 10px;margin-top: 10px;">
- <div class="title"><h1 class="center">{{doc.code}}</h1></div>
- <div class="code"><h3 class="center">{{doc.document_type.name}}</h3></div>
- <div class="content">
- <p>Con la presente firma approvo il documento con codice {{doc.code}} accettando
- tutte le clausole apposte su di esso.
- Inoltre comprovo come veritieri e completi tutti i dati apposti sul documento.
- </p>
+ <br><br><br><br>
+ <br><br><br><br>
+ <div class="row">
+ <h2 class="center">{{doc.code}}</h2>
+ </div>
+ <div class="row">
+ <h4 class="center">{{doc.document_type.name}}</h4>
+ </div>
+ <div class="row">
+ <div class="col s6 offset-s3">
+ <p>Con la presente firma approvo il documento con codice {{doc.code}} accettando
+ tutte le clausole apposte su di esso.
+ Inoltre comprovo come veritieri e completi tutti i dati apposti sul documento.
+ </p>
+ </div>
</div>
<br><br><br><br>
<br><br><br><br>
<br><br><br><br>
<br><br><br><br>
- <div class"footer">
- <table>
- <tr>
- <td><h4 class="left">Data</h4></div></td>
- <td><h4 class="right">Firma</h4></td>
- </tr>
- </table>
+ <div class="row">
+ <div class="col s4 offset-s1">
+ <div class="input-field">
+ <input type="text">
+ <span class="helper-text">Data e luogo</span>
+ </div>
+ </div>
+ <div class="col s4 offset-s2">
+ <div class="input-field">
+ <input type="text">
+ <span class="helper-text">Firma</span>
+ </div>
+ </div>
</div>
</main>
</body>
+<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
</html> \ No newline at end of file
diff --git a/client/views.py b/client/views.py
index b43a3c9..17d9e0a 100644
--- a/client/views.py
+++ b/client/views.py
@@ -92,7 +92,7 @@ def approve(request):
if not (request.user.is_staff or request.user.has_perm('approved')):
usercode = UserCode.objects.filter(user=request.user)[0]
okay = False
- if request.user.first_name != "" and request.user.last_name != "" and request.user.email != "" and len(request.user.groups.values_list('name', flat=True)) != 0:
+ if request.user.first_name != "" and request.user.last_name != "" and request.user.email != "" and usercode.phone != "":
okay = True
context = {'code': 'U' + str(usercode.code), 'okay': okay}
return render(request, 'client/approve.html', context)
@@ -162,7 +162,7 @@ def create(request):
break
document = Document(
- user=request.user, group=group, code=code, status=status, document_type=document_type, personal_data=personal_data, medical_data=medical_data)
+ user=request.user, group=document_type.group, code=code, status=status, document_type=document_type, personal_data=personal_data, medical_data=medical_data)
document.save()
if document_type.custom_data:
diff --git a/server/templates/server/doc_create.html b/server/templates/server/doc_create.html
index 6454bee..1c469ae 100644
--- a/server/templates/server/doc_create.html
+++ b/server/templates/server/doc_create.html
@@ -80,14 +80,20 @@
<br>
<div class="row">
<div class="input-field col s12">
- <textarea name="custom" id="textarea" class="materialize-textarea"></textarea>
- <label for="textarea">Lista parametri personalizzati, uno per riga</label>
+ <textarea name="custom" id="param" class="materialize-textarea"></textarea>
+ <label for="param">Lista parametri personalizzati, uno per riga</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
- <textarea name="custom_message_text" id="textarea" class="materialize-textarea"></textarea>
- <label for="textarea">Messaggio personalizzato</label>
+ <textarea name="custom_message_text" id="message" class="materialize-textarea"></textarea>
+ <label for="message">Messaggio personalizzato</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="input-field col s12">
+ <textarea name="custom_group" id="group" class="materialize-textarea"></textarea>
+ <label for="group">Gruppo personalizzato</label>
</div>
</div>
<div class="fixed-action-btn">
@@ -100,4 +106,12 @@
</div>
</div>
</div>
+{% endblock %}
+
+{% block script%}
+$(document).ready(function(){
+ {% if error %}
+ M.toast({html: '{{ error_text}}', classes: 'orange'})
+ {% endif %}
+});
{% endblock %} \ No newline at end of file
diff --git a/server/templates/server/doc_list.html b/server/templates/server/doc_list.html
index 961b9ab..5206d2f 100644
--- a/server/templates/server/doc_list.html
+++ b/server/templates/server/doc_list.html
@@ -36,8 +36,10 @@
</li>
<li><a class="tooltipped" data-position="top" data-tooltip="Archivia selezionati" onclick="send('archive')"><i class="material-icons">archive</i></a></li>
<li><a class="tooltipped" data-position="top" data-tooltip="Dearchivia selezionati" Onclick="send('unarchive')"><i class="material-icons">unarchive</i></a></li>
- <li><a class="tooltipped" data-position="top" data-tooltip="Approva selezionati" Onclick="send('approve')"><i class="material-icons left">check</i>DEBUG</a></li>
- <li><a class="tooltipped" data-position="top" data-tooltip="Elimina selezionati" Onclick="send('delete')"><i class="material-icons left">delete</i>DEBUG</a></li>
+ {% if settings.DEBUG %}
+ <li><a class="tooltipped" data-position="top" data-tooltip="Approva selezionati" Onclick="send('approve')"><i class="material-icons left">check</i>DEBUG</a></li>
+ <li><a class="tooltipped" data-position="top" data-tooltip="Elimina selezionati" Onclick="send('delete')"><i class="material-icons left">delete</i>DEBUG</a></li>
+ {% endif %}
</ul>
<ul class="right">
<li><a class="tooltipped" data-position="top" data-tooltip="Pulisci filtri" Onclick="send('clear')"><i class="material-icons">clear</i></a></li>
@@ -79,25 +81,34 @@
</label>
</div>
</div>
+ <br>
<div class="row">
- <div class="input-field col s6">
- <label for="newer">Pi&ugrave; recenti di</label>
- <input value="{{newer}}" name="newer" id="newer" type="text" class="datepicker">
- </div>
- <div class="input-field col s6">
- <label for="older">Pi&ugrave; vecchi di</label>
- <input value="{{older}}" name="older" id="older" type="text" class="datepicker">
- </div>
- </div>
- <div class = "row">
- <div class="col s12">
- <div id="chips_type" class="chips chips-placeholder chips-autocomplete"></div>
- </div>
- </div>
- <div class ="row col s12">
- <div class="col s12">
- <div id="chips_owner" class="chips chips-placeholder chips-autocomplete "></div>
- </div>
+ <ul class="collapsible"><li>
+ <div class="collapsible-header">Avanzati</div>
+ <div class="collapsible-body"><span>
+ <div class = "row">
+ <div class="input-field col s6">
+ <label for="newer">Pi&ugrave; recenti di</label>
+ <input value="{{newer}}" name="newer" id="newer" type="text" class="datepicker">
+ </div>
+ <div class="input-field col s6">
+ <label for="older">Pi&ugrave; vecchi di</label>
+ <input value="{{older}}" name="older" id="older" type="text" class="datepicker">
+ </div>
+ </div>
+ <div class = "row">
+ <div class="col s12">
+ <div id="chips_type" class="chips chips-placeholder chips-autocomplete"></div>
+ </div>
+ <div class="col s12">
+ <div id="chips_owner" class="chips chips-placeholder chips-autocomplete "></div>
+ </div>
+ <div class="col s12">
+ <div id="chips_groups" class="chips chips-placeholder chips-autocomplete "></div>
+ </div>
+ </div>
+ </span></div>
+ </li></ul>
</div>
</div>
<div class="modal-footer">
@@ -107,6 +118,7 @@
<input type="hidden" name="action" id="action">
<input type="hidden" name="owner" id="owner">
<input type="hidden" name="type" id="type">
+<input type="hidden" name="groups" id="groups">
<ul class="collapsible">
{% for doc in docs %}
<li>
@@ -129,7 +141,7 @@
</div>
<div class="collapsible-body"><span>
{% if doc.0.status == "ok" or doc.0.status == 'archive' %}
- <a class="waves-effect waves-light btn red lighten-1" onclick="send('f{{doc.0.id}}')"><i class="material-icons left">file_download</i> Scarica documento</a>
+ <a class="waves-effect waves-light btn red lighten-1" onclick="send('k{{doc.0.id}}')"><i class="material-icons left">file_download</i> Scarica documento</a>
<br>
<br>
{% endif %}
@@ -141,6 +153,13 @@
</div>
</li>
{% endif %}
+ {% if doc.0.document_type.custom_group %}
+ <li>
+ <div class="collapsible-header">
+ <i class="material-icons">group_work</i>{{doc.0.group.name}}
+ </div>
+ </li>
+ {% endif %}
<li>
<div class="collapsible-header">
<i class="material-icons">send</i>{{doc.0.compilation_date}}
@@ -415,16 +434,37 @@ $('#chips_owner').chips({
{% endfor %}
]
});
+$('#chips_groups').chips({
+ placeholder: 'Gruppo',
+ secondaryPlaceholder: '+Altro gruppo',
+ autocompleteOptions: {
+ data: {
+ {% for g in groups %}
+ '{{g}}': null,
+ {% endfor %}
+ },
+ limit: Infinity,
+ minLength: 0
+ },
+ data: [
+ {% for g in chips_groups %}
+ {tag: '{{g}}'},
+ {% endfor %}
+ ]
+});
function send(id) {
var form = document.getElementById('selection')
var action = document.getElementById('action')
var owner = document.getElementById('owner')
var type = document.getElementById('type')
+ var groups = document.getElementById('groups')
var chips_owner = M.Chips.getInstance(document.getElementById('chips_owner'));
var chips_type = M.Chips.getInstance(document.getElementById('chips_type'));
+ var chips_groups = M.Chips.getInstance(document.getElementById('chips_groups'));
var type_array = []
var owner_array = []
+ var groups_array = []
for (i=0; i < chips_owner.chipsData.length; i++) {
owner_array.push(chips_owner.chipsData[i].tag)
@@ -434,9 +474,14 @@ function send(id) {
type_array.push(chips_type.chipsData[i].tag)
}
+ for (i=0; i < chips_groups.chipsData.length; i++) {
+ groups_array.push(chips_groups.chipsData[i].tag)
+ }
+
action.setAttribute('value', id);
owner.setAttribute('value', owner_array.join("^|"))
type.setAttribute('value', type_array.join("^|"))
+ groups.setAttribute('value', groups_array.join("^|"))
form.submit()
}
$('#select-all').click(function(event) {
diff --git a/server/templates/server/doc_type.html b/server/templates/server/doc_type.html
index 39b5101..b4b7f87 100644
--- a/server/templates/server/doc_type.html
+++ b/server/templates/server/doc_type.html
@@ -53,45 +53,51 @@
<div class="modal-content">
<h5>Filtri</h5>
<div class="row">
- <div class="input-field col s4">
+ <div class="input-field col l3 s12">
<label>
<input name="filter_hidden" type="checkbox" class="filled-in" {{hidden_check}}/>
<span><i class="material-icons left">visibility_off</i>Disabilitati</span>
</label>
</div>
- <div class="input-field col s4">
+ <div class="input-field col l3 s12">
<label>
<input name="filter_public" type="checkbox" class="filled-in" {{public_check}}/>
<span><i class="material-icons left">public</i>Pubblici</span>
</label>
</div>
- <div class="input-field col s4">
+ <div class="input-field col l3 s12">
<label>
<input name="filter_selfsign" type="checkbox" class="filled-in" {{selfsign_check}}/>
<span><i class="material-icons left">assignment_turned_in</i>No firma</span>
</label>
</div>
+ <div class="input-field col l3 s12">
+ <label>
+ <input name="filter_group" type="checkbox" class="filled-in" {{group_check}}/>
+ <span><i class="material-icons left">group_work</i>Gruppo</span>
+ </label>
+ </div>
</div>
<div class="row">
- <div class="input-field col s3">
+ <div class="input-field col l3 s12">
<label>
<input name="filter_personal" type="checkbox" class="filled-in" {{personal_check}}/>
<span><i class="material-icons left">person</i>Personali</span>
</label>
</div>
- <div class="input-field col s3">
+ <div class="input-field col l3 s12">
<label>
<input name="filter_medic" type="checkbox" class="filled-in" {{medic_check}}/>
<span><i class="material-icons left">healing</i>Medici</span>
</label>
</div>
- <div class="input-field col s3">
+ <div class="input-field col l3 s12">
<label>
<input name="filter_custom" type="checkbox" class="filled-in" {{custom_check}}/>
<span><i class="material-icons left">add_circle_outline</i>Personalizzati</span>
</label>
</div>
- <div class="input-field col s3">
+ <div class="input-field col l3 s12">
<label>
<input name="filter_message" type="checkbox" class="filled-in" {{message_check}}/>
<span><i class="material-icons left">message</i>Messaggi</span>
@@ -119,6 +125,9 @@
{% if not doctype.0.group_private %}
<i class="material-icons">public</i>
{% endif %}
+ {% if doctype.0.custom_group %}
+ <i class="material-icons">group_work</i>
+ {% endif %}
{% if doctype.0.auto_sign %}
<i class="material-icons">assignment_turned_in</i>
{% endif %}
@@ -127,6 +136,13 @@
</div>
<div class="collapsible-body"><span>
<ul class="collapsible">
+ {% if not doctype.0.group_private %}
+ <li>
+ <div class="collapsible-header">
+ <i class="material-icons">group_work</i>{{doctype.0.group.name}}
+ </div>
+ </li>
+ {% endif %}
{% if doctype.0.personal_data %}
<li>
<div class="collapsible-header">
diff --git a/server/templates/server/download_doc.html b/server/templates/server/download_doc.html
index 0f36372..15ec72a 100644
--- a/server/templates/server/download_doc.html
+++ b/server/templates/server/download_doc.html
@@ -16,7 +16,7 @@
<i class="material-icons">assignment_turned_in</i>
{% endif %}
{{doc.0.document_type.name}}
- <span class="badge" data-badge-caption="">{{doc.0.compilation_date}}</span>
+ <span class="badge" data-badge-caption="">{{doc.0.user.username}}</span>
</div>
<div class="collapsible-body"><span>
<ul class="collapsible">
diff --git a/server/templates/server/index.html b/server/templates/server/index.html
index 6b2f597..2676c3a 100644
--- a/server/templates/server/index.html
+++ b/server/templates/server/index.html
@@ -32,8 +32,8 @@
</p>
</div>
<div class="card-action">
- <a href="{% url 'ulist' %}">Lista utenti</a>
- <a href="{% url 'uapprove' %}">Approva utente</a>
+ <a class="waves-effect waves-light btn red lighten-1" href="{% url 'ulist' %}">Lista utenti</a>
+ <a class="waves-effect waves-light btn red lighten-1" href="{% url 'uapprove' %}">Approva utente</a>
</div>
</div>
</div>
@@ -60,9 +60,9 @@
</ul>
</div>
<div class="card-action">
- <a href="{% url 'doctype' %}">Lista tipo doc</a>
- <a href="{% url 'doclist' %}">Lista documenti</a>
- <a href="{% url 'docapprove' %}">Approva documento</a>
+ <a class="waves-effect waves-light btn red lighten-1" href="{% url 'doctype' %}">Lista tipo doc</a>
+ <a class="waves-effect waves-light btn red lighten-1" href="{% url 'doclist' %}">Lista documenti</a>
+ <a class="waves-effect waves-light btn red lighten-1" href="{% url 'docapprove' %}">Approva documento</a>
</div>
</div>
</div>
diff --git a/server/templates/server/user_list.html b/server/templates/server/user_list.html
index 3837619..8abf5e8 100644
--- a/server/templates/server/user_list.html
+++ b/server/templates/server/user_list.html
@@ -3,26 +3,251 @@
{% block title %}Admin - Lista Utenti{% endblock %}
{% block nav %}
- <a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb">Home</a>
- <a href="{% url 'server'%}" class="breadcrumb hide-on-med-and-down">Admin</a>
- <a href="#!" class="breadcrumb hide-on-med-and-down">Lista Utenti</a>
+ <a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb">Home</a>
+ <a href="{% url 'server'%}" class="breadcrumb hide-on-med-and-down">Admin</a>
+ <a href="#!" class="breadcrumb hide-on-med-and-down">Lista Utenti</a>
{% endblock %}
{% block content %}
-<table>
- <tr>
- <th>Username</th>
- <th>Nome</th>
- <th>Cognome</th>
- <th>Codice</th>
- <th>Stato</th>
- </tr>
- {% for user in users %}
- <tr>
- {% for att in user %}
- <td>{{att}}</td>
- {% endfor %}
- </tr>
- {% endfor %}
-</table>
+<form id="form" action="{% url 'ulist' %}" method="post">
+{% csrf_token %}
+<input type="hidden" name="action" id="action">
+<ul class="collapsible">
+ {% for user in users %}
+ <li>
+ <div class="collapsible-header">
+ {% if user.0.is_staff %}
+ <i class="material-icons">grade</i>
+ {% endif %}
+ {{user.0.first_name}} {{user.0.last_name}}
+ </div>
+ <div class="collapsible-body"><span>
+ <ul class="collapsible">
+ <li>
+ <div class="collapsible-header">
+ <i class="material-icons">person</i>Dati personali
+ </div>
+ <div class="collapsible-body"><span>
+ <div class="row">
+ <div class="input-field col l4 s12">
+ <input disabled value="{{user.0.first_name}}" id="first_name" type="text" >
+ <label for="first_name">Nome</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{user.0.last_name}}" id="last_name" type="text" >
+ <label for="last_name">Cognome</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{user.1.born_date}}" id="birth_date" type="text">
+ <label for="birth_date">Data di nascita</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{user.2}}" id="branca" type="text">
+ <label for="branca">Branca</label>
+ </div>
+ <div class="input-field col l8 s12">
+ <input disabled value="{{user.1.parent_name}}" id="parent_name" type="text" >
+ <label for="parent_name">Nome dei genitori</label>
+ </div>
+ <div class="input-field col l12 s12">
+ <input value="{{user.1.via}}" disabled id="via" type="text" >
+ <label for="via">Via e numero</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{user.1.cap}}" name="cap" id="cap" type="text" >
+ <label for="cap">CAP</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{user.1.country}}" name="country" id="country" type="text" >
+ <label for="country">Paese</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{user.1.nationality}}" name="nationality" id="nationality" type="text" >
+ <label for="nationality">Nazionalit&agrave;</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{user.1.phone}}" name="phone" id="phone" type="text" >
+ <label for="phone">Cellulare</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{user.1.home_phone}}" name="home_phone" id="home_phone" type="text" >
+ <label for="home_phone">Telefono di casa</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{user.1.email}}" name="email" id="email" type="text" >
+ <label for="email">Email</label>
+ </div>
+ <div class="input-field col l8 s12">
+ <input disabled value="{{user.1.school}}" name="school" id="school" type="text" >
+ <label for="school">Scuola frequentata</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{user.1.year}}" name="year" id="year" type="text" >
+ <label for="year">Classe</label>
+ </div>
+ </div>
+ </span></div>
+ </li>
+ <li>
+ <div class="collapsible-header">
+ <i class="material-icons">healing</i>Dati medici
+ </div>
+ <div class="collapsible-body"><span>
+ <div class="row">
+ <div class="col s12">
+ <h6>Persona di contatto in caso di necessit&agrave;</h6>
+ </div>
+ </div>
+ <div class="row">
+ <div class="input-field col l6 s12">
+ <input disabled name="emer_name" value="{{user.1.medic.emer_name}}" id="emer_name" type="text" >
+ <label for="emer_name">Nome e cognome</label>
+ </div>
+ <div class="input-field col l3 s12">
+ <input disabled name="emer_relative" value="{{user.1.medic.emer_relative}}" id="emer_relative" type="text" >
+ <label for="emer_releative">Parentela</label>
+ </div>
+ <div class="input-field col l3 s12">
+ <input disabled name="cell_phone" value="{{user.1.medic.cell_phone}}" id="cellphone" type="text" >
+ <label for="cell_phone">Cellulare</label>
+ </div>
+ <div class="input-field col l9 s12">
+ <input disabled value="{{user.1.medic.address}}" name="address" id="address" type="text" >
+ <label for="address">Indirizzo completo</label>
+ </div>
+ <div class="input-field col l3 s12">
+ <input disabled value="{{user.1.medic.emer_phone}}" name="emer_phone" id="emer_phone" type="text" >
+ <label for="emer_phone">Telefono di casa</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <h6>Assicurazione</h6>
+ </div>
+ </div>
+ <div class="row">
+ <div class="input-field col l4 s12">
+ <input disabled value="{{user.1.medic.health_care}}" name="health_care" id="health_care" type="text" >
+ <label for="health_care">Cassa Malati</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{user.1.medic.injuries}}" name="injuries" id="injuries" type="text" >
+ <label for="injuries">Infortuni</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{user.1.medic.rc}}" name="rc" id="rc" type="text" >
+ <label for="rc">Responsabilit&agrave; civile</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="switch col s12">
+ &Egrave; sostenitore REGA&nbsp;&nbsp;
+ <label>
+ No
+ <input disabled name="rega" type="checkbox" {% if user.1.medic.rega %}checked="checked"{%endif%}>
+ <span class="lever"></span>
+ Si
+ </label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <h6>Medico di famiglia</h6>
+ </div>
+ <div class="input-field col l6 s12">
+ <input disabled value="{{user.1.medic.medic_name}}" name="medic_name" id="medic_name" type="text" >
+ <label for="medic_name">Nome e cognome</label>
+ </div>
+ <div class="input-field col l6 s12">
+ <input disabled value="{{user.1.medic.medic_phone}}" name="medic_phone" id="medic_phone" type="text" >
+ <label for="medic_phone">Telefono studio</label>
+ </div>
+ <div class="input-field col l12 s12">
+ <input disabled value="{{user.1.medic.medic_address}}" name="medic_address" id="medic_address" type="text" >
+ <label for="medic_address">Indirizzo completo</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <h6>Scheda medica personale</h6>
+ </div>
+ <div class="input-field col s12">
+ <input disabled value="{{user.1.medic.sickness}}" name="sickness" id="sickness" type="text">
+ <label for="sickness">Principali malattie avute</label>
+ </div>
+ <div class="input-field col l8 s12">
+ <input disabled value="{{user.1.medic.vaccine}}" name="vaccine" id="vaccine" type="text">
+ <label for="vaccine">Vacinazioni fatte</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <label for="tetanus_date">Ultima vacinazione contro il tetano</label>
+ <input disabled value="{{user.1.medic.tetanus_date}}" name="tetanus_date" id="tetanus_date" type="text">
+ </div>
+ <div class="input-field col s12">
+ <input disabled value="{{user.1.medic.allergy}}" name="allergy" id="allergy" type="text">
+ <label for="allergy">Allergie particolari/Intolleraze alimentari</label>
+ </div>
+ <div class="switch col s12">
+ Deve assumere regolarmente medicamenti&nbsp;&nbsp;
+ <label>
+ No
+ <input disabled name="drugs_bool" type="checkbox" {% if user.1.medic.drugs_bool %}checked="checked"{%endif%}>
+ <span class="lever"></span>
+ Si
+ </label>
+ </div>
+ <div class="input-field col s12">
+ <input disabled value="{{user.1.medic.drugs}}" name="drugs" id="drugs" type="text">
+ <label for="drugs">Se s&igrave; quali, in che dosi e prescrizioni</label>
+ </div>
+ <div class="switch col s12">
+ Informazioni particolari sullo stato di salute: (postumi di operazioni, incidenti, malattie, disturbi fisici)&nbsp;&nbsp;
+ <label>
+ No
+ <input disabled name="misc_bool" type="checkbox" {% if user.1.medic.misc_bool %}checked="checked"{%endif%}>
+ <span class="lever"></span>
+ Si
+ </label>
+ </div>
+ <div class="input-field col s12">
+ <input disabled value="{{user.1.medic.misc}}" name="misc" id="misc" type="text">
+ <label for="misc">Se s&igrave; quali</label>
+ </div>
+ </span></div>
+ </li>
+ <li>
+ <div class="collapsible-header">
+ <i class="material-icons">assignment</i>Documenti
+ </div>
+ <div class="collapsible-body"><span>
+ <ul class="collapsible">
+ {% for doc in user.3 %}
+ <li>
+ <div class="collapsible-header"><a onclick="send('f{{doc.id}}')">{{doc.document_type.name}}</a></div>
+ </li>
+ {% endfor %}
+ </ul>
+ </span></div>
+ </li>
+ </ul>
+ </span></div>
+ </li>
+ {% endfor %}
+</ul>
+</form>
+{% endblock %}
+
+{% block script %}
+document.addEventListener('DOMContentLoaded', function() {
+ var elems = document.querySelectorAll('.collapsible');
+ var instances = M.Collapsible.init(elems, {});
+});
+
+function send(id) {
+ var form = document.getElementById('form')
+ var action = document.getElementById('action')
+
+ action.setAttribute('value', id);
+ form.submit()
+}
{% endblock %} \ No newline at end of file
diff --git a/server/views.py b/server/views.py
index fb6af0f..0954a1f 100644
--- a/server/views.py
+++ b/server/views.py
@@ -5,6 +5,7 @@ from django.db.models import Q
from django.http import HttpResponseRedirect, FileResponse
from django.db.models.deletion import ProtectedError
from django.template.loader import get_template
+from django.conf import settings
import dateparser
from datetime import datetime
@@ -140,61 +141,27 @@ def docapprove(request):
def ulist(request):
context = {}
if (request.user.is_staff):
- parent_group = request.user.groups.values_list('name', flat=True)[
- 0]
- users = User.objects.filter(groups__name=parent_group)
+ parent_group = request.user.groups.values_list('name', flat=True)[0]
+ group = Group.objects.get(name=parent_group)
+ if request.method == "POST":
+ if request.POST["action"][0] == 'f':
+ document = Document.objects.get(id=request.POST["action"][1:])
+ if document.group == group:
+ template = get_template('server/download_doc.html')
+ doc = [document, KeyVal.objects.filter(container=document), document.personal_data, document.medical_data, parent_group]
+ context = {'doc': doc}
+ html = template.render(context)
+ pdf = pdfkit.from_string(html, False)
+ result = BytesIO(pdf)
+ result.seek(0)
+
+ return FileResponse(result, as_attachment=True, filename=document.user.username+"_"+document.document_type.name+".pdf")
+ users = User.objects.filter(groups__name=parent_group).order_by("first_name")
out = []
for user in users:
- code = ""
- parent_name = ""
- via = ""
- cap = ""
- country = ""
- nationality = ""
- born_date = ""
- home_phone = ""
- phone = ""
- school = ""
- year = ""
- status = ""
- if user.is_staff:
- status = "Staff"
- elif user.has_perm("approved"):
- status = "Attivo"
- else:
- status = "In attesa"
- if len(UserCode.objects.filter(user=user)) > 0:
- usercode = UserCode.objects.filter(user=user)[0]
- code = 'U' + str(usercode.code)
- parent_name = usercode.parent_name
- via = usercode.via
- cap = usercode.cap
- country = usercode.country
- nationality = usercode.nationality
- born_date = usercode.born_date
- home_phone = usercode.home_phone
- phone = usercode.phone
- school = usercode.school
- year = usercode.year
- else:
- status = "Non registrato"
- out.append([
- status,
- user.username,
- user.first_name,
- user.last_name,
- born_date,
- parent_name,
- user.email,
- phone,
- home_phone,
- via,
- cap,
- country,
- nationality,
- school,
- year,
- code])
+ usercode = UserCode.objects.filter(user=user)[0]
+ documents = Document.objects.filter(Q(user=user) & ~Q(status='archive'))
+ out.append([user, usercode, parent_group, documents])
context = {'users': out}
return render(request, 'server/user_list.html', context)
else:
@@ -214,6 +181,7 @@ def doctype(request):
medic = True
custom = True
message = True
+ group_bool = True
public_check = 'checked="checked"'
selfsign_check = 'checked="checked"'
hidden_check = 'checked="checked"'
@@ -221,11 +189,15 @@ def doctype(request):
medic_check = 'checked="checked"'
custom_check = 'checked="checked"'
message_check = 'checked="checked"'
+ group_check = 'checked="checked"'
if request.method == "POST":
selected = []
+ parent_groups = request.user.groups.values_list('name', flat=True)
for i in request.POST.keys():
if i.isdigit():
- selected.append(DocumentType.objects.get(id=i))
+ docc = DocumentType.objects.get(id=i)
+ if docc.group.name in parent_groups:
+ selected.append(docc)
for i in selected:
if request.POST["action"] == 'delete':
@@ -248,6 +220,7 @@ def doctype(request):
medic = "filter_medic" in request.POST
custom = "filter_custom" in request.POST
message = "filter_message" in request.POST
+ group_bool = "filter_group" in request.POST
if request.POST["action"] == 'clear':
public = True
@@ -257,6 +230,7 @@ def doctype(request):
medic = True
custom = True
message = True
+ group_bool = True
parent_group = request.user.groups.values_list('name', flat=True)[
0]
@@ -284,6 +258,9 @@ def doctype(request):
if not message:
public_types = public_types.filter(custom_message=False)
message_check = ""
+ if not group_bool:
+ public_types = public_types.filter(custom_group=False)
+ group_check = ""
out = []
for doc in public_types:
@@ -300,6 +277,7 @@ def doctype(request):
'medic_check': medic_check,
'custom_check': custom_check,
'message_check': message_check,
+ 'group_check': group_check,
'error': error,
'error_text': error_text,
}
@@ -319,12 +297,14 @@ def doccreate(request):
personal_data = False
medical_data = False
custom_data = False
+ custom_group_bool = False
name = ""
+ custom_group = ""
- enabled_check = 'checked="checked'
+ enabled_check = 'checked="checked"'
private_check = 'checked="checked"'
personal_check = 'checked="checked"'
- sign_check = 'checked="checked'
+ sign_check = 'checked="checked"'
medical_check = ""
custom_check = ""
custom_message_check = ""
@@ -347,8 +327,20 @@ def doccreate(request):
custom_message = "custom_message" in request.POST.keys()
custom_message_text = request.POST["custom_message_text"]
name = request.POST["name"]
+ custom_group = request.POST["custom_group"]
+
+ if custom_group != "":
+ print("here")
+ if custom_group not in request.user.groups.values_list('name', flat=True):
+ context["error"] = "true"
+ context["error_text"] = "Non puoi creare un tipo assegnato ad un gruppo di cui non fai parte"
+ return render(request, 'server/doc_create.html', context)
+ else:
+ group = Group.objects.filter(name=custom_group)[0]
+ custom_group_bool = True
+
doctype = DocumentType(
- auto_sign=auto_sign, custom_message=custom_message, custom_message_text=custom_message_text, name=request.POST["name"], enabled=enabled, group_private=group_private, group=group, personal_data=personal_data, medical_data=medical_data, custom_data=custom_data)
+ custom_group=custom_group_bool, auto_sign=auto_sign, custom_message=custom_message, custom_message_text=custom_message_text, name=request.POST["name"], enabled=enabled, group_private=group_private, group=group, personal_data=personal_data, medical_data=medical_data, custom_data=custom_data)
doctype.save()
if custom_data:
custom = request.POST["custom"]
@@ -387,11 +379,13 @@ def doclist(request):
older = zurich.localize(datetime.now())
owner = []
types = []
+ groups = []
chips_owner = []
chips_types = []
+ chips_groups = []
if request.method == "POST":
- if request.POST["action"][0] == 'f':
+ if request.POST["action"][0] == 'k':
document = Document.objects.get(id=request.POST["action"][1:])
if document.group == group:
template = get_template('server/download_doc.html')
@@ -405,9 +399,12 @@ def doclist(request):
return FileResponse(result, as_attachment=True, filename=document.user.username+"_"+document.document_type.name+".pdf")
selected = []
+ parent_groups = request.user.groups.values_list('name', flat=True)
for i in request.POST.keys():
if i.isdigit():
- selected.append(Document.objects.get(id=i))
+ docc = Document.objects.get(id=i)
+ if docc.group.name in parent_groups:
+ selected.append(docc)
for i in selected:
if request.POST["action"] == 'delete':
@@ -438,6 +435,7 @@ def doclist(request):
older = zurich.localize(dateparser.parse(request.POST["older"]) + timedelta(days=1))
owner = request.POST["owner"].split("^|")
types = request.POST["type"].split("^|")
+ groups = request.POST["groups"].split("^|")
if request.POST["action"] == 'clear':
hidden = False
@@ -448,8 +446,14 @@ def doclist(request):
older = zurich.localize(datetime.now())
owner = []
types = []
+ groups = []
+
+ parent_groups = request.user.groups.values_list('name', flat=True)
+ q_obj = Q()
+ for i in parent_groups:
+ q_obj |= Q(group__name=i)
- documents = Document.objects.filter(group=group)
+ documents = Document.objects.filter(q_obj)
if not hidden:
documents = documents.filter(~Q(status="archive"))
@@ -485,6 +489,15 @@ def doclist(request):
documents = documents.filter(q_obj)
+ if len(groups) > 0:
+ if groups[0] != "":
+ q_obj = Q()
+ for g in groups:
+ q_obj |= Q(group__name=g)
+ chips_groups.append(g)
+
+ documents = documents.filter(q_obj)
+
out = []
for i in documents:
personal = None
@@ -503,6 +516,7 @@ def doclist(request):
context = {
"types": auto_types,
"users": users,
+ "groups": parent_groups,
"docs": out,
"hidden_check": hidden_check,
"wait_check": wait_check,
@@ -512,8 +526,10 @@ def doclist(request):
"older": older,
"chips_owner": chips_owner,
"chips_type": chips_types,
+ "chips_groups": chips_groups,
'error': error,
'error_text': error_text,
+ 'settings': settings,
}
return render(request, 'server/doc_list.html', context)
else: