DPP/DLT functionality #36

Merged
pedro merged 68 commits from dpp into main 2024-12-11 15:15:14 +00:00
6 changed files with 35 additions and 19 deletions
Showing only changes of commit e54d8ba49c - Show all commits

View file

@ -29,9 +29,11 @@
<li class="nav-item">
<a href="#evidences" class="nav-link" data-bs-toggle="tab" data-bs-target="#evidences">{% trans 'Evidences' %}</a>
</li>
{% if dpps %}
<li class="nav-item">
<a href="#dpps" class="nav-link" data-bs-toggle="tab" data-bs-target="#dpps">{% trans 'Dpps' %}</a>
</li>
{% endif %}
<li class="nav-item">
<a class="nav-link" href="{% url 'device:device_web' object.id %}" target="_blank">Web</a>
</li>
@ -233,6 +235,7 @@
</div>
</div>
{% if dpps %}
<div class="tab-pane fade" id="dpps">
<h5 class="card-title">{% trans 'List of dpps' %}</h5>
<div class="list-group col">
@ -249,6 +252,7 @@
{% endfor %}
</div>
</div>
{% endif %}
</div>
{% endblock %}

View file

@ -1,6 +1,5 @@
from django.http import JsonResponse
from django.http import Http404
from django.conf import settings
from django.urls import reverse_lazy
from django.shortcuts import get_object_or_404, Http404
from django.utils.translation import gettext_lazy as _
@ -13,10 +12,11 @@ from django.views.generic.base import TemplateView
from dashboard.mixins import DashboardView, Http403
from evidence.models import Annotation
from lot.models import LotTag
from dpp.models import Proof
from dpp.api_dlt import PROOF_TYPE
from device.models import Device
from device.forms import DeviceFormSet
if settings.DPP:
from dpp.models import Proof
from dpp.api_dlt import PROOF_TYPE
class NewDeviceView(DashboardView, FormView):
@ -104,6 +104,8 @@ class DetailsView(DashboardView, TemplateView):
context = super().get_context_data(**kwargs)
self.object.initial()
lot_tags = LotTag.objects.filter(owner=self.request.user.institution)
dpps = []
if settings.DPP:
dpps = Proof.objects.filter(
uuid__in=self.object.uuids,
type=PROOF_TYPE["IssueDPP"]

View file

@ -89,10 +89,13 @@ INSTALLED_APPS = [
"dashboard",
"admin",
"api",
"dpp",
"did",
]
DPP = config("DPP", default=False, cast=bool)
if DPP:
INSTALLED_APPS.extend(["dpp", "did"])
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",

View file

@ -14,7 +14,7 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.urls import path, include
urlpatterns = [
@ -27,6 +27,10 @@ urlpatterns = [
path("user/", include("user.urls")),
path("lot/", include("lot.urls")),
path('api/', include('api.urls')),
]
if settings.DPP:
urlpatterns.extend([
path('dpp/', include('dpp.urls')),
path('did/', include('did.urls')),
]
])

View file

@ -4,12 +4,14 @@ import logging
from dmidecode import DMIParse
from json_repair import repair_json
from django.conf import settings
from evidence.parse_details import get_lshw_child, ParseSnapshot
from evidence.models import Annotation
from evidence.xapian import index
from dpp.api_dlt import register_device_dlt, register_passport_dlt
from utils.constants import CHASSIS_DH
if settings.DPP:
from dpp.api_dlt import register_device_dlt, register_passport_dlt
logger = logging.getLogger('django')
@ -51,6 +53,7 @@ class Build:
self.index()
self.create_annotations()
if settings.DPP:
self.register_device_dlt()
def index(self):

View file

@ -137,7 +137,7 @@ class DownloadEvidenceView(DashboardView, TemplateView):
evidence.get_doc()
data = json.dumps(evidence.doc)
response = HttpResponse(data, content_type="application/json")
response['Content-Disposition'] = 'attachment; filename={}'.format("credential.json")
response['Content-Disposition'] = 'attachment; filename={}'.format("evidence.json")
return response