activate/deactivate DPP from env
This commit is contained in:
parent
7f44d88b61
commit
e54d8ba49c
|
@ -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>
|
||||
|
@ -232,7 +234,8 @@
|
|||
{% endfor %}
|
||||
</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 %}
|
||||
|
||||
|
@ -257,12 +261,12 @@
|
|||
document.addEventListener('DOMContentLoaded', function () {
|
||||
// Obtener el hash de la URL (ejemplo: #components)
|
||||
const hash = window.location.hash
|
||||
|
||||
|
||||
// Verificar si hay un hash en la URL
|
||||
if (hash) {
|
||||
// Buscar el botón o enlace que corresponde al hash y activarlo
|
||||
const tabTrigger = document.querySelector(`[data-bs-target="${hash}"]`)
|
||||
|
||||
|
||||
if (tabTrigger) {
|
||||
// Crear una instancia de tab de Bootstrap para activar el tab
|
||||
const tab = new bootstrap.Tab(tabTrigger)
|
||||
|
|
|
@ -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,10 +104,12 @@ class DetailsView(DashboardView, TemplateView):
|
|||
context = super().get_context_data(**kwargs)
|
||||
self.object.initial()
|
||||
lot_tags = LotTag.objects.filter(owner=self.request.user.institution)
|
||||
dpps = Proof.objects.filter(
|
||||
uuid__in=self.object.uuids,
|
||||
type=PROOF_TYPE["IssueDPP"]
|
||||
)
|
||||
dpps = []
|
||||
if settings.DPP:
|
||||
dpps = Proof.objects.filter(
|
||||
uuid__in=self.object.uuids,
|
||||
type=PROOF_TYPE["IssueDPP"]
|
||||
)
|
||||
context.update({
|
||||
'object': self.object,
|
||||
'snapshot': self.object.get_last_evidence(),
|
||||
|
|
|
@ -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",
|
||||
|
|
10
dhub/urls.py
10
dhub/urls.py
|
@ -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')),
|
||||
path('dpp/', include('dpp.urls')),
|
||||
path('did/', include('did.urls')),
|
||||
]
|
||||
|
||||
if settings.DPP:
|
||||
urlpatterns.extend([
|
||||
path('dpp/', include('dpp.urls')),
|
||||
path('did/', include('did.urls')),
|
||||
])
|
||||
|
|
|
@ -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,7 +53,8 @@ class Build:
|
|||
|
||||
self.index()
|
||||
self.create_annotations()
|
||||
self.register_device_dlt()
|
||||
if settings.DPP:
|
||||
self.register_device_dlt()
|
||||
|
||||
def index(self):
|
||||
snap = json.dumps(self.json)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue