Skip to content

Commit 43d0eff

Browse files
committed
Added code, tested on the api, not tested in pro-ui yet
1 parent 20c6083 commit 43d0eff

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

dojo/api_v2/serializers.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,9 @@ class FindingSerializer(serializers.ModelSerializer):
16921692
many=True, read_only=True, source="risk_acceptance_set",
16931693
)
16941694
push_to_jira = serializers.BooleanField(default=False)
1695+
found_by = serializers.PrimaryKeyRelatedField(
1696+
queryset=Test_Type.objects.all(), many=True,
1697+
)
16951698
age = serializers.IntegerField(read_only=True)
16961699
sla_days_remaining = serializers.IntegerField(read_only=True, allow_null=True)
16971700
finding_meta = FindingMetaSerializer(read_only=True, many=True)
@@ -1774,6 +1777,18 @@ def update(self, instance, validated_data):
17741777
if parsed_vulnerability_ids:
17751778
save_vulnerability_ids(instance, parsed_vulnerability_ids)
17761779

1780+
# Get found_by from validated_data
1781+
found_by = validated_data.pop("found_by", None)
1782+
1783+
# Handle updates to found_by data
1784+
if found_by:
1785+
instance.found_by.clear()
1786+
instance.found_by.add(*found_by)
1787+
# If there is no argument entered for found_by, the user would like to clear out the values on the Finding's found_by field
1788+
# Findings still maintain original found_by value associated with their test
1789+
else:
1790+
instance.found_by.clear()
1791+
17771792
instance = super().update(
17781793
instance, validated_data,
17791794
)

0 commit comments

Comments
 (0)