Skip to content

Commit

Permalink
filter selected implementation groups in table mode (#960)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Hacene authored Nov 14, 2024
2 parents 9d3c9c2 + 273e8a6 commit e4cc3cd
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2242,7 +2242,7 @@ def get_selected_implementation_groups(self):
if group.get("ref_id") in self.selected_implementation_groups
]

def get_requirement_assessments(self, include_non_assessable=False):
def get_requirement_assessments(self, include_non_assessable: bool):
"""
Returns sorted assessable requirement assessments based on the selected implementation groups.
If include_non_assessable is True, it returns all requirements regardless of their assessable status.
Expand Down
1 change: 1 addition & 0 deletions backend/core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ class RequirementAssessmentReadSerializer(BaseModelSerializer):
evidences = FieldsRelatedField(many=True)
compliance_assessment = FieldsRelatedField()
folder = FieldsRelatedField()
assessable = serializers.BooleanField(source="requirement.assessable")

class Meta:
model = RequirementAssessment
Expand Down
16 changes: 10 additions & 6 deletions backend/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1805,9 +1805,11 @@ def action_plan(self, request, pk):
"active": [],
"deprecated": [],
}
compliance_assessment_object = self.get_object()
compliance_assessment_object: ComplianceAssessment = self.get_object()
requirement_assessments_objects = (
compliance_assessment_object.get_requirement_assessments()
compliance_assessment_object.get_requirement_assessments(
include_non_assessable=True
)
)
applied_controls = [
{
Expand Down Expand Up @@ -1920,9 +1922,11 @@ def action_plan_pdf(self, request, pk):
"--": "#e5e7eb",
}
status = AppliedControl.Status.choices
compliance_assessment_object = self.get_object()
compliance_assessment_object: ComplianceAssessment = self.get_object()
requirement_assessments_objects = (
compliance_assessment_object.get_requirement_assessments()
compliance_assessment_object.get_requirement_assessments(
include_non_assessable=True
)
)
applied_controls = (
AppliedControl.objects.filter(
Expand Down Expand Up @@ -2090,8 +2094,8 @@ def tree(self, request, pk):
@action(detail=True, methods=["get"])
def requirements_list(self, request, pk):
"""Returns the list of requirement assessments for the different audit modes"""
requirement_assessments_objects = (
self.get_object().get_requirement_assessments()
requirement_assessments_objects = self.get_object().get_requirement_assessments(
include_non_assessable=True
)
requirements_objects = RequirementNode.objects.filter(
framework=self.get_object().framework
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ export const load = (async ({ fetch, params }) => {
}
);
const observationBuffer = requirementAssessment.observation;
const assessable = true;
return {
...requirementAssessment,
evidenceCreateForm,
observationBuffer,
assessable
observationBuffer
};
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
</div>
</div>
{/if}
{#each data.requirements as requirementAssessment}
{#each data.requirement_assessments as requirementAssessment}
<div
class="flex flex-col items-center justify-center border pb-2 px-2 shadow-lg rounded-md space-y-2"
>
Expand Down

0 comments on commit e4cc3cd

Please sign in to comment.