diff --git a/dashboard/templates/unassigned_devices.html b/dashboard/templates/unassigned_devices.html
index d54e450..867dcdc 100644
--- a/dashboard/templates/unassigned_devices.html
+++ b/dashboard/templates/unassigned_devices.html
@@ -20,9 +20,9 @@
{% trans 'Exports' %}
{% if lot %}
-
+
- {% trans 'Annotations' %}
+ {% trans 'properties' %}
{% endif %}
diff --git a/lot/models.py b/lot/models.py
index 6c81bfd..53f2acd 100644
--- a/lot/models.py
+++ b/lot/models.py
@@ -7,8 +7,8 @@ from utils.constants import (
)
from user.models import User, Institution
+from device.models import Property
# from device.models import Device
-# from evidence.models import Annotation
class LotTag(models.Model):
@@ -45,17 +45,6 @@ class Lot(models.Model):
for d in DeviceLot.objects.filter(lot=self, device_id=v):
d.delete()
+class LotProperty (Property):
-class LotAnnotation(models.Model):
- class Type(models.IntegerChoices):
- SYSTEM= 0, "System"
- USER = 1, "User"
- DOCUMENT = 2, "Document"
-
- created = models.DateTimeField(auto_now_add=True)
lot = models.ForeignKey(Lot, on_delete=models.CASCADE)
- owner = models.ForeignKey(Institution, on_delete=models.CASCADE)
- user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True)
- type = models.SmallIntegerField(choices=Type)
- key = models.CharField(max_length=STR_EXTEND_SIZE)
- value = models.CharField(max_length=STR_EXTEND_SIZE)
diff --git a/lot/templates/new_annotation.html b/lot/templates/new_property.html
similarity index 100%
rename from lot/templates/new_annotation.html
rename to lot/templates/new_property.html
diff --git a/lot/templates/annotations.html b/lot/templates/properties.html
similarity index 83%
rename from lot/templates/annotations.html
rename to lot/templates/properties.html
index 7e6747e..fec72b4 100644
--- a/lot/templates/annotations.html
+++ b/lot/templates/properties.html
@@ -11,15 +11,15 @@
-
Annotations
+
Properties
@@ -31,7 +31,7 @@
- {% for a in annotations %}
+ {% for a in properties %}
{{ a.key }} |
{{ a.value }} |
diff --git a/lot/urls.py b/lot/urls.py
index eb863b0..806a311 100644
--- a/lot/urls.py
+++ b/lot/urls.py
@@ -12,6 +12,6 @@ urlpatterns = [
path("tag//", views.LotsTagsView.as_view(), name="tag"),
path("/document/", views.LotDocumentsView.as_view(), name="documents"),
path("/document/add", views.LotAddDocumentView.as_view(), name="add_document"),
- path("/annotation", views.LotAnnotationsView.as_view(), name="annotations"),
- path("/annotation/add", views.LotAddAnnotationView.as_view(), name="add_annotation"),
+ path("/property", views.LotPropertiesView.as_view(), name="properties"),
+ path("/property/add", views.LotAddPropertyView.as_view(), name="add_property"),
]
diff --git a/lot/views.py b/lot/views.py
index 182aade..36f582f 100644
--- a/lot/views.py
+++ b/lot/views.py
@@ -9,9 +9,9 @@ from django.views.generic.edit import (
FormView,
)
from dashboard.mixins import DashboardView
-from lot.models import Lot, LotTag, LotAnnotation
+from lot.models import Lot, LotTag, LotProperty
from lot.forms import LotsForm
-
+from device.models import Property
class NewLotView(DashboardView, CreateView):
template_name = "new_lot.html"
@@ -143,18 +143,18 @@ class LotsTagsView(DashboardView, TemplateView):
class LotAddDocumentView(DashboardView, CreateView):
- template_name = "new_annotation.html"
+ template_name = "new_property.html"
title = _("New Document")
breadcrumb = "Device / New document"
success_url = reverse_lazy('dashboard:unassigned_devices')
- model = LotAnnotation
+ model = LotProperty
fields = ("key", "value")
def form_valid(self, form):
form.instance.owner = self.request.user.institution
form.instance.user = self.request.user
form.instance.lot = self.lot
- form.instance.type = LotAnnotation.Type.DOCUMENT
+ form.instance.type = Property.Type.DOCUMENT
response = super().form_valid(form)
return response
@@ -169,16 +169,16 @@ class LotAddDocumentView(DashboardView, CreateView):
class LotDocumentsView(DashboardView, TemplateView):
template_name = "documents.html"
title = _("New Document")
- breadcrumb = "Device / New document"
+ breadcrumb = "Devicce / New document"
def get_context_data(self, **kwargs):
self.pk = kwargs.get('pk')
context = super().get_context_data(**kwargs)
lot = get_object_or_404(Lot, owner=self.request.user.institution, id=self.pk)
- documents = LotAnnotation.objects.filter(
+ documents = LotProperty.objects.filter(
lot=lot,
owner=self.request.user.institution,
- type=LotAnnotation.Type.DOCUMENT,
+ type=Property.Type.DOCUMENT,
)
context.update({
'lot': lot,
@@ -189,48 +189,48 @@ class LotDocumentsView(DashboardView, TemplateView):
return context
-class LotAnnotationsView(DashboardView, TemplateView):
- template_name = "annotations.html"
- title = _("New Annotation")
- breadcrumb = "Device / New annotation"
+class LotPropertiesView(DashboardView, TemplateView):
+ template_name = "properties.html"
+ title = _("New Lot Property")
+ breadcrumb = "Lot / New property"
def get_context_data(self, **kwargs):
self.pk = kwargs.get('pk')
context = super().get_context_data(**kwargs)
lot = get_object_or_404(Lot, owner=self.request.user.institution, id=self.pk)
- annotations = LotAnnotation.objects.filter(
+ properties = LotProperty.objects.filter(
lot=lot,
owner=self.request.user.institution,
- type=LotAnnotation.Type.USER,
+ type=Property.Type.USER,
)
context.update({
'lot': lot,
- 'annotations': annotations,
+ 'properties': properties,
'title': self.title,
'breadcrumb': self.breadcrumb
})
return context
-class LotAddAnnotationView(DashboardView, CreateView):
- template_name = "new_annotation.html"
- title = _("New Annotation")
- breadcrumb = "Device / New annotation"
+class LotAddPropertyView(DashboardView, CreateView):
+ template_name = "new_property.html"
+ title = _("New Lot Property")
+ breadcrumb = "Device / New property"
success_url = reverse_lazy('dashboard:unassigned_devices')
- model = LotAnnotation
+ model = LotProperty
fields = ("key", "value")
def form_valid(self, form):
form.instance.owner = self.request.user.institution
form.instance.user = self.request.user
form.instance.lot = self.lot
- form.instance.type = LotAnnotation.Type.USER
+ form.instance.type = Property.Type.USER
response = super().form_valid(form)
return response
def get_form_kwargs(self):
pk = self.kwargs.get('pk')
self.lot = get_object_or_404(Lot, pk=pk, owner=self.request.user.institution)
- self.success_url = reverse_lazy('lot:annotations', args=[pk])
+ self.success_url = reverse_lazy('lot:properties', args=[pk])
kwargs = super().get_form_kwargs()
return kwargs