Skip to content

Commit

Permalink
Properly serialize selected implementation groups in ComplianceAssess…
Browse files Browse the repository at this point in the history
…mentReadSerializer
  • Loading branch information
nas-tabchiche committed May 6, 2024
1 parent eb7f768 commit c5d4b54
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,16 @@ def get_global_score(self):
return round(score["score__avg"], 1)
return -1

def get_selected_implementation_groups(self):
framework = self.framework
if not framework.implementation_groups_definition:
return []
return [
group.get("name")
for group in framework.implementation_groups_definition
if group.get("ref_id") in self.selected_implementation_groups
]

def get_requirements_status_count(self):
requirements_status_count = []
for st in RequirementAssessment.Status:
Expand Down
3 changes: 3 additions & 0 deletions backend/core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,9 @@ class ComplianceAssessmentReadSerializer(AssessmentReadSerializer):
framework = FieldsRelatedField(
["id", "min_score", "max_score", "implementation_groups_definition"]
)
selected_implementation_groups = serializers.ReadOnlyField(
source="get_selected_implementation_groups"
)

class Meta:
model = ComplianceAssessment
Expand Down

0 comments on commit c5d4b54

Please sign in to comment.