renaming to property

This commit is contained in:
Thomas Nahuel Rusiecki 2024-11-13 21:05:54 -03:00
parent bfe922bed6
commit 2a9eca74eb
6 changed files with 14 additions and 13 deletions

View File

@ -96,7 +96,7 @@ class SearchView(InventaryMixin):
qry |= Q(value__startswith=i) qry |= Q(value__startswith=i)
chids = SystemProperty.objects.filter( chids = SystemProperty.objects.filter(
type=Annotation.Type.SYSTEM, type=Property.Type.SYSTEM,
owner=self.request.user.institution owner=self.request.user.institution
).filter( ).filter(
qry qry

View File

@ -59,7 +59,7 @@ class BaseDeviceFormSet(forms.BaseFormSet):
path_name = save_in_disk(doc, self.user.institution.name, place="placeholder") path_name = save_in_disk(doc, self.user.institution.name, place="placeholder")
create_index(doc, self.user) 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") move_json(path_name, self.user.institution.name, place="placeholder")
return doc return doc

View File

@ -105,7 +105,8 @@ class Device:
properties = self.get_properties() properties = self.get_properties()
if not properties.count(): if not properties.count():
return return
property = property.first() property = properties.first()
self.last_evidence = Evidence(property.uuid) self.last_evidence = Evidence(property.uuid)
def is_eraseserver(self): def is_eraseserver(self):
@ -135,7 +136,7 @@ class Device:
def get_unassigned(cls, institution, offset=0, limit=None): def get_unassigned(cls, institution, offset=0, limit=None):
sql = """ sql = """
WITH RankedAnnotations AS ( WITH RankedProperties AS (
SELECT SELECT
t1.value, t1.value,
t1.key, t1.key,
@ -158,7 +159,7 @@ class Device:
SELECT DISTINCT SELECT DISTINCT
value value
FROM FROM
RankedAnnotations RankedProperties
WHERE WHERE
row_num = 1 row_num = 1
""".format( """.format(
@ -258,7 +259,7 @@ class Device:
cursor.execute(sql) cursor.execute(sql)
properties = cursor.fetchall() properties = cursor.fetchall()
return cls(id=annotations[0][0]) return cls(id=properties[0][0])
@property @property
def is_websnapshot(self): def is_websnapshot(self):

View File

@ -179,17 +179,17 @@ class AddUserPropertyView(DashboardView, CreateView):
form.instance.owner = self.request.user.institution form.instance.owner = self.request.user.institution
form.instance.user = self.request.user form.instance.user = self.request.user
form.instance.uuid = self.annotation.uuid form.instance.uuid = self.annotation.uuid
form.instance.type = Annotation.Type.USER form.instance.type = Property.Type.USER
response = super().form_valid(form) response = super().form_valid(form)
return response return response
def get_form_kwargs(self): def get_form_kwargs(self):
pk = self.kwargs.get('pk') pk = self.kwargs.get('pk')
institution = self.request.user.institution institution = self.request.user.institution
self.annotation = Annotation.objects.filter( self.annotation = SystemProperty.objects.filter(
owner=institution, owner=institution,
value=pk, value=pk,
type=Annotation.Type.SYSTEM type=Property.Type.SYSTEM
).first() ).first()
if not self.annotation: if not self.annotation:
@ -222,7 +222,7 @@ class AddDocumentView(DashboardView, CreateView):
self.annotation = SystemProperty.objects.filter( self.annotation = SystemProperty.objects.filter(
owner=institution, owner=institution,
value=pk, value=pk,
type=Annotation.Type.SYSTEM type=Property.Type.SYSTEM
).first() ).first()
if not self.annotation: if not self.annotation:

View File

@ -164,7 +164,7 @@ class ImportForm(forms.Form):
table = [] table = []
for row in self.rows: for row in self.rows:
doc = create_doc(row) doc = create_doc(row)
annotation = create_annotation(doc, self.user) annotation = create_property(doc, self.user)
table.append((doc, annotation)) table.append((doc, annotation))
if commit: if commit:
@ -222,7 +222,7 @@ class EraseServerForm(forms.Form):
if self.instance: if self.instance:
return return
Annotation.objects.create( SystemProperty.objects.create(
uuid=self.uuid, uuid=self.uuid,
type=Annotation.Type.ERASE_SERVER, type=Annotation.Type.ERASE_SERVER,
key='ERASE_SERVER', key='ERASE_SERVER',

View File

@ -70,7 +70,7 @@ class Command(BaseCommand):
def build_placeholder(self, s, user, f_path): def build_placeholder(self, s, user, f_path):
try: try:
create_index(s, user) create_index(s, user)
create_annotation(s, user, commit=True) create_property(s, user, commit=True)
except Exception as err: except Exception as err:
txt = "In placeholder %s \n%s" txt = "In placeholder %s \n%s"
logger.warning(txt, f_path, err) logger.warning(txt, f_path, err)