model constraints changed and moved url to /device

This commit is contained in:
Thomas Nahuel Rusiecki 2024-11-15 18:15:44 -03:00
parent 10f2f6dc16
commit 04099d31a6
2 changed files with 11 additions and 5 deletions

View File

@ -28,10 +28,7 @@ class Property(models.Model):
value = models.CharField(max_length=STR_EXTEND_SIZE)
class Meta:
constraints = [
models.UniqueConstraint(
fields=["type", "key", "uuid"], name="unique_type_key_uuid")
]
#Only for shared behaviour, it is not a table
abstract = True
class SystemProperty(Property):
@ -43,6 +40,12 @@ class SystemProperty(Property):
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):
@ -55,6 +58,10 @@ class UserProperty(Property):
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>/eraseserver", views.EraseServerView.as_view(), name="erase_server"),
path("<uuid:pk>/download", views.DownloadEvidenceView.as_view(), name="download"),
path('user_property/<int:pk>/del', views.UserPropertyDeleteView.as_view(), name='delete_user_property'),
]