From 3a175662da52cc770d52e46a9abe2cd782aa2142 Mon Sep 17 00:00:00 2001 From: Andrea Lepori Date: Mon, 20 Jul 2020 23:53:03 +0200 Subject: search users, show attachments, fancy pass reset --- accounts/templates/accounts/index.html | 19 +++-- accounts/views.py | 4 +- client/templates/client/index.html | 27 ++++++++ client/views.py | 15 +++- manager/settings.py | 1 - server/templates/server/doc_list.html | 27 ++++++++ server/templates/server/download_doc.html | 27 ++++++++ server/templates/server/user_list.html | 81 ++++++++++++++++++++-- server/views.py | 50 +++++++++++-- templates/registration/login.html | 3 + .../registration/password_reset_complete.html | 14 +++- templates/registration/password_reset_confirm.html | 35 ++++++---- templates/registration/password_reset_done.html | 24 ++++--- templates/registration/password_reset_email.html | 11 ++- templates/registration/password_reset_form.html | 21 ++++-- 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 %} +
- +
@@ -130,6 +131,7 @@ save
+
@@ -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 @@ {% endif %} + {% if doc.0.document_type.medical_data %} +
  • +
    + attach_fileAllegati +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
  • + {% endif %} 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 @@ {% endif %} + {% if doc.0.document_type.medical_data %} +
  • +
    + attach_fileAllegati +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
  • + {% endif %} 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 @@ {% endif %} + {% if doc.0.document_type.medical_data %} +
  • +
    + attach_fileAllegati +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
  • + {% endif %} 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 %} - Home - Admin - Lista Utenti +
    {% endblock %} {% block content %} @@ -15,7 +44,7 @@