From 9503a9a8b4faf9f6a46b4296cc1a21393cf52d28 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 29 Jan 2025 18:05:59 +0100 Subject: [PATCH] add did document to details page --- device/models.py | 5 +++++ device/templates/details.html | 38 +++++++++++++++++++++++++---------- evidence/models.py | 11 ++++++++++ 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/device/models.py b/device/models.py index 7ca2a1f..9adc93d 100644 --- a/device/models.py +++ b/device/models.py @@ -315,3 +315,8 @@ class Device: def components(self): self.get_last_evidence() return self.last_evidence.get_components() + + @property + def did_document(self): + self.get_last_evidence() + return self.last_evidence.get_did_document() diff --git a/device/templates/details.html b/device/templates/details.html index af6ce7c..c5934cd 100644 --- a/device/templates/details.html +++ b/device/templates/details.html @@ -228,17 +228,33 @@
{% trans 'List of evidences' %}
-
- {% for snap in object.evidences %} -
-
- {{ snap.created }} -
-

- {{ snap.uuid }} -

-
- {% endfor %} +
+ + + + + + + + + + {% for snap in object.evidences %} + + + + + + {% endfor %} + +
uuidDid Document{% trans "Date" %}
+ {{ snap.uuid }} + + {% if snap.did_document %} + DID + {% endif %} + + {{ snap.created }} +
diff --git a/evidence/models.py b/evidence/models.py index 024031d..3e9bee5 100644 --- a/evidence/models.py +++ b/evidence/models.py @@ -206,3 +206,14 @@ class Evidence: def is_web_snapshot(self): return self.doc.get("type") == "WebSnapshot" + + def did_document(self): + if not self.doc.get("credentialSubject"): + return '' + did = self.doc.get('issuer') + if not "did:web" in did: + return '' + + return "https://{}/did.json".format( + did.split("did:web:")[1].replace(":", "/") + )