fix(api): Enable to set recommendation
and decision
in risk_acceptance
#12303
+4
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Until now, the API endpoint


POST /api/v2/risk_acceptance/
(which also applies toPUT
andPATCH
) has not acceptedrecommendation
anddecision
. As a result, DD used the default value (fix for recommendation and accept for decision). There was no error message.For
GET
requests, DD translated the chosen value (one ofA
,V
,M
,F
,T
) to human-readable form.It sounds nice, but not if it means that fields are not writable.
Solution
This PR dropped

SerializerMethodField
s withget_...
methods, which locked these fields to read-only mode. Now, during the creation of RiskAcc, the user is able to definerecommendation
anddecision
.But
The only "disadvantage" is that it is now unable to see a human-readable form anymore.

No buts
APIs are not for humans but for machines, so simple values should not be the issue.
Translation is still possible based on the description in the OpenAPI spec:
or