aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--server/templates/server/doc_list.html27
-rw-r--r--server/templates/server/download_doc.html27
-rw-r--r--server/templates/server/user_list.html81
-rw-r--r--server/views.py50
4 files changed, 175 insertions, 10 deletions
diff --git a/server/templates/server/doc_list.html b/server/templates/server/doc_list.html
index 5206d2f..51cd5e4 100644
--- a/server/templates/server/doc_list.html
+++ b/server/templates/server/doc_list.html
@@ -380,6 +380,33 @@
</span></div>
</li>
{% endif %}
+ {% if doc.0.document_type.medical_data %}
+ <li>
+ <div class="collapsible-header">
+ <i class="material-icons">attach_file</i>Allegati
+ </div>
+ <div class="collapsible-body"><span>
+ <div class="row">
+ <div class="col s12">
+ <div class="card">
+ <div class="card-image">
+ <img src="data:;base64,{{ doc.5 }}">
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <div class="card">
+ <div class="card-image">
+ <img src="data:;base64,{{ doc.6 }}">
+ </div>
+ </div>
+ </div>
+ </div>
+ </span></div>
+ </li>
+ {% endif %}
</ul>
</span></div>
</li>
diff --git a/server/templates/server/download_doc.html b/server/templates/server/download_doc.html
index 15ec72a..b55b9a0 100644
--- a/server/templates/server/download_doc.html
+++ b/server/templates/server/download_doc.html
@@ -247,6 +247,33 @@
</span></div>
</li>
{% endif %}
+ {% if doc.0.document_type.medical_data %}
+ <li class="active">
+ <div class="collapsible-header">
+ <i class="material-icons">attach_file</i>Allegati
+ </div>
+ <div class="collapsible-body"><span>
+ <div class="row">
+ <div class="col s12">
+ <div class="card">
+ <div class="card-image">
+ <img src="data:;base64,{{ vac }}">
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <div class="card">
+ <div class="card-image">
+ <img src="data:;base64,{{ health }}">
+ </div>
+ </div>
+ </div>
+ </div>
+ </span></div>
+ </li>
+ {% endif %}
</ul>
</span></div>
</li>
diff --git a/server/templates/server/user_list.html b/server/templates/server/user_list.html
index 8abf5e8..8ee2008 100644
--- a/server/templates/server/user_list.html
+++ b/server/templates/server/user_list.html
@@ -1,11 +1,40 @@
-{% extends 'registration/base.html' %}
+{% extends 'registration/base_custom.html' %}
{% 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>
+ <nav class="nav-extended">
+ <div class="nav-wrapper red lighten-1">
+ <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>
+ <ul class="right">
+ {% if user.is_staff %}
+ <li><a href="{% url 'server' %}">Pannello Admin</a></li>
+ {% endif %}
+ {% if user.is_authenticated %}
+ <li><a href="{% url 'personal' %}">{{ user.username }}</a></li>
+ {% endif %}
+ {% if user.username != "" %}
+ <li>
+ <a href="{% url 'logout' %}"><i class="material-icons">exit_to_app</i></a>
+ </li>
+ {% else %}
+ <li><a href="{% url 'signup' %}">Registrazione</a></li>
+ <li><a href="{% url 'login' %}">Login</a></li>
+ {% endif %}
+ </ul>
+ </div>
+ <div class="nav-wrapper red lighten-1">
+ <form>
+ <div class="input-field">
+ <input autocomplete="off" id="search" type="search" onkeyup="filterResults()" required>
+ <label class="label-icon" for="search"><i class="material-icons">search</i></label>
+ <i class="material-icons">close</i>
+ </div>
+ </form>
+ </div>
+ </nav>
{% endblock %}
{% block content %}
@@ -15,7 +44,7 @@
<ul class="collapsible">
{% for user in users %}
<li>
- <div class="collapsible-header">
+ <div class="collapsible-header list">
{% if user.0.is_staff %}
<i class="material-icons">grade</i>
{% endif %}
@@ -217,6 +246,31 @@
</li>
<li>
<div class="collapsible-header">
+ <i class="material-icons">attach_file</i>Allegati
+ </div>
+ <div class="collapsible-body"><span>
+ <div class="row">
+ <div class="col s12">
+ <div class="card">
+ <div class="card-image">
+ <img src="data:;base64,{{ user.4 }}">
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <div class="card">
+ <div class="card-image">
+ <img src="data:;base64,{{ user.5 }}">
+ </div>
+ </div>
+ </div>
+ </div>
+ </span></div>
+ </li>
+ <li>
+ <div class="collapsible-header">
<i class="material-icons">assignment</i>Documenti
</div>
<div class="collapsible-body"><span>
@@ -250,4 +304,21 @@ function send(id) {
action.setAttribute('value', id);
form.submit()
}
+
+function filterResults() {
+ var search = document.getElementById('search')
+ var filter = search.value.toUpperCase()
+ var items = document.getElementsByClassName('list')
+
+
+ for (i = 0; i < items.length; i++) {
+ var a = items[i];
+ var txtValue = a.innerText;
+ if (txtValue.toUpperCase().indexOf(filter) > -1) {
+ items[i].style.display = "";
+ } else {
+ items[i].style.display = "none";
+ }
+ }
+}
{% endblock %} \ No newline at end of file
diff --git a/server/views.py b/server/views.py
index b04cce1..e9739c3 100644
--- a/server/views.py
+++ b/server/views.py
@@ -14,6 +14,7 @@ from datetime import timedelta
import pytz
import pdfkit
from io import BytesIO
+import os, base64
# Create your views here.
@@ -142,9 +143,20 @@ def ulist(request):
if request.POST["action"][0] == 'f':
document = Document.objects.get(id=request.POST["action"][1:])
if document.group == group:
+ vac_file = ""
+ health_file = ""
+ if document.medical_data:
+ if document.medical_data.vac_certificate.name:
+ with open(document.medical_data.vac_certificate.name, 'rb') as image_file:
+ vac_file = base64.b64encode(image_file.read()).decode()
+
+ if document.medical_data.health_care_certificate.name:
+ with open(document.medical_data.health_care_certificate.name, 'rb') as image_file:
+ health_file = base64.b64encode(image_file.read()).decode()
+
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}
+ context = {'doc': doc, 'vac': vac_file, 'health': health_file}
html = template.render(context)
pdf = pdfkit.from_string(html, False)
result = BytesIO(pdf)
@@ -155,8 +167,18 @@ def ulist(request):
out = []
for user in users:
usercode = UserCode.objects.filter(user=user)[0]
- documents = Document.objects.filter(Q(user=user) & ~Q(status='archive'))
- out.append([user, usercode, parent_group, documents])
+ documents = Document.objects.filter(Q(user=user) & ~Q(status='archive') & Q(group__name=parent_group))
+ vac_file = ""
+ health_file = ""
+ if usercode.medic:
+ if usercode.medic.vac_certificate.name:
+ with open(usercode.medic.vac_certificate.name, 'rb') as image_file:
+ vac_file = base64.b64encode(image_file.read()).decode()
+
+ if usercode.medic.health_care_certificate.name:
+ with open(usercode.medic.health_care_certificate.name, 'rb') as image_file:
+ health_file = base64.b64encode(image_file.read()).decode()
+ out.append([user, usercode, parent_group, documents, vac_file, health_file])
context = {'users': out}
return render(request, 'server/user_list.html', context)
@@ -377,9 +399,20 @@ def doclist(request):
if request.POST["action"][0] == 'k':
document = Document.objects.get(id=request.POST["action"][1:])
if document.group == group:
+ vac_file = ""
+ health_file = ""
+ if document.medical_data:
+ if document.medical_data.vac_certificate.name:
+ with open(document.medical_data.vac_certificate.name, 'rb') as image_file:
+ vac_file = base64.b64encode(image_file.read()).decode()
+
+ if document.medical_data.health_care_certificate.name:
+ with open(document.medical_data.health_care_certificate.name, 'rb') as image_file:
+ health_file = base64.b64encode(image_file.read()).decode()
+
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}
+ context = {'doc': doc, 'vac': vac_file, 'health': health_file}
html = template.render(context)
pdf = pdfkit.from_string(html, False)
result = BytesIO(pdf)
@@ -495,10 +528,17 @@ def doclist(request):
personal = i.personal_data
if i.document_type.medical_data:
medical = i.medical_data
+ if medical.vac_certificate.name:
+ with open(medical.vac_certificate.name, 'rb') as image_file:
+ vac_file = base64.b64encode(image_file.read()).decode()
+
+ if medical.health_care_certificate.name:
+ with open(medical.health_care_certificate.name, 'rb') as image_file:
+ health_file = base64.b64encode(image_file.read()).decode()
doc_group = i.user.groups.values_list('name', flat=True)[0]
- out.append([i, KeyVal.objects.filter(container=i), personal, medical, doc_group])
+ out.append([i, KeyVal.objects.filter(container=i), personal, medical, doc_group, vac_file, health_file])
auto_types = DocumentType.objects.filter(Q(group_private=False) | Q(group=group))
users = User.objects.filter(groups__name=parent_group)