Merge pull request 'bugfix integration with dpp/dlt' (#50) from fix_build into main
Reviewed-on: #50
This commit is contained in:
commit
42f5cf7e36
|
@ -103,6 +103,8 @@
|
|||
|
||||
{% include 'tabs/evidences.html' %}
|
||||
|
||||
{% include 'tabs/dpps.html' %}
|
||||
|
||||
<!-- Add a note popup -->
|
||||
<div class="modal fade" id="addNoteModal" tabindex="-1" aria-labelledby="addNoteModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
|
|
18
device/templates/tabs/dpps.html
Normal file
18
device/templates/tabs/dpps.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
{% load i18n %}
|
||||
|
||||
<div class="tab-pane fade" id="dpps">
|
||||
<h5 class="card-title">{% trans 'List of dpps' %}</h5>
|
||||
<div class="list-group col">
|
||||
{% for d in dpps %}
|
||||
<div class="list-group-item">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<small class="text-muted">{{ d.2.timestamp }}</small>
|
||||
<span>{{ d.2.type }}</span>
|
||||
</div>
|
||||
<p class="mb-1">
|
||||
<a href="{% url 'did:device_web' d.0 %}">{{ d.1 }}...</a>
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
|
@ -94,10 +94,14 @@ class DetailsView(DashboardView, TemplateView):
|
|||
lot_tags = LotTag.objects.filter(owner=self.request.user.institution)
|
||||
dpps = []
|
||||
if settings.DPP:
|
||||
dpps = Proof.objects.filter(
|
||||
_dpps = Proof.objects.filter(
|
||||
uuid__in=self.object.uuids,
|
||||
type=PROOF_TYPE["IssueDPP"]
|
||||
)
|
||||
for x in _dpps:
|
||||
dpp = "{}:{}".format(self.pk, x.signature)
|
||||
dpps.append((dpp, x.signature[:10], x))
|
||||
|
||||
last_evidence = self.object.get_last_evidence()
|
||||
uuids = self.object.uuids
|
||||
state_definitions = StateDefinition.objects.filter(
|
||||
|
|
16
did/views.py
16
did/views.py
|
@ -106,10 +106,10 @@ class PublicDeviceWebView(TemplateView):
|
|||
'device': {},
|
||||
}
|
||||
dev = Build(self.object.last_evidence.doc, None, check=True)
|
||||
doc = dev.get_phid()
|
||||
doc = dev.build.get_doc()
|
||||
data['document'] = json.dumps(doc)
|
||||
data['device'] = dev.device
|
||||
data['components'] = dev.components
|
||||
data['device'] = dev.build.device
|
||||
data['components'] = dev.build.components
|
||||
|
||||
self.object.get_evidences()
|
||||
last_dpp = Proof.objects.filter(
|
||||
|
@ -118,7 +118,7 @@ class PublicDeviceWebView(TemplateView):
|
|||
|
||||
key = self.pk
|
||||
if last_dpp:
|
||||
key = last_dpp.signature
|
||||
key += ":"+last_dpp.signature
|
||||
|
||||
url = "https://{}/did/{}".format(
|
||||
self.request.get_host(),
|
||||
|
@ -135,17 +135,17 @@ class PublicDeviceWebView(TemplateView):
|
|||
for d in self.object.evidences:
|
||||
d.get_doc()
|
||||
dev = Build(d.doc, None, check=True)
|
||||
doc = dev.get_phid()
|
||||
doc = dev.build.get_doc()
|
||||
ev = json.dumps(doc)
|
||||
phid = dev.get_signature(doc)
|
||||
phid = dev.sign(ev)
|
||||
dpp = "{}:{}".format(self.pk, phid)
|
||||
rr = {
|
||||
'dpp': dpp,
|
||||
'document': ev,
|
||||
'algorithm': ALGORITHM,
|
||||
'manufacturer DPP': '',
|
||||
'device': dev.device,
|
||||
'components': dev.components
|
||||
'device': dev.build.device,
|
||||
'components': dev.build.components
|
||||
}
|
||||
|
||||
tmpl = dpp_tmpl.copy()
|
||||
|
|
|
@ -42,19 +42,6 @@ gen_env_vars() {
|
|||
export API_RESOLVER='http://id_index_api:3012'
|
||||
# TODO hardcoded
|
||||
export ID_FEDERATED='DH1'
|
||||
# propagate to .env
|
||||
dpp_env_vars="$(cat <<END
|
||||
API_DLT=${API_DLT}
|
||||
API_DLT_TOKEN=${API_DLT_TOKEN}
|
||||
API_RESOLVER=${API_RESOLVER}
|
||||
ID_FEDERATED=${ID_FEDERATED}
|
||||
END
|
||||
)"
|
||||
# generate config using env vars from docker
|
||||
# TODO rethink if this is needed because now this is django, not flask
|
||||
cat > .env <<END
|
||||
${dpp_env_vars:-}
|
||||
END
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ from dpp.models import Proof
|
|||
|
||||
|
||||
class ProofView(View):
|
||||
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
timestamp = kwargs.get("proof_id")
|
||||
proof = Proof.objects.filter(timestamp=timestamp).first()
|
||||
|
@ -22,9 +22,9 @@ class ProofView(View):
|
|||
ev = Evidence(proof.uuid)
|
||||
if not ev.doc:
|
||||
return JsonResponse({}, status=404)
|
||||
|
||||
|
||||
dev = Build(ev.doc, None, check=True)
|
||||
doc = dev.get_phid()
|
||||
doc = dev.build.get_doc()
|
||||
|
||||
data = {
|
||||
"algorithm": ALGORITHM,
|
||||
|
|
|
@ -66,4 +66,9 @@ class Build(BuildMix):
|
|||
|
||||
def _get_components(self):
|
||||
data = ParseSnapshot(self.json)
|
||||
self.device = data.device
|
||||
self.components = data.components
|
||||
|
||||
self.device.pop("actions", None)
|
||||
for c in self.components:
|
||||
c.pop("actions", None)
|
||||
|
|
|
@ -17,7 +17,7 @@ class BuildMix:
|
|||
self.chassis = ""
|
||||
self.sku = ""
|
||||
self.mac = ""
|
||||
self.tpy = ""
|
||||
self.type = ""
|
||||
self.version = ""
|
||||
self.get_details()
|
||||
self.generate_chids()
|
||||
|
@ -41,8 +41,6 @@ class BuildMix:
|
|||
|
||||
def get_doc(self):
|
||||
self._get_components()
|
||||
for c in self.components:
|
||||
c.pop("actions", None)
|
||||
|
||||
components = sorted(self.components, key=lambda x: x.get("type"))
|
||||
device = self.algorithms.get('ereuse22')
|
||||
|
@ -52,6 +50,8 @@ class BuildMix:
|
|||
for c in components:
|
||||
doc.append((c.get("type"), self.get_id_hw_dpp(c)))
|
||||
|
||||
return doc
|
||||
|
||||
def get_id_hw_dpp(self, d):
|
||||
algorithm = ALGOS.get("ereuse22", [])
|
||||
hid = ""
|
||||
|
|
|
@ -36,7 +36,9 @@ class Build(BuildMix):
|
|||
self.manufacturer = system
|
||||
self.model = get_inxi(m, "product")
|
||||
self.serial_number = get_inxi(m, "serial")
|
||||
self.chassis = get_inxi(m, "Type")
|
||||
self.type = get_inxi(m, "Type")
|
||||
self.chassis = self.type
|
||||
self.version = get_inxi(m, "v")
|
||||
else:
|
||||
self.sku = get_inxi(m, "part-nu")
|
||||
|
||||
|
@ -61,4 +63,9 @@ class Build(BuildMix):
|
|||
|
||||
def _get_components(self):
|
||||
data = ParseSnapshot(self.json)
|
||||
self.device = data.device
|
||||
self.components = data.components
|
||||
|
||||
self.device.pop("actions", None)
|
||||
for c in self.components:
|
||||
c.pop("actions", None)
|
||||
|
|
|
@ -11,12 +11,16 @@ class Build(BuildMix):
|
|||
# normaly is worbench 11
|
||||
|
||||
def get_details(self):
|
||||
device = self.json.get('device', {})
|
||||
self.manufacturer = device.get("manufacturer", '')
|
||||
self.model = device.get("model", '')
|
||||
self.chassis = device.get("chassis", '')
|
||||
self.serial_number = device.get("serialNumber", '')
|
||||
self.sku = device.get("sku", '')
|
||||
self.device = self.json.get('device', {})
|
||||
self.manufacturer = self.device.get("manufacturer", '')
|
||||
self.model = self.device.get("model", '')
|
||||
self.chassis = self.device.get("chassis", '')
|
||||
self.serial_number = self.device.get("serialNumber", '')
|
||||
self.sku = self.device.get("sku", '')
|
||||
|
||||
def _get_components(self):
|
||||
self.components = self.json.get("components", [])
|
||||
|
||||
self.device.pop("actions", None)
|
||||
for c in self.components:
|
||||
c.pop("actions", None)
|
||||
|
|
Loading…
Reference in a new issue