diff --git a/backend/core/models.py b/backend/core/models.py index c46f296de..5069db3c7 100644 --- a/backend/core/models.py +++ b/backend/core/models.py @@ -22,6 +22,7 @@ ########################### Referential objects ######################### + class ReferentialObjectMixin(NameDescriptionMixin, FolderMixin): """ Mixin for referential objects. @@ -355,6 +356,7 @@ class Meta: ########################### Domain objects ######################### + class Project(NameDescriptionMixin, FolderMixin): PRJ_LC_STATUS = [ ("undefined", _("--")), @@ -653,6 +655,9 @@ def get_linked_requirements_count(self): class PolicyManager(models.Manager): + def get_queryset(self): + return super().get_queryset().filter(category="policy") + def create(self, *args, **kwargs): kwargs["category"] = "policy" # Ensure category is always "policy" return super().create(*args, **kwargs) @@ -672,7 +677,7 @@ def save(self, *args, **kwargs): ########################### Secondary objects ######################### - + class Assessment(NameDescriptionMixin): class Status(models.TextChoices): @@ -1408,7 +1413,7 @@ class Meta: ########################### RiskAcesptance is a domain object relying on secondary objects ######################### - + class RiskAcceptance(NameDescriptionMixin, FolderMixin): ACCEPTANCE_STATE = [ @@ -1495,4 +1500,3 @@ def set_state(self, state): elif state == "revoked": self.revoked_at = datetime.now() self.save() -