diff --git a/dashboard/views.py b/dashboard/views.py index 9b1be56..2cf0a62 100644 --- a/dashboard/views.py +++ b/dashboard/views.py @@ -96,7 +96,7 @@ class SearchView(InventaryMixin): qry |= Q(value__startswith=i) chids = SystemProperty.objects.filter( - type=Annotation.Type.SYSTEM, + type=Property.Type.SYSTEM, owner=self.request.user.institution ).filter( qry diff --git a/device/forms.py b/device/forms.py index b69bc9e..1fd1f0b 100644 --- a/device/forms.py +++ b/device/forms.py @@ -59,7 +59,7 @@ class BaseDeviceFormSet(forms.BaseFormSet): path_name = save_in_disk(doc, self.user.institution.name, place="placeholder") create_index(doc, self.user) - create_annotation(doc, user, commit=commit) + create_property(doc, user, commit=commit) move_json(path_name, self.user.institution.name, place="placeholder") return doc diff --git a/device/models.py b/device/models.py index 42f6426..717af74 100644 --- a/device/models.py +++ b/device/models.py @@ -105,7 +105,8 @@ class Device: properties = self.get_properties() if not properties.count(): return - property = property.first() + property = properties.first() + self.last_evidence = Evidence(property.uuid) def is_eraseserver(self): @@ -135,7 +136,7 @@ class Device: def get_unassigned(cls, institution, offset=0, limit=None): sql = """ - WITH RankedAnnotations AS ( + WITH RankedProperties AS ( SELECT t1.value, t1.key, @@ -158,7 +159,7 @@ class Device: SELECT DISTINCT value FROM - RankedAnnotations + RankedProperties WHERE row_num = 1 """.format( @@ -258,7 +259,7 @@ class Device: cursor.execute(sql) properties = cursor.fetchall() - return cls(id=annotations[0][0]) + return cls(id=properties[0][0]) @property def is_websnapshot(self): diff --git a/device/views.py b/device/views.py index 9dd5cc0..45ff289 100644 --- a/device/views.py +++ b/device/views.py @@ -179,17 +179,17 @@ class AddUserPropertyView(DashboardView, CreateView): form.instance.owner = self.request.user.institution form.instance.user = self.request.user form.instance.uuid = self.annotation.uuid - form.instance.type = Annotation.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') institution = self.request.user.institution - self.annotation = Annotation.objects.filter( + self.annotation = SystemProperty.objects.filter( owner=institution, value=pk, - type=Annotation.Type.SYSTEM + type=Property.Type.SYSTEM ).first() if not self.annotation: @@ -222,7 +222,7 @@ class AddDocumentView(DashboardView, CreateView): self.annotation = SystemProperty.objects.filter( owner=institution, value=pk, - type=Annotation.Type.SYSTEM + type=Property.Type.SYSTEM ).first() if not self.annotation: diff --git a/evidence/forms.py b/evidence/forms.py index fb9d28d..30611c1 100644 --- a/evidence/forms.py +++ b/evidence/forms.py @@ -164,7 +164,7 @@ class ImportForm(forms.Form): table = [] for row in self.rows: doc = create_doc(row) - annotation = create_annotation(doc, self.user) + annotation = create_property(doc, self.user) table.append((doc, annotation)) if commit: @@ -222,7 +222,7 @@ class EraseServerForm(forms.Form): if self.instance: return - Annotation.objects.create( + SystemProperty.objects.create( uuid=self.uuid, type=Annotation.Type.ERASE_SERVER, key='ERASE_SERVER', diff --git a/evidence/management/commands/reindex.py b/evidence/management/commands/reindex.py index af3e35d..bf4a49c 100644 --- a/evidence/management/commands/reindex.py +++ b/evidence/management/commands/reindex.py @@ -70,7 +70,7 @@ class Command(BaseCommand): def build_placeholder(self, s, user, f_path): try: create_index(s, user) - create_annotation(s, user, commit=True) + create_property(s, user, commit=True) except Exception as err: txt = "In placeholder %s \n%s" logger.warning(txt, f_path, err)