Skip to content

Commit

Permalink
fix requirement translation regression (#1178)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Hacene authored Dec 12, 2024
2 parents 7ccbc7e + 2bdae56 commit 12085fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
2 changes: 0 additions & 2 deletions backend/app_tests/api/test_api_requirement_assessments.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def test_get_requirement_assessments(self, test):
"str": compliance_assessment.name,
},
"requirement": {
"str": str(RequirementNode.objects.all()[0]),
"id": str(RequirementNode.objects.all()[0].id),
"urn": RequirementNode.objects.all()[0].urn,
"annotation": RequirementNode.objects.all()[0].annotation,
Expand Down Expand Up @@ -252,7 +251,6 @@ def test_update_requirement_assessments(self, test):
"str": compliance_assessment.name,
},
"requirement": {
"str": str(RequirementNode.objects.all()[0]),
"id": str(RequirementNode.objects.all()[0].id),
"urn": RequirementNode.objects.all()[0].urn,
"annotation": RequirementNode.objects.all()[0].annotation,
Expand Down
31 changes: 17 additions & 14 deletions backend/core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,26 +635,29 @@ class Meta:


class RequirementAssessmentReadSerializer(BaseModelSerializer):
class FilteredNodeSerializer(RequirementNodeReadSerializer):
class Meta:
model = RequirementNode
fields = [
"id",
"urn",
"annotation",
"name",
"description",
"typical_evidence",
"ref_id",
"associated_reference_controls",
"associated_threats",
"parent_requirement",
]

name = serializers.CharField(source="__str__")
description = serializers.CharField(source="get_requirement_description")
evidences = FieldsRelatedField(many=True)
compliance_assessment = FieldsRelatedField()
folder = FieldsRelatedField()
assessable = serializers.BooleanField(source="requirement.assessable")
requirement = FieldsRelatedField(
[
"id",
"urn",
"annotation",
"name",
"description",
"typical_evidence",
"ref_id",
"associated_reference_controls",
"associated_threats",
"parent_requirement",
]
)
requirement = FilteredNodeSerializer()

class Meta:
model = RequirementAssessment
Expand Down

0 comments on commit 12085fc

Please sign in to comment.