
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Requires #5145
Overview
Now, let's proceed with building the CommunityLibraryViewset. This viewset will manage the API interactions for creating, listing, modifying, removing, and resolving community library submissions.
Technical requirements
We will need to create a new Viewset that inherits from the ValuesViewset within a new file, contentcuration/viewsets/submission.py. This class will:
- Expose the following fields through the
values tuple: id, description, channel_id, channel_version, author_id, author__name (which needs to be mapped to author_name via field_map) , categories, date_created, and status.
- Create a model serializer that sets the CommunityLibraryViewset fields excluding
date_created, status and version.
- The channel field should be defined using our UserFilteredPrimaryKeyRelatedField class that manage the filtering for read/write access for getting the related object in our serializer (e.g. here)
date_created should be automatically set at the model level upon creation.
- A separate serializer will be used for changing the status when resolving the submission.
- The
version should be set to the current version of the channel within the serializer's create method. If the channel has not been published yet (i.e. its version is 0), throw a validation error.
- Additionally, this serializer should override the
update method to prevent modifications to the channel or author related to the submission.
- The viewset's queryset should query all submissions and order them by
date_created in descending order.
- It should include a submission filterset that allows filtering by
channel (we may expand this in the future, but as of now, this is the only filter needed)
- Permission classes should just include the IsAuthenticated permissions class
- We should optionally allow cursor pagination using our ValuesViewsetCursorPagination as our viewset's pagination_class
- Override the
consolidate method for querying the list of related countries and setting a countries list for each submission, containing only the country codes (for example here we use this consolidate method to set the languages list to the result of the channel metadata query).
We will be introducing other actions to this viewset in the future for resolving the submission, but we won't be doing this in the scope of this issue.
This new serializer should be registered in the contentcuration router with the name communitylibrary_submission
Additionally, unit tests should be added to cover at least the following scenarios:
- Successful submission creation.
- A user submitting a channel they are not an editor of.
- Inability to set the channel version on the creation request.
- Inability to create a new submission of a channel that has not been published yet.
- Successful submission editing.
- Inability to edit the status, channel or version via PUT or PATCH requests.
- GET request filtering by channel.
- GET request for a single submission by ID.
- A user requesting a submission for a channel they are not an editor of.
- An admin user being able to view a single submission even if they are not an editor of the channel.
- Successful submission deletion.
- A user trying to delete a channel they are not an editor of.
Acceptance criteria
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Requires #5145
Overview
Now, let's proceed with building the
CommunityLibraryViewset. This viewset will manage the API interactions for creating, listing, modifying, removing, and resolving community library submissions.Technical requirements
We will need to create a new Viewset that inherits from the ValuesViewset within a new file,
contentcuration/viewsets/submission.py. This class will:valuestuple:id,description,channel_id,channel_version,author_id,author__name(which needs to be mapped toauthor_nameviafield_map) ,categories,date_created, andstatus.date_created,statusandversion.date_createdshould be automatically set at the model level upon creation.versionshould be set to the current version of the channel within the serializer'screatemethod. If the channel has not been published yet (i.e. its version is 0), throw a validation error.updatemethod to prevent modifications to thechannelorauthorrelated to the submission.date_createdin descending order.channel(we may expand this in the future, but as of now, this is the only filter needed)consolidatemethod for querying the list of related countries and setting acountrieslist for each submission, containing only the country codes (for example here we use this consolidate method to set the languages list to the result of the channel metadata query).We will be introducing other actions to this viewset in the future for resolving the submission, but we won't be doing this in the scope of this issue.
This new serializer should be registered in the contentcuration router with the name
communitylibrary_submissionAdditionally, unit tests should be added to cover at least the following scenarios:
Acceptance criteria