Skip to content

ESoCC: Create CommunityLibrarySubmission model #5145

@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.

Overview

Let's start with the Easy Sharing of Community Library with one of its most basic blocks: the data model for the "Community Library Submission" entity.

This entity will encapsulate all the information related to a single request for a channel to be included in our Community Library.

Channels in the Community Library will have special metadata, such as target countries and the subjects it contains. This metadata, once approved, will be applied to the Community Library Channel.

Technical requirements

We will need to create a new Django model in contentcuration/models.py that will include the following fields:

  • Description: A detailed explanation of the reason for submitting the channel to the Community Library.
  • Channel: A foreign key to the Channel model, linking to the channel associated with the submission. (Required)
  • Channel version: A positive integer field that describes the specific version of the channel being submitted for review. (Required)
  • Author: A foreign key to the User model, referencing the user who initiated the channel submission for review. (Required)
  • Countries (optional): We will need to create a Country table and have a many-to-many relationship. For now, let's just create the model; populating this table will be addressed in a separate task. This table will contain:
    • code: Primary Key - The Alpha-2 code of the country.
    • name: The name in English of the country.
  • Categories: A text field for storing categories, separated by commas.
  • Date created: A datetime field for storing the timestamp of when the submission was created.
  • Status: A ChoiceEnum that will contain:
    • Pending: The initial and default status of a ContentLibrarySubmission
    • Flagged: Indicates the submission has been flagged for review, meaning the sender should review and correct any noted issues.
    • Approved: The submission has been approved, but the channel is not yet published in the Community Library.
    • Live: The submission has been approved and the channel is already published in the Community Library.

Constraints:

  • The channel and channel_version fields must be unique together.

There will be other fields related to the resolution of the Community Library but we won't address it for now.

Additionally, we will need to override these class methods:

  • filter_view_queryset: Admins can view all submissions. Users can only view submissions for channels they are authorized to edit (i.e., by checking User.editable_channels) (e.g. here).
  • filter_edit_queryset: Admins can edit all submissions. Otherwise, only the user who sent the submission can edit it, also checking that user is also an editor of the channel being submitted (e.g. here).

Finally, we should add some smoke tests for the model instance creation, and add unit tests for the filter_view_queryset and filter_edit_queryset methods (e.g. here).

Acceptance criteria

  • A new CommunityLibraySubmission model has been created with the described fields and methods.
  • We have the corresponding migrations for this new model.
  • Described unit tests have been added.

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions