Skip to content

Commit

Permalink
fix: risk assessment generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Hacene committed Dec 20, 2024
1 parent cbe6a28 commit c2579d5
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,7 @@ def get_descendants(self) -> set[Self]:
children = self.get_children()
sub_children = set()
for child in children:
sub_children.append(child)
sub_children.add(child)
sub_children.update(child.get_descendants())
return sub_children

Expand Down
3 changes: 2 additions & 1 deletion backend/core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,11 @@ class RiskAssessmentReadSerializer(AssessmentReadSerializer):
risk_scenarios = FieldsRelatedField(many=True)
risk_scenarios_count = serializers.IntegerField(source="risk_scenarios.count")
risk_matrix = FieldsRelatedField()
ebios_rm_study = FieldsRelatedField(["id", "name"])

class Meta:
model = RiskAssessment
exclude = ["ebios_rm_study"]
exclude = []


class AssetWriteSerializer(BaseModelSerializer):
Expand Down
20 changes: 15 additions & 5 deletions backend/ebios_rm/migrations/0009_alter_roto_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,25 @@


class Migration(migrations.Migration):

dependencies = [
('ebios_rm', '0008_remove_attackpath_ro_to_couple_strategicscenario_and_more'),
("ebios_rm", "0008_remove_attackpath_ro_to_couple_strategicscenario_and_more"),
]

operations = [
migrations.AlterField(
model_name='roto',
name='activity',
field=models.PositiveSmallIntegerField(choices=[(0, 'undefined'), (1, 'very_low'), (2, 'low'), (3, 'moderate'), (4, 'important')], default=0, validators=[django.core.validators.MaxValueValidator(4)], verbose_name='Activity'),
model_name="roto",
name="activity",
field=models.PositiveSmallIntegerField(
choices=[
(0, "undefined"),
(1, "very_low"),
(2, "low"),
(3, "moderate"),
(4, "important"),
],
default=0,
validators=[django.core.validators.MaxValueValidator(4)],
verbose_name="Activity",
),
),
]
2 changes: 1 addition & 1 deletion backend/ebios_rm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ def ro_to(self):

def get_assets(self):
initial_assets = Asset.objects.filter(
feared_events__in=self.ro_to.feared_events.all(), is_selected=True
feared_events__in=self.ro_to.feared_events.filter(is_selected=True)
)
assets = set()
for asset in initial_assets:
Expand Down
2 changes: 1 addition & 1 deletion backend/ebios_rm/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def motivation(self, request):
@action(detail=False, name="Get resources choices")
def resources(self, request):
return Response(dict(RoTo.Resources.choices))

@action(detail=False, name="Get activity choices")
def activity(self, request):
return Response(dict(RoTo.Activity.choices))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,17 @@
>
</div>
<br />
<div class="text-sm">
<span class="font-semibold" data-testid="risk-matrix-field-title"
>{m.ebiosRmStudy()}:</span
>
<a
href="/ebios-rm/{risk_assessment.ebios_rm_study.id}"
class="anchor"
data-testid="ebios-rm-field-value">{risk_assessment.ebios_rm_study.name}</a
>
</div>
<br />
<div class="text-sm">
<span class="font-semibold" data-testid="description-field-title">{m.description()}:</span
>
Expand Down

0 comments on commit c2579d5

Please sign in to comment.