This commit is contained in:
Cayo Puigdefabregas 2024-11-19 18:02:43 +01:00
parent 0d574cae63
commit cc350775ed
6 changed files with 29 additions and 11 deletions

View File

@ -30,7 +30,7 @@
<a href="#evidences" class="nav-link" data-bs-toggle="tab" data-bs-target="#evidences">{% trans 'Evidences' %}</a> <a href="#evidences" class="nav-link" data-bs-toggle="tab" data-bs-target="#evidences">{% trans 'Evidences' %}</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a href="#dpps" class="nav-link" data-bs-toggle="tab" data-bs-target="#evidences">{% trans 'Dpps' %}</a> <a href="#dpps" class="nav-link" data-bs-toggle="tab" data-bs-target="#dpps">{% trans 'Dpps' %}</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="{% url 'device:device_web' object.id %}" target="_blank">Web</a> <a class="nav-link" href="{% url 'device:device_web' object.id %}" target="_blank">Web</a>
@ -242,7 +242,7 @@
<small class="text-muted">{{ d.timestamp }}</small> <small class="text-muted">{{ d.timestamp }}</small>
</div> </div>
<p class="mb-1"> <p class="mb-1">
<a href="{% url 'evidence:details' d.uuid %}">{{ d.signature }}</a> <a href="{% url 'did:device_web' d.uuid %}">{{ d.signature }}</a>
</p> </p>
</div> </div>
{% endfor %} {% endfor %}

View File

@ -104,7 +104,7 @@ class DetailsView(DashboardView, TemplateView):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
self.object.initial() self.object.initial()
lot_tags = LotTag.objects.filter(owner=self.request.user.institution) lot_tags = LotTag.objects.filter(owner=self.request.user.institution)
dpps = Proof.objects.filter(uuid_in=self.object.uuids) dpps = Proof.objects.filter(uuid__in=self.object.uuids)
context.update({ context.update({
'object': self.object, 'object': self.object,
'snapshot': self.object.get_last_evidence(), 'snapshot': self.object.get_last_evidence(),

View File

@ -90,6 +90,7 @@ INSTALLED_APPS = [
"admin", "admin",
"api", "api",
"dpp", "dpp",
"did",
] ]
@ -240,3 +241,7 @@ LOGGING = {
SNAPSHOT_PATH="/tmp/" SNAPSHOT_PATH="/tmp/"
DATA_UPLOAD_MAX_NUMBER_FILES = 1000 DATA_UPLOAD_MAX_NUMBER_FILES = 1000
COMMIT = config('COMMIT', default='') COMMIT = config('COMMIT', default='')
# DLT SETTINGS
TOKEN_DLT = config("TOKEN_DLT", default=None)
API_DLT = config("API_DLT", default=None)

View File

@ -4,7 +4,7 @@ import logging
from django.conf import settings from django.conf import settings
from ereuseapi.methods import API from ereuseapi.methods import API
from dpp.models import Proof, Dpp from dpp.models import Proof
logger = logging.getLogger('django') logger = logging.getLogger('django')
@ -31,11 +31,11 @@ PROOF_TYPE = {
def connect_api(): def connect_api():
if not settings.get('TOKEN_DLT'): if not settings.TOKEN_DLT:
return return
token_dlt = settings.get('TOKEN_DLT') token_dlt = settings.TOKEN_DLT
api_dlt = settings.get('API_DLT') api_dlt = settings.API_DLT
return API(api_dlt, token_dlt, "ethereum") return API(api_dlt, token_dlt, "ethereum")
@ -51,14 +51,14 @@ def register_dlt(chid, phid, proof_type=None):
ALGORITHM, ALGORITHM,
phid, phid,
proof_type, proof_type,
settings.get('ID_FEDERATED') settings.ID_FEDERATED
) )
return api.register_device( return api.register_device(
chid, chid,
ALGORITHM, ALGORITHM,
phid, phid,
settings.get('ID_FEDERATED') settings.ID_FEDERATED
) )
@ -72,7 +72,7 @@ def issuer_dpp_dlt(dpp):
dpp, dpp,
ALGORITHM, ALGORITHM,
phid, phid,
settings.get('ID_FEDERATED') settings.ID_FEDERATED
) )
@ -96,6 +96,11 @@ def save_proof(signature, ev_uuid, result, proof_type, user):
def register_device_dlt(chid, phid, ev_uuid, user): def register_device_dlt(chid, phid, ev_uuid, user):
token_dlt = settings.TOKEN_DLT
api_dlt = settings.API_DLT
if not token_dlt or not api_dlt:
return
cny_a = 1 cny_a = 1
while cny_a: while cny_a:
result = register_dlt(chid, phid) result = register_dlt(chid, phid)
@ -131,6 +136,11 @@ def register_device_dlt(chid, phid, ev_uuid, user):
def register_passport_dlt(chid, phid, ev_uuid, user): def register_passport_dlt(chid, phid, ev_uuid, user):
token_dlt = settings.TOKEN_DLT
api_dlt = settings.API_DLT
if not token_dlt or not api_dlt:
return
dpp = "{chid}:{phid}".format(chid=chid, phid=phid) dpp = "{chid}:{phid}".format(chid=chid, phid=phid)
if Proof.objects.filter(signature=dpp, type=PROOF_TYPE['IssueDPP']).exists(): if Proof.objects.filter(signature=dpp, type=PROOF_TYPE['IssueDPP']).exists():
return return

View File

@ -4,5 +4,5 @@ from dpp import views
app_name = 'dpp' app_name = 'dpp'
urlpatterns = [ urlpatterns = [
path("<int:proof_id>/", views.LotDashboardView.as_view(), name="proof"), path("<int:proof_id>/", views.ProofView.as_view(), name="proof"),
] ]

View File

@ -11,3 +11,6 @@ xlrd==2.0.1
odfpy==1.4.1 odfpy==1.4.1
pytz==2024.2 pytz==2024.2
json-repair==0.30.0 json-repair==0.30.0
setuptools==75.5.0
requests==2.32.3
wheel==0.45.0