activate/deactivate DPP from env
This commit is contained in:
parent
7f44d88b61
commit
e54d8ba49c
|
@ -29,9 +29,11 @@
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<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>
|
||||||
|
{% if dpps %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a href="#dpps" class="nav-link" data-bs-toggle="tab" data-bs-target="#dpps">{% trans 'Dpps' %}</a>
|
<a href="#dpps" class="nav-link" data-bs-toggle="tab" data-bs-target="#dpps">{% trans 'Dpps' %}</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% endif %}
|
||||||
<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>
|
||||||
</li>
|
</li>
|
||||||
|
@ -232,7 +234,8 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if dpps %}
|
||||||
<div class="tab-pane fade" id="dpps">
|
<div class="tab-pane fade" id="dpps">
|
||||||
<h5 class="card-title">{% trans 'List of dpps' %}</h5>
|
<h5 class="card-title">{% trans 'List of dpps' %}</h5>
|
||||||
<div class="list-group col">
|
<div class="list-group col">
|
||||||
|
@ -249,6 +252,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -257,12 +261,12 @@
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
// Obtener el hash de la URL (ejemplo: #components)
|
// Obtener el hash de la URL (ejemplo: #components)
|
||||||
const hash = window.location.hash
|
const hash = window.location.hash
|
||||||
|
|
||||||
// Verificar si hay un hash en la URL
|
// Verificar si hay un hash en la URL
|
||||||
if (hash) {
|
if (hash) {
|
||||||
// Buscar el botón o enlace que corresponde al hash y activarlo
|
// Buscar el botón o enlace que corresponde al hash y activarlo
|
||||||
const tabTrigger = document.querySelector(`[data-bs-target="${hash}"]`)
|
const tabTrigger = document.querySelector(`[data-bs-target="${hash}"]`)
|
||||||
|
|
||||||
if (tabTrigger) {
|
if (tabTrigger) {
|
||||||
// Crear una instancia de tab de Bootstrap para activar el tab
|
// Crear una instancia de tab de Bootstrap para activar el tab
|
||||||
const tab = new bootstrap.Tab(tabTrigger)
|
const tab = new bootstrap.Tab(tabTrigger)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
|
from django.conf import settings
|
||||||
from django.http import Http404
|
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.shortcuts import get_object_or_404, Http404
|
from django.shortcuts import get_object_or_404, Http404
|
||||||
from django.utils.translation import gettext_lazy as _
|
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 dashboard.mixins import DashboardView, Http403
|
||||||
from evidence.models import Annotation
|
from evidence.models import Annotation
|
||||||
from lot.models import LotTag
|
from lot.models import LotTag
|
||||||
from dpp.models import Proof
|
|
||||||
from dpp.api_dlt import PROOF_TYPE
|
|
||||||
from device.models import Device
|
from device.models import Device
|
||||||
from device.forms import DeviceFormSet
|
from device.forms import DeviceFormSet
|
||||||
|
if settings.DPP:
|
||||||
|
from dpp.models import Proof
|
||||||
|
from dpp.api_dlt import PROOF_TYPE
|
||||||
|
|
||||||
|
|
||||||
class NewDeviceView(DashboardView, FormView):
|
class NewDeviceView(DashboardView, FormView):
|
||||||
|
@ -104,10 +104,12 @@ 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(
|
dpps = []
|
||||||
uuid__in=self.object.uuids,
|
if settings.DPP:
|
||||||
type=PROOF_TYPE["IssueDPP"]
|
dpps = Proof.objects.filter(
|
||||||
)
|
uuid__in=self.object.uuids,
|
||||||
|
type=PROOF_TYPE["IssueDPP"]
|
||||||
|
)
|
||||||
context.update({
|
context.update({
|
||||||
'object': self.object,
|
'object': self.object,
|
||||||
'snapshot': self.object.get_last_evidence(),
|
'snapshot': self.object.get_last_evidence(),
|
||||||
|
|
|
@ -89,10 +89,13 @@ INSTALLED_APPS = [
|
||||||
"dashboard",
|
"dashboard",
|
||||||
"admin",
|
"admin",
|
||||||
"api",
|
"api",
|
||||||
"dpp",
|
|
||||||
"did",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
DPP = config("DPP", default=False, cast=bool)
|
||||||
|
|
||||||
|
if DPP:
|
||||||
|
INSTALLED_APPS.extend(["dpp", "did"])
|
||||||
|
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
"django.middleware.security.SecurityMiddleware",
|
"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
|
1. Import the include() function: from django.urls import include, path
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
|
from django.conf import settings
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
@ -27,6 +27,10 @@ urlpatterns = [
|
||||||
path("user/", include("user.urls")),
|
path("user/", include("user.urls")),
|
||||||
path("lot/", include("lot.urls")),
|
path("lot/", include("lot.urls")),
|
||||||
path('api/', include('api.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 dmidecode import DMIParse
|
||||||
from json_repair import repair_json
|
from json_repair import repair_json
|
||||||
|
from django.conf import settings
|
||||||
from evidence.parse_details import get_lshw_child, ParseSnapshot
|
from evidence.parse_details import get_lshw_child, ParseSnapshot
|
||||||
|
|
||||||
from evidence.models import Annotation
|
from evidence.models import Annotation
|
||||||
from evidence.xapian import index
|
from evidence.xapian import index
|
||||||
from dpp.api_dlt import register_device_dlt, register_passport_dlt
|
|
||||||
from utils.constants import CHASSIS_DH
|
from utils.constants import CHASSIS_DH
|
||||||
|
if settings.DPP:
|
||||||
|
from dpp.api_dlt import register_device_dlt, register_passport_dlt
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger('django')
|
logger = logging.getLogger('django')
|
||||||
|
@ -51,7 +53,8 @@ class Build:
|
||||||
|
|
||||||
self.index()
|
self.index()
|
||||||
self.create_annotations()
|
self.create_annotations()
|
||||||
self.register_device_dlt()
|
if settings.DPP:
|
||||||
|
self.register_device_dlt()
|
||||||
|
|
||||||
def index(self):
|
def index(self):
|
||||||
snap = json.dumps(self.json)
|
snap = json.dumps(self.json)
|
||||||
|
|
|
@ -137,7 +137,7 @@ class DownloadEvidenceView(DashboardView, TemplateView):
|
||||||
evidence.get_doc()
|
evidence.get_doc()
|
||||||
data = json.dumps(evidence.doc)
|
data = json.dumps(evidence.doc)
|
||||||
response = HttpResponse(data, content_type="application/json")
|
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
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue