Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Policies queryset #86

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()

Loading