add did document to details page

This commit is contained in:
Cayo Puigdefabregas 2025-01-29 18:05:59 +01:00
parent 754820f631
commit d25f388bbb
3 changed files with 43 additions and 11 deletions

View file

@ -315,3 +315,8 @@ class Device:
def components(self): def components(self):
self.get_last_evidence() self.get_last_evidence()
return self.last_evidence.get_components() return self.last_evidence.get_components()
@property
def did_document(self):
self.get_last_evidence()
return self.last_evidence.get_did_document()

View file

@ -228,17 +228,33 @@
<div class="tab-pane fade" id="evidences"> <div class="tab-pane fade" id="evidences">
<h5 class="card-title">{% trans 'List of evidences' %}</h5> <h5 class="card-title">{% trans 'List of evidences' %}</h5>
<div class="list-group col-6"> <div class="list-group col">
{% for snap in object.evidences %} <table class="table">
<div class="list-group-item"> <thead>
<div class="d-flex w-100 justify-content-between"> <tr>
<small class="text-muted">{{ snap.created }}</small> <th scope="col">uuid</th>
</div> <th scope="col">Did Document</th>
<p class="mb-1"> <th scope="col">{% trans "Date" %}</th>
<a href="{% url 'evidence:details' snap.uuid %}">{{ snap.uuid }}</a> </tr>
</p> </thead>
</div> <tbody>
{% endfor %} {% for snap in object.evidences %}
<tr>
<td>
<a href="{% url 'evidence:details' snap.uuid %}">{{ snap.uuid }}</a>
</td>
<td>
{% if snap.did_document %}
<a href="{{ snap.did_document }}" target="_blank">DID</a>
{% endif %}
</td>
<td>
<small class="text-muted">{{ snap.created }}</small>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div> </div>
</div> </div>

View file

@ -206,3 +206,14 @@ class Evidence:
def is_web_snapshot(self): def is_web_snapshot(self):
return self.doc.get("type") == "WebSnapshot" 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(":", "/")
)