Skip to content

Implement Article Model, Schemas, and Decorators #5

Open
@bryanwong8

Description

@bryanwong8

Is your feature request related to a problem? Please describe.
Need to create Article Schemas for serialization and validation. Also need to create decorators to not allow users to access a non-existing Article.

Describe the solution you'd like
Create Decorators and Schemas for Article.

Routes/functions to implement/change

  • Create the article_exists decorator
  • Create the ArticleFormSchema, ArticleSchema and ArticlesSchema.

Additional context

  • Create the Article model in models.py with the following fields:
  • title: text (nullable=False)
  • cover_image: text (nullable=True)
  • content: text (nullable=False)
  • date_published: Date (nullable=False)
  • likes: int (nullable=False, default=0)
  • is_published (nullable=False)
  • The article_exists decorator should take the query id from the route and query for the Article. If the Article exists return the args and kwargs. If not return a 404 message saying that "Article does not exist".
  • Create the ArticleFormSchema class to contain the following fields:
  • title (required)
  • cover_image (not required)
  • content (not required)
  • Create the ArticleSchema that has the following fields:
    • id
  • You can create the ArticlesSchema by using the ArticleSchema, but set it to return many models instead.

Metadata

Metadata

Assignees

Labels

backendbackend featurestagingThis issues is in the staging branch

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions