Skip to content

Commit

Permalink
fix pytest
Browse files Browse the repository at this point in the history
copy of score parameters in models instead of in views
  • Loading branch information
eric-intuitem committed Apr 28, 2024
1 parent e9cec9c commit f81232d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 8 additions & 0 deletions backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,14 @@ class Meta:
verbose_name = _("Compliance assessment")
verbose_name_plural = _("Compliance assessments")

def save(self, *args, **kwargs) -> None:
if self.min_score is None:
self.min_score = self.framework.min_score
self.max_score = self.framework.max_score
self.scores_definition = self.framework.scores_definition
super().save(*args, **kwargs)


def get_global_score(self):
requirement_assessments_scored = (
RequirementAssessment.objects.filter(compliance_assessment=self)
Expand Down
5 changes: 0 additions & 5 deletions backend/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1179,11 +1179,6 @@ def perform_create(self, serializer):
"""
serializer.save()
instance = ComplianceAssessment.objects.get(id=serializer.data["id"])
if instance.min_score is None:
instance.min_score = instance.framework.min_score
instance.max_score = instance.framework.max_score
instance.scores_definition = instance.framework.scores_definition
instance.save()
requirements = RequirementNode.objects.filter(framework=instance.framework)
for requirement in requirements:
RequirementAssessment.objects.create(
Expand Down

0 comments on commit f81232d

Please sign in to comment.