From 22cbc05be615e10d7c766dee8b865182f919677d Mon Sep 17 00:00:00 2001 From: Andrea Lepori Date: Thu, 10 Dec 2020 15:23:38 +0100 Subject: lazyload of images in non admin page --- client/templates/client/index.html | 22 +++++++++++++++++++--- client/views.py | 14 +++++++------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/client/templates/client/index.html b/client/templates/client/index.html index b5d1135..932af1c 100644 --- a/client/templates/client/index.html +++ b/client/templates/client/index.html @@ -310,14 +310,19 @@ {% if doc.0.document_type.medical_data %}
  • - attach_fileAllegati + {% if doc.0.medical_data %} + attach_fileAllegati + {% else %} + attach_fileAllegati + {% endif %}
    + {% if doc.0.medical_data %}
    - {% if doc.5 %} {% endif %} + {% if doc.5 %} {% endif %}
    @@ -326,12 +331,22 @@
    - {% if doc.6 %}{% endif %} + {% if doc.6 %}{% endif %} +
    +
    +
    +
    +
    +
    +
    +
    + {% if doc.7 %}{% endif %}
    + {% endif %}
  • {% endif %} @@ -389,6 +404,7 @@ $(document).ready(function(){ {% endif %} {% endif %} {% endif %} + lazyload(); }); {% if user.is_authenticated %} {% if user.is_staff or perms.client.approved %} diff --git a/client/views.py b/client/views.py index 821bc9b..b6e9832 100644 --- a/client/views.py +++ b/client/views.py @@ -101,24 +101,24 @@ def index(request): medical = None vac_file = "" health_file = "" + sign_doc_file = "" if i.personal_data: personal = i.personal_data if i.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() + vac_file = "/server/media/" + str(i.id) + "/vac_certificate/doc" 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() + health_file = "/server/media/" + str(i.id) + "/health_care_certificate/doc" + + if i.signed_doc: + sign_doc_file = "/server/media/" + str(i.id) + "/signed_doc/doc" doc_group = i.user.groups.values_list('name', flat=True)[0] out.append([i, KeyVal.objects.filter(container=i), - personal, medical, doc_group, vac_file, health_file]) + personal, medical, doc_group, vac_file, health_file, sign_doc_file]) context = { "docs": out, -- cgit v1.2.1