Compare commits

...

3 Commits

7 changed files with 18 additions and 17 deletions

View File

@ -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

View File

@ -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

View File

@ -95,17 +95,18 @@ class Device:
key__in=algos,
).values_list("value", flat=True)))
def get_properties(self):
def get_evidences(self):
if not self.uuids:
self.get_uuids()
self.properties = [SystemProperty(u) for u in self.uuids]
self.evidences = [Evidence(u) for u in self.uuids]
def get_last_evidence(self):
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):

View File

@ -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:

View File

@ -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',

View File

@ -5,7 +5,7 @@ import logging
from django.core.management.base import BaseCommand
from django.conf import settings
from utils.device import create_annotation, create_doc, create_index
from utils.device import create_property, create_doc, create_index
from user.models import Institution
from evidence.parse import Build
@ -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)

View File

@ -6,7 +6,7 @@ from dmidecode import DMIParse
from json_repair import repair_json
from evidence.parse_details import get_lshw_child
from evidence.models import SystemProperty
from evidence.models import SystemProperty, Property
from evidence.xapian import index
from utils.constants import CHASSIS_DH