diff --git a/evidence/forms.py b/evidence/forms.py
index 2e49a6d..7eaf0ca 100644
--- a/evidence/forms.py
+++ b/evidence/forms.py
@@ -9,7 +9,6 @@ from evidence.models import Annotation
class UploadForm(forms.Form):
-
evidence_file = MultipleFileField(label=_("File"))
def clean(self):
@@ -47,3 +46,30 @@ class UploadForm(forms.Form):
for ev in self.evidences:
Build(ev[1], user)
+
+
+class UserTagForm(forms.Form):
+ tag = forms.CharField(label=_("Tag"))
+
+ def __init__(self, *args, **kwargs):
+ self.uuid = kwargs.pop('uuid', None)
+ super().__init__(*args, **kwargs)
+
+ def clean(self):
+ data = self.cleaned_data.get('tag')
+ if not data:
+ return False
+ self.tag = data
+ return True
+
+ def save(self, user, commit=True):
+ if not commit:
+ return
+
+ Annotation.objects.create(
+ uuid=self.uuid,
+ owner=user,
+ type=Annotation.Type.SYSTEM,
+ key='CUSTOM_ID',
+ value=self.tag
+ )
diff --git a/evidence/templates/ev_details.html b/evidence/templates/ev_details.html
index 2289f84..e589d2f 100644
--- a/evidence/templates/ev_details.html
+++ b/evidence/templates/ev_details.html
@@ -45,5 +45,29 @@
{% endfor %}
+
+ {% load django_bootstrap5 %}
+
+
{% endblock %}
diff --git a/evidence/views.py b/evidence/views.py
index 58a0d56..a9459e1 100644
--- a/evidence/views.py
+++ b/evidence/views.py
@@ -7,7 +7,7 @@ from django.views.generic.edit import (
from dashboard.mixins import DashboardView, Http403
from evidence.models import Evidence
-from evidence.forms import UploadForm
+from evidence.forms import UploadForm, UserTagForm
# from django.shortcuts import render
# from rest_framework import viewsets
# from snapshot.serializers import SnapshotSerializer
@@ -51,12 +51,14 @@ class UploadView(DashboardView, FormView):
response = super().form_invalid(form)
return response
-
-class EvidenceView(DashboardView, TemplateView):
+
+class EvidenceView(DashboardView, FormView):
template_name = "ev_details.html"
section = "evidences"
title = _("Evidences")
breadcrumb = "Evidences / Details"
+ success_url = reverse_lazy('evidence:list')
+ form_class = UserTagForm
def get(self, request, *args, **kwargs):
self.pk = kwargs['pk']
@@ -73,3 +75,22 @@ class EvidenceView(DashboardView, TemplateView):
'object': self.object,
})
return context
+
+ def get_form_kwargs(self):
+ self.pk = self.kwargs.get('pk')
+ kwargs = super().get_form_kwargs()
+ kwargs['uuid'] = self.pk
+ return kwargs
+
+ 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
+
+ def get_success_url(self):
+ success_url = reverse_lazy('evidence:details', args=[self.pk])
+ return success_url
diff --git a/lot/views.py b/lot/views.py
index 0045d16..280450e 100644
--- a/lot/views.py
+++ b/lot/views.py
@@ -162,7 +162,7 @@ class LotDocumentsView(DashboardView, TemplateView):
template_name = "documents.html"
title = _("New Document")
breadcrumb = "Device / New document"
-
+
def get_context_data(self, **kwargs):
self.pk = kwargs.get('pk')
context = super().get_context_data(**kwargs)
@@ -185,7 +185,7 @@ class LotAnnotationsView(DashboardView, TemplateView):
template_name = "annotations.html"
title = _("New Annotation")
breadcrumb = "Device / New annotation"
-
+
def get_context_data(self, **kwargs):
self.pk = kwargs.get('pk')
context = super().get_context_data(**kwargs)
@@ -203,7 +203,7 @@ class LotAnnotationsView(DashboardView, TemplateView):
})
return context
-
+
class LotAddAnnotationView(DashboardView, CreateView):
template_name = "new_annotation.html"
title = _("New Annotation")