Skip to content

Commit

Permalink
Fix Policies queryset
Browse files Browse the repository at this point in the history
  • Loading branch information
nas-tabchiche committed Feb 28, 2024
1 parent d5cd947 commit c9cc54e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

########################### Referential objects #########################


class ReferentialObjectMixin(NameDescriptionMixin, FolderMixin):
"""
Mixin for referential objects.
Expand Down Expand Up @@ -355,6 +356,7 @@ class Meta:

########################### Domain objects #########################


class Project(NameDescriptionMixin, FolderMixin):
PRJ_LC_STATUS = [
("undefined", _("--")),
Expand Down Expand Up @@ -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)
Expand All @@ -672,7 +677,7 @@ def save(self, *args, **kwargs):


########################### Secondary objects #########################


class Assessment(NameDescriptionMixin):
class Status(models.TextChoices):
Expand Down Expand Up @@ -1408,7 +1413,7 @@ class Meta:


########################### RiskAcesptance is a domain object relying on secondary objects #########################


class RiskAcceptance(NameDescriptionMixin, FolderMixin):
ACCEPTANCE_STATE = [
Expand Down Expand Up @@ -1495,4 +1500,3 @@ def set_state(self, state):
elif state == "revoked":
self.revoked_at = datetime.now()
self.save()

0 comments on commit c9cc54e

Please sign in to comment.