split into system and user properties
This commit is contained in:
parent
1732cc7a9c
commit
41926ea85a
|
@ -3,13 +3,15 @@ import json
|
||||||
from dmidecode import DMIParse
|
from dmidecode import DMIParse
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
from django.db.models import Q
|
||||||
from utils.constants import STR_EXTEND_SIZE, CHASSIS_DH
|
from utils.constants import STR_EXTEND_SIZE, CHASSIS_DH
|
||||||
from evidence.xapian import search
|
from evidence.xapian import search
|
||||||
from evidence.parse_details import ParseSnapshot
|
from evidence.parse_details import ParseSnapshot
|
||||||
from user.models import User, Institution
|
from user.models import User, Institution
|
||||||
|
|
||||||
|
#TODO: base class is abstract; revise if should be for query efficiency
|
||||||
class Annotation(models.Model):
|
class Property(models.Model):
|
||||||
class Type(models.IntegerChoices):
|
class Type(models.IntegerChoices):
|
||||||
SYSTEM = 0, "System"
|
SYSTEM = 0, "System"
|
||||||
USER = 1, "User"
|
USER = 1, "User"
|
||||||
|
@ -30,6 +32,30 @@ class Annotation(models.Model):
|
||||||
models.UniqueConstraint(
|
models.UniqueConstraint(
|
||||||
fields=["type", "key", "uuid"], name="unique_type_key_uuid")
|
fields=["type", "key", "uuid"], name="unique_type_key_uuid")
|
||||||
]
|
]
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
class SystemProperty(Property):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
constraints = [
|
||||||
|
models.CheckConstraint(
|
||||||
|
check=~Q(type=1), #Enforce that type is not User
|
||||||
|
name='property_cannot_be_user'
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
class UserProperty(Property):
|
||||||
|
|
||||||
|
type = models.SmallIntegerField(default=Property.Type.USER)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
constraints = [
|
||||||
|
models.CheckConstraint(
|
||||||
|
check=Q(type=1), #Enforce that type is User
|
||||||
|
name='property_needs_to_be_user'
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Evidence:
|
class Evidence:
|
||||||
|
|
Loading…
Reference in New Issue