add did document to details page
This commit is contained in:
parent
9247f11c27
commit
9503a9a8b4
|
@ -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()
|
||||
|
|
|
@ -228,17 +228,33 @@
|
|||
|
||||
<div class="tab-pane fade" id="evidences">
|
||||
<h5 class="card-title">{% trans 'List of evidences' %}</h5>
|
||||
<div class="list-group col-6">
|
||||
{% for snap in object.evidences %}
|
||||
<div class="list-group-item">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<small class="text-muted">{{ snap.created }}</small>
|
||||
</div>
|
||||
<p class="mb-1">
|
||||
<a href="{% url 'evidence:details' snap.uuid %}">{{ snap.uuid }}</a>
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="list-group col">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">uuid</th>
|
||||
<th scope="col">Did Document</th>
|
||||
<th scope="col">{% trans "Date" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% 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>
|
||||
|
||||
|
|
|
@ -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(":", "/")
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue