From b5ae2b0629fea23e4f415a17cdb029435bf56d29 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 7 Jul 2023 16:57:36 +0200 Subject: [PATCH] add manuals in templates: --- .../modules/did/templates/anonymous.html | 14 ++++ .../modules/did/templates/operator.html | 76 +++++++++++++++++-- .../modules/did/templates/verifier.html | 14 ++++ ereuse_devicehub/modules/did/views.py | 9 ++- 4 files changed, 104 insertions(+), 9 deletions(-) diff --git a/ereuse_devicehub/modules/did/templates/anonymous.html b/ereuse_devicehub/modules/did/templates/anonymous.html index b2efdadc..a154468c 100644 --- a/ereuse_devicehub/modules/did/templates/anonymous.html +++ b/ereuse_devicehub/modules/did/templates/anonymous.html @@ -69,6 +69,20 @@
Details
+ {% if manuals.details %} +
+
+ {% if manuals.details.logo %} + + {% endif %} +
+
+ {% if manuals.details.image %} + + {% endif %} +
+
+ {% endif %}
Type diff --git a/ereuse_devicehub/modules/did/templates/operator.html b/ereuse_devicehub/modules/did/templates/operator.html index fff3018c..8116354c 100644 --- a/ereuse_devicehub/modules/did/templates/operator.html +++ b/ereuse_devicehub/modules/did/templates/operator.html @@ -68,7 +68,21 @@
-
Basic
+
Details
+ {% if manuals.details %} +
+
+ {% if manuals.details.logo %} + + {% endif %} +
+
+ {% if manuals.details.image %} + + {% endif %} +
+
+ {% endif %}
Type @@ -148,7 +162,7 @@
-
+
Status
@@ -174,6 +188,51 @@
+
+
+ {% if manuals.icecat %} +
Icecat data sheet
+
+
+ {% if manuals.details.logo %} + + {% endif %} + {% if manuals.details.image %} + + {% endif %} + {% if manuals.details.pdf %} + {{ manuals.details.title }}
+ {% else %} + {{ manuals.details.title }}
+ {% endif %} +
+
+
+ +
+
+
+ {% for m in manuals.icecat %} +
+ {% if m.logo %} + + {% endif %} + {% if m.pdf %} + {{ m.title }}
+ {% else %} + {{ m.title }}
+ {% endif %} +
+ {% endfor %} +
+
+
+
+ {% endif %} +
@@ -223,10 +282,16 @@
+ {% if manuals.ifixit %}
-
-
Repair manuals
-
+
+
+ +
+
{% for m in manuals.ifixit %}
@@ -244,6 +309,7 @@
+ {% endif %}
diff --git a/ereuse_devicehub/modules/did/templates/verifier.html b/ereuse_devicehub/modules/did/templates/verifier.html index bf6348be..ac0e17b9 100644 --- a/ereuse_devicehub/modules/did/templates/verifier.html +++ b/ereuse_devicehub/modules/did/templates/verifier.html @@ -69,6 +69,20 @@
Details
+ {% if manuals.details %} +
+
+ {% if manuals.details.logo %} + + {% endif %} +
+
+ {% if manuals.details.image %} + + {% endif %} +
+
+ {% endif %}
Type diff --git a/ereuse_devicehub/modules/did/views.py b/ereuse_devicehub/modules/did/views.py index bd7e0ab5..b9a270b3 100644 --- a/ereuse_devicehub/modules/did/views.py +++ b/ereuse_devicehub/modules/did/views.py @@ -192,14 +192,15 @@ class DidView(View): def get_manuals(self): params = { - "manufacturer": 'HP' or self.device.manufacturer, - "model": 'Pavilion dv6000' or self.device.model, + "manufacturer": self.device.manufacturer, + "model": self.device.model, } self.params = json.dumps(params) - manuals = {'ifixit': {}, 'icecat': {}} + manuals = {'ifixit': [], 'icecat': [], 'details': {}} manuals['ifixit'] = self.request_manuals('ifixit') manuals['icecat'] = self.request_manuals('icecat') - # import pdb; pdb.set_trace() + if manuals['icecat']: + manuals['details'] = manuals['icecat'][0] self.context['manuals'] = manuals def request_manuals(self, prefix):