WIP: rework/properties #31

Draft
rskthomas wants to merge 19 commits from rework/properties into main
2 changed files with 11 additions and 5 deletions
Showing only changes of commit b7d7b9041d - Show all commits

View File

@ -28,10 +28,7 @@ class Property(models.Model):
value = models.CharField(max_length=STR_EXTEND_SIZE) value = models.CharField(max_length=STR_EXTEND_SIZE)
class Meta: class Meta:
constraints = [ #Only for shared behaviour, it is not a table
models.UniqueConstraint(
fields=["type", "key", "uuid"], name="unique_type_key_uuid")
]
abstract = True abstract = True
class SystemProperty(Property): class SystemProperty(Property):
@ -43,6 +40,12 @@ class SystemProperty(Property):
name='property_cannot_be_user' name='property_cannot_be_user'
), ),
] ]
#Django orm wont inherit constraints to child
#TODO: check if this is needed
constraints = [
models.UniqueConstraint(
fields=["type", "key", "uuid"], name="system_unique_type_key_uuid")
]
class UserProperty(Property): class UserProperty(Property):
@ -55,6 +58,10 @@ class UserProperty(Property):
name='property_needs_to_be_user' name='property_needs_to_be_user'
), ),
] ]
constraints = [
models.UniqueConstraint(
fields=["type", "key", "uuid"], name="user_unique_type_key_uuid")
]

View File

@ -20,5 +20,4 @@ urlpatterns = [
path("<uuid:pk>", views.EvidenceView.as_view(), name="details"), path("<uuid:pk>", views.EvidenceView.as_view(), name="details"),
path("<uuid:pk>/eraseserver", views.EraseServerView.as_view(), name="erase_server"), path("<uuid:pk>/eraseserver", views.EraseServerView.as_view(), name="erase_server"),
path("<uuid:pk>/download", views.DownloadEvidenceView.as_view(), name="download"), path("<uuid:pk>/download", views.DownloadEvidenceView.as_view(), name="download"),
path('user_property/<int:pk>/del', views.UserPropertyDeleteView.as_view(), name='delete_user_property'),
] ]