Skip to content

Commit

Permalink
Display risk scenarios count instead of list in risk assessment Model…
Browse files Browse the repository at this point in the history
…Table
  • Loading branch information
nas-tabchiche committed Apr 16, 2024
1 parent 7d739cd commit 4a1fc34
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
12 changes: 5 additions & 7 deletions backend/core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
class BaseModelSerializer(serializers.ModelSerializer):
def update(self, instance: models.Model, validated_data: Any) -> models.Model:
if hasattr(instance, "urn") and getattr(instance, "urn"):
raise PermissionDenied(
{"urn": "Imported objects cannot be modified"}
)
raise PermissionDenied({"urn": "Imported objects cannot be modified"})
try:
object_updated = super().update(instance, validated_data)
return object_updated
Expand Down Expand Up @@ -134,6 +132,7 @@ class Meta:

class RiskAssessmentReadSerializer(AssessmentReadSerializer):
risk_scenarios = FieldsRelatedField(many=True)
risk_scenarios_count = serializers.IntegerField(source="risk_scenarios.count")
risk_matrix = FieldsRelatedField()

class Meta:
Expand Down Expand Up @@ -162,7 +161,7 @@ class Meta:

class ReferenceControlReadSerializer(ReferenceControlWriteSerializer):
folder = FieldsRelatedField()
library = FieldsRelatedField(["name","urn"])
library = FieldsRelatedField(["name", "urn"])


class LibraryReadSerializer(BaseModelSerializer):
Expand All @@ -187,7 +186,7 @@ class Meta:

class ThreatReadSerializer(BaseModelSerializer):
folder = FieldsRelatedField()
library = FieldsRelatedField(["name","urn"])
library = FieldsRelatedField(["name", "urn"])

class Meta:
model = Threat
Expand Down Expand Up @@ -407,7 +406,7 @@ class Meta:

class FrameworkReadSerializer(BaseModelSerializer):
folder = FieldsRelatedField()
library = FieldsRelatedField(["name","urn"])
library = FieldsRelatedField(["name", "urn"])

class Meta:
model = Framework
Expand Down Expand Up @@ -503,4 +502,3 @@ class RequirementAssessmentWriteSerializer(BaseModelSerializer):
class Meta:
model = RequirementAssessment
fields = "__all__"

11 changes: 2 additions & 9 deletions frontend/src/lib/utils/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,15 @@ export const listViewFields = {
},
'risk-assessments': {
head: ['name', 'riskMatrix', 'description', 'riskScenarios', 'project'],
body: ['name', 'risk_matrix', 'description', 'risk_scenarios', 'project']
body: ['name', 'risk_matrix', 'description', 'risk_scenarios_count', 'project']
},
threats: {
head: ['ref', 'name', 'description', 'provider', 'domain'],
body: ['ref_id', 'name', 'description', 'provider', 'folder'],
meta: ['id', 'urn']
},
'risk-scenarios': {
head: [
'name',
'threats',
'riskAssessment',
'appliedControls',
'currentLevel',
'residualLevel'
],
head: ['name', 'threats', 'riskAssessment', 'appliedControls', 'currentLevel', 'residualLevel'],
body: [
'name',
'threats',
Expand Down

0 comments on commit 4a1fc34

Please sign in to comment.