-
Notifications
You must be signed in to change notification settings - Fork 291
Description
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Requires: #5157
Overview
As part of this issue, we will be building the action admins will use to resolve Community library submissions, i.e., approve or flag for review a submission.
Technical requirements
-
We'll be adding these new fields to the Community Library Submission model:
- Resolved by: FK to the user who resolved that submission. In the Community Library Submission Viewset, we won't expose this field for non-admin users.
- Resolution reason: a ChoiceEnum reason for the given resolution - For now, it will only apply for Flagged resolutions, with these possible values:
- Invalid licensing
- Technical quality assurance
- invalid metadata
- portability issues
- other
- Feedback notes: Feedback notes the admin give when resolving a submission for the user who sent the submission.
- Internal notes - Internal notes for admins to know why the submission was approved/rejected. We won't expose this field for non-admin users.
- Date resolved - A Datetime field for storing the timestamp of when it was resolved.
-
We will add a new status to the CommunityLibrarySubmission model: Superseded. This status will be set to submissions that has been superseded by a more recent submission that has been approved.
-
For keeping admin fields available just for admins, we will create a new
AdminCommunityLibrarySubmissionViewsetthat will inherit from theCommunityLibrarySubmissionViewsetand will add theinternal_notesandresolved_byfields to the classvaluestuple.- To make this
valuestuple reusable, we can create abase_community_library_submission_valuesvariable at module level with the common values for both viewset, and in the admin viewset add the only-admins fields. (e.g. here). - For this viewset, we will use the IsAdminUser permission class.
- To make this
-
We will add a new
resolveaction in the Admin Community Library Submission Viewset. This will handle apostrequest for a given submission to approve or reject the submission.- Admins will be able to override the values we already have in the submission as part of this request, like adding a category or modifying the countries. So for this request, we will create a different serializer that will extend/reuse the current Submission Serializer fields we have for the viewset, and add the
status,resolution_reason,feedback_notes, andinternal_notesfields. - The status can be set just to
APPROVEDorREJECTEDand when the status is being set toREJECTED, thefeedback_notesandresolution_reasonbecome required fields. - We can just resolve submissions that currently have the status =
PENDING. If we try resolving a submission that has already been approved, rejected or superseded, we will return a 400 error.
- Admins will be able to override the values we already have in the submission as part of this request, like adding a category or modifying the countries. So for this request, we will create a different serializer that will extend/reuse the current Submission Serializer fields we have for the viewset, and add the
-
If the user approve a submission. All previous pending submissions should be marked as
superseded. This won't happen when the admin flag for review a submission, as a previous version can still be compliant to be added to the community library. -
Additionally, unit tests should be added to cover at least the following scenarios:
- Just admins can resolve submissions.
- Just admins can see the
internal_notesandresolved_byfields. - The
statusfield can just set toAPPROVEDorREJECTED. - An admin trying to resolve an already rejected, approved or superseded submission should get an error.
- If the admin is rejecting a submission without sending feedback notes or a resolution reason, a validation error is returned.
- A successful approval submission scenario, checking that resolved_by and date_resolved have been set.
- A successful rejection submission scenario.
- A successful resolution scenario where the admin overwrote the countries or categories fields.
- If the admin approves a submission, all previous
pendingsubmissions are set assuperseded. But more recent pending submissions remains with its status. - If a submission is flagged for review, check that all previous pending submissions are still pending.
Acceptance criteria
- The new resolution fields have been added to the CommunityLibray Model.
- The new resolve action has been added to the CommunityLibrayViewset.
- Described unit tests have been added.
