xapian #1
|
@ -114,7 +114,7 @@
|
|||
</a>
|
||||
<ul class="flex-column mb-2 ul_sidebar accordion-collapse {% if section == 'People' %}expanded{% else %}collapse{% endif %}" id="ul_evidences" data-bs-parent="#sidebarMenu">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link{% if path == 'admin_people_list' %} active2{% endif %}" href="{# url 'idhub:admin_people_list' #}">
|
||||
<a class="nav-link{% if path == 'admin_people_list' %} active2{% endif %}" href="{% url 'evidence:upload' %}">
|
||||
{% trans 'Upload one' %}
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -7,18 +7,22 @@
|
|||
<h3>{{ subtitle }}</h3>
|
||||
</div>
|
||||
<div class="col text-center">
|
||||
{% if lot %}
|
||||
<a href="{% url 'lot:documents' object.id %}" type="button" class="btn btn-green-admin">
|
||||
<i class="bi bi-folder2"></i>
|
||||
{% trans 'Documents' %}
|
||||
</a>
|
||||
{% endif %}
|
||||
<a href="{# url 'idhub:admin_people_activate' object.id #}" type="button" class="btn btn-green-admin">
|
||||
<i class="bi bi-reply"></i>
|
||||
{% trans 'Exports' %}
|
||||
</a>
|
||||
{% if lot %}
|
||||
<a href="{% url 'lot:annotations' object.id %}" type="button" class="btn btn-green-admin">
|
||||
<i class="bi bi-tag"></i>
|
||||
{% trans 'Annotations' %}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -31,8 +31,10 @@ class LotDashboardView(InventaryMixin, DetailsMixin):
|
|||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
devices = self.get_devices()
|
||||
lot = context.get('object')
|
||||
context.update({
|
||||
'devices': devices,
|
||||
'lot': lot,
|
||||
})
|
||||
return context
|
||||
|
||||
|
|
|
@ -1,8 +1,33 @@
|
|||
import json
|
||||
|
||||
from django import forms
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from evidence.parse import Build
|
||||
|
||||
|
||||
class UploadForm(forms.Form):
|
||||
|
||||
evidence_file = forms.FileField(label=_("File"))
|
||||
|
||||
def clean(self):
|
||||
data = self.cleaned_data
|
||||
data = self.cleaned_data.get('evidence_file')
|
||||
if not data:
|
||||
return False
|
||||
|
||||
self.file_name = data.name
|
||||
self.file_data = data.read()
|
||||
if not self.file_name or not self.file_data:
|
||||
return False
|
||||
try:
|
||||
self.file_json = json.loads(self.file_data)
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def save(self, user, commit=True):
|
||||
if not commit or not user:
|
||||
return
|
||||
|
||||
evidence = Build(self.file_json, user)
|
||||
return evidence
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h3>{{ subtitle }}</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% load django_bootstrap5 %}
|
||||
<form role="form" method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{% if form.errors %}
|
||||
<div class="alert alert-danger alert-icon alert-icon-border alert-dismissible" role="alert">
|
||||
<div class="icon"><span class="mdi mdi-close-circle-o"></span></div>
|
||||
<div class="message">
|
||||
{% for field, error in form.errors.items %}
|
||||
{{ error }}<br />
|
||||
{% endfor %}
|
||||
<button class="btn-close" type="button" data-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% bootstrap_form form %}
|
||||
<div class="form-actions-no-box">
|
||||
<a class="btn btn-grey" href="{% url 'dashboard:unassigned_devices' %}">{% translate "Cancel" %}</a>
|
||||
<input class="btn btn-green-admin" type="submit" name="submit" value="{% translate 'Save' %}" />
|
||||
</div>
|
||||
|
||||
</form>
|
||||
{% endblock %}
|
|
@ -15,4 +15,5 @@ app_name = 'evidence'
|
|||
|
||||
urlpatterns = [
|
||||
path("", views.ListEvidencesView.as_view(), name="list"),
|
||||
path("upload", views.UploadView.as_view(), name="upload"),
|
||||
]
|
||||
|
|
|
@ -9,7 +9,7 @@ from django.views.generic.edit import (
|
|||
|
||||
from dashboard.mixins import DashboardView
|
||||
from evidence.models import Evidence, Annotation
|
||||
# from snapshot.forms import UploadForm
|
||||
from evidence.forms import UploadForm
|
||||
# from django.shortcuts import render
|
||||
# from rest_framework import viewsets
|
||||
# from snapshot.serializers import SnapshotSerializer
|
||||
|
@ -36,10 +36,19 @@ class ListEvidencesView(DashboardView, TemplateView):
|
|||
return context
|
||||
|
||||
|
||||
# class UploadView(DashboardView, FormView):
|
||||
# template_name = "upload.html"
|
||||
# section = "snapshots"
|
||||
# title = _("Upload Snapshot")
|
||||
# breadcrumb = "Snapshots / Upload"
|
||||
# success_url = reverse_lazy('snashot:list')
|
||||
# form_class = UploadForm
|
||||
class UploadView(DashboardView, FormView):
|
||||
template_name = "upload.html"
|
||||
section = "evidences"
|
||||
title = _("Upload Evidence")
|
||||
breadcrumb = "Evidences / Upload"
|
||||
success_url = reverse_lazy('evidence:list')
|
||||
form_class = UploadForm
|
||||
|
||||
def form_valid(self, form):
|
||||
form.save(self.request.user)
|
||||
response = super().form_valid(form)
|
||||
return response
|
||||
|
||||
def form_invalid(self, form):
|
||||
response = super().form_invalid(form)
|
||||
return response
|
||||
|
|
Loading…
Reference in New Issue