diff options
Diffstat (limited to '')
-rw-r--r-- | accounts/templates/accounts/index.html | 19 | ||||
-rw-r--r-- | accounts/views.py | 4 | ||||
-rw-r--r-- | client/templates/client/index.html | 27 | ||||
-rw-r--r-- | client/views.py | 15 | ||||
-rw-r--r-- | manager/settings.py | 1 | ||||
-rw-r--r-- | server/templates/server/doc_list.html | 27 | ||||
-rw-r--r-- | server/templates/server/download_doc.html | 27 | ||||
-rw-r--r-- | server/templates/server/user_list.html | 81 | ||||
-rw-r--r-- | server/views.py | 50 | ||||
-rw-r--r-- | templates/registration/login.html | 3 | ||||
-rw-r--r-- | templates/registration/password_reset_complete.html | 14 | ||||
-rw-r--r-- | templates/registration/password_reset_confirm.html | 35 | ||||
-rw-r--r-- | templates/registration/password_reset_done.html | 24 | ||||
-rw-r--r-- | templates/registration/password_reset_email.html | 11 | ||||
-rw-r--r-- | templates/registration/password_reset_form.html | 21 | ||||
-rw-r--r-- | templates/registration/password_reset_subject.txt | 2 |
16 files changed, 301 insertions, 60 deletions
diff --git a/accounts/templates/accounts/index.html b/accounts/templates/accounts/index.html index a6e6edd..01240ad 100644 --- a/accounts/templates/accounts/index.html +++ b/accounts/templates/accounts/index.html @@ -51,11 +51,12 @@ {% endblock%} {% block content %} +<form action="{% url 'personal'%}" method="post" id="form" enctype="multipart/form-data"> <div id="personal" class="row"> <div class="col l8 offset-l2 s12"> <div class="card-panel"> <div class="row"> - <form action="{% url 'personal'%}" method="post" id="form" class="col s12" enctype="multipart/form-data"> + <div class="col 12"> <input type="hidden" name="action" id="action"> <input type="hidden" name="delete_vac" id="delete_vac"> <input type="hidden" name="delete_health" id="delete_health"> @@ -130,6 +131,7 @@ <i class="large material-icons">save</i> </a> </div> + </div> </div> </div> </div> @@ -323,6 +325,7 @@ {% block script %} function send(id) { + $('#form').trigger('reinitialize.areYouSure'); var form = document.getElementById('form'); var action = document.getElementById('action'); action.setAttribute('value', id); @@ -364,17 +367,21 @@ var options = { labelMonthSelect: 'Seleziona un mese', labelYearSelect: 'Seleziona un anno' }} + var instance = M.Tabs.init(elem, options); + document.addEventListener('DOMContentLoaded', function() { -var elems = document.querySelectorAll('.datepicker'); -var instances = M.Datepicker.init(elems, options); + var elems = document.querySelectorAll('.datepicker'); + var instances = M.Datepicker.init(elems, options); }); + document.addEventListener('DOMContentLoaded', function() { -var elems = document.querySelectorAll('select'); -var instances = M.FormSelect.init(elems, options); + var elems = document.querySelectorAll('select'); + var instances = M.FormSelect.init(elems, options); }); + $(document).ready(function() { -$('input#sickness, input#vaccine, input#allergy, input#drugs, input#misc').characterCounter(); + $('input#sickness, input#vaccine, input#allergy, input#drugs, input#misc').characterCounter(); }); /*! diff --git a/accounts/views.py b/accounts/views.py index 24e1b96..369e173 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -99,11 +99,11 @@ def personal(request): medic.save() if request.POST["delete_vac"] == 'vac': - medic.vac_certificate.delete() + medic.vac_certificate = None medic.save() if request.POST["delete_health"] == 'health': - medic.health_care_certificate.delete() + medic.health_care_certificate = None medic.save() if len(request.user.groups.values_list('name', flat=True)) == 0: diff --git a/client/templates/client/index.html b/client/templates/client/index.html index ff12e74..0eb244e 100644 --- a/client/templates/client/index.html +++ b/client/templates/client/index.html @@ -266,6 +266,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/client/views.py b/client/views.py index 76672cd..f215e7e 100644 --- a/client/views.py +++ b/client/views.py @@ -10,6 +10,7 @@ from django.shortcuts import render from django.template.loader import get_template from io import BytesIO import pdfkit +import base64 # Create your views here. @@ -77,9 +78,17 @@ def index(request): 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]) context = { "docs": out, "empty": len(out) == 0, @@ -155,7 +164,7 @@ def create(request): if document_type.medical_data: medic = usercode.medic - medical_data = MedicalData(emer_name=medic.emer_name, emer_relative=medic.emer_relative, cell_phone=medic.cell_phone, address=medic.address, emer_phone=medic.emer_phone, health_care=medic.health_care, injuries=medic.injuries, rc=medic.rc, rega=medic.rega, medic_name=medic.medic_name, medic_phone=medic.medic_phone, medic_address=medic.medic_address, sickness=medic.sickness, vaccine=medic.vaccine, tetanus_date=medic.tetanus_date, allergy=medic.allergy, drugs_bool=medic.drugs_bool, drugs=medic.drugs, misc_bool=medic.misc_bool, misc=medic.misc) + medical_data = MedicalData(vac_certificate=medic.vac_certificate, health_care_certificate=medic.health_care_certificate, emer_name=medic.emer_name, emer_relative=medic.emer_relative, cell_phone=medic.cell_phone, address=medic.address, emer_phone=medic.emer_phone, health_care=medic.health_care, injuries=medic.injuries, rc=medic.rc, rega=medic.rega, medic_name=medic.medic_name, medic_phone=medic.medic_phone, medic_address=medic.medic_address, sickness=medic.sickness, vaccine=medic.vaccine, tetanus_date=medic.tetanus_date, allergy=medic.allergy, drugs_bool=medic.drugs_bool, drugs=medic.drugs, misc_bool=medic.misc_bool, misc=medic.misc) medical_data.save() while (True): @@ -200,7 +209,7 @@ def edit_wrapper(request, context): if document.document_type.medical_data: medic = usercode.medic - medical_data = MedicalData(emer_name=medic.emer_name, emer_relative=medic.emer_relative, cell_phone=medic.cell_phone, address=medic.address, emer_phone=medic.emer_phone, health_care=medic.health_care, injuries=medic.injuries, rc=medic.rc, rega=medic.rega, medic_name=medic.medic_name, medic_phone=medic.medic_phone, medic_address=medic.medic_address, sickness=medic.sickness, vaccine=medic.vaccine, tetanus_date=medic.tetanus_date, allergy=medic.allergy, drugs_bool=medic.drugs_bool, drugs=medic.drugs, misc_bool=medic.misc_bool, misc=medic.misc) + medical_data = MedicalData(vac_certificate=medic.vac_certificate, health_care_certificate=medic.health_care_certificate, emer_name=medic.emer_name, emer_relative=medic.emer_relative, cell_phone=medic.cell_phone, address=medic.address, emer_phone=medic.emer_phone, health_care=medic.health_care, injuries=medic.injuries, rc=medic.rc, rega=medic.rega, medic_name=medic.medic_name, medic_phone=medic.medic_phone, medic_address=medic.medic_address, sickness=medic.sickness, vaccine=medic.vaccine, tetanus_date=medic.tetanus_date, allergy=medic.allergy, drugs_bool=medic.drugs_bool, drugs=medic.drugs, misc_bool=medic.misc_bool, misc=medic.misc) medical_data.save() old_data = document.medical_data document.medical_data = medical_data diff --git a/manager/settings.py b/manager/settings.py index 037fc9e..094f1e9 100644 --- a/manager/settings.py +++ b/manager/settings.py @@ -46,7 +46,6 @@ INSTALLED_APPS = [ 'server.apps.ServerConfig', 'accounts.apps.AccountsConfig', 'client.apps.ClientConfig', - 'django_cleanup', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 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) diff --git a/templates/registration/login.html b/templates/registration/login.html index 9459f93..9ee3bb8 100644 --- a/templates/registration/login.html +++ b/templates/registration/login.html @@ -11,6 +11,9 @@ {% csrf_token %} {{ form.as_p }} <br> + <a href={% url 'password_reset' %}>Password dimenticata</a> + <br> + <br> <button class="btn waves-effect waves-light" type="submit">Login</button> </form> </div> diff --git a/templates/registration/password_reset_complete.html b/templates/registration/password_reset_complete.html index c0bccc1..bf8e24c 100644 --- a/templates/registration/password_reset_complete.html +++ b/templates/registration/password_reset_complete.html @@ -1,7 +1,15 @@ {% extends 'registration/base_simple.html' %} {% block content %} - <p> - Your password has been set. You may go ahead and <a href="{% url 'signin' %}">sign in</a> now. - </p> + <div class="row"> + <div class="col l4 offset-l4 m8 offset-m2 s12"> + <div class="card"> + <div class="card-content"> + <p> + La password è stata reimpostata con successo. Ora puoi fare il <a href="{% url 'login' %}">login</a>. + </p> + </div> + </div> + </div> + </div> {% endblock %}
\ No newline at end of file diff --git a/templates/registration/password_reset_confirm.html b/templates/registration/password_reset_confirm.html index 6838eb8..b0b46a4 100644 --- a/templates/registration/password_reset_confirm.html +++ b/templates/registration/password_reset_confirm.html @@ -1,17 +1,26 @@ {% extends 'registration/base_simple.html' %} {% block content %} - {% if validlink %} - <h3>Change password</h3> - <form method="post"> - {% csrf_token %} - {{ form.as_p }} - <button type="submit">Change password</button> - </form> - {% else %} - <p> - The password reset link was invalid, possibly because it has already been used. - Please request a new password reset. - </p> - {% endif %} + <div class="row"> + <div class="col l4 offset-l4 m8 offset-m2 s12"> + <div class="card"> + <div class="card-content"> + {% if validlink %} + <h5>Cambia password</h5> + <form method="post"> + {% csrf_token %} + {{ form.as_p }} + <br> + <button class="btn waves-effect waves-light" type="submit">Invia</button> + </form> + {% else %} + <p> + Il link di reimpostazione della password è invalido, probabilmente perchè è già stato usato. + Prego richiedere un altro link. + </p> + {% endif %} + </div> + </div> + </div> + </div> {% endblock %}
\ No newline at end of file diff --git a/templates/registration/password_reset_done.html b/templates/registration/password_reset_done.html index 6abc3e1..399afb7 100644 --- a/templates/registration/password_reset_done.html +++ b/templates/registration/password_reset_done.html @@ -1,12 +1,20 @@ {% extends 'registration/base_simple.html' %} {% block content %} - <p> - We've emailed you instructions for setting your password, if an account exists with the email you entered. - You should receive them shortly. - </p> - <p> - If you don't receive an email, please make sure you've entered the address you registered with, - and check your spam folder. - </p> + <div class="row"> + <div class="col l4 offset-l4 m8 offset-m2 s12"> + <div class="card"> + <div class="card-content"> + <p> + Ti abbiamo inviato una email con le istruzioni per reimpostare la password, se l'account inserito + esiste. Dovresti riceverle a breve. + </p> + <p> + Se non hai ricevuto la email controlla che l'indirizzo inserito sia corretto e controlla la cartella + di spam. + </p> + </div> + </div> + </div> + </div> {% endblock %}
\ No newline at end of file diff --git a/templates/registration/password_reset_email.html b/templates/registration/password_reset_email.html index da2c169..b5892a4 100644 --- a/templates/registration/password_reset_email.html +++ b/templates/registration/password_reset_email.html @@ -1,12 +1,9 @@ {% autoescape off %} -To initiate the password reset process for your {{ user.get_username }} TestSite Account, -click the link below: +Per reimpostare la password per l'utente {{ user.get_username }} +clicca il link qua sotto: {{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %} -If clicking the link above doesn't work, please copy and paste the URL in a new browser -window instead. - -Sincerely, -The TestSite Team +Se cliccando il link non funziona prova a copiare ed incollare il link direttamente nella barra del +tuo browser. {% endautoescape %}
\ No newline at end of file diff --git a/templates/registration/password_reset_form.html b/templates/registration/password_reset_form.html index d0d6250..5789900 100644 --- a/templates/registration/password_reset_form.html +++ b/templates/registration/password_reset_form.html @@ -1,10 +1,19 @@ {% extends 'registration/base_simple.html' %} {% block content %} - <h3>Forgot password</h3> - <form method="post"> - {% csrf_token %} - {{ form.as_p }} - <button type="submit">Submit</button> - </form> + <div class="row"> + <div class="col l4 offset-l4 m8 offset-m2 s12"> + <div class="card"> + <div class="card-content"> + <h5>Reimposta password</h5> + <form method="post"> + {% csrf_token %} + {{ form.as_p }} + <br> + <button class="btn waves-effect waves-light" type="submit">Invia</button> + </form> + </div> + </div> + </div> + </div> {% endblock %}
\ No newline at end of file diff --git a/templates/registration/password_reset_subject.txt b/templates/registration/password_reset_subject.txt index 7b5a65b..711fff8 100644 --- a/templates/registration/password_reset_subject.txt +++ b/templates/registration/password_reset_subject.txt @@ -1 +1 @@ -TestSite password reset
\ No newline at end of file +Scout Breganzona reimpostazione password
\ No newline at end of file |