From c9cc54e094b37dc44d77a0157151ab4c3db0f562 Mon Sep 17 00:00:00 2001 From: Nassim Tabchiche Date: Wed, 28 Feb 2024 12:41:24 +0100 Subject: [PATCH] Fix Policies queryset --- backend/core/models.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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() -