Skip to content

ESoCC: Add action to resolve Community Library Submissions #5170

@AlexVelezLl

Description

@AlexVelezLl

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

  1. 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.
  2. 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.

  3. For keeping admin fields available just for admins, we will create a new AdminCommunityLibrarySubmissionViewset that will inherit from the CommunityLibrarySubmissionViewset and will add the internal_notes and resolved_by fields to the class values tuple.

    • To make this values tuple reusable, we can create a base_community_library_submission_values variable 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.
  4. We will add a new resolve action in the Admin Community Library Submission Viewset. This will handle a post request 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, and internal_notes fields.
    • The status can be set just to APPROVED or REJECTED and when the status is being set to REJECTED, the feedback_notes and resolution_reason become 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.
  5. 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.

  6. Additionally, unit tests should be added to cover at least the following scenarios:

    • Just admins can resolve submissions.
    • Just admins can see the internal_notes and resolved_by fields.
    • The status field can just set to APPROVED or REJECTED.
    • 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 pending submissions are set as superseded. 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.

Metadata

Metadata

Assignees

Labels

P0 - criticalPriority: Release blocker or regression

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions