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 --- client/templates/client/index.html | 27 +++++++++++++++++++++++++++ client/views.py | 15 ++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) (limited to 'client') 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 -- cgit v1.2.1