flaskapp.models package

Submodules

flaskapp.models.catalog module

class flaskapp.models.catalog.CatalogModel(**kwargs)[source]

Bases: Base

ORM class for catalog objects.

filepath
classmethod find_all_query(db: Session) Query[source]

Returns all catalog objects.

Parameters:

db (Session) – The database session in which to execute the query.

Returns:

The query for finding all catalog objects present in the database.

Return type:

Query

classmethod find_by_id_query(db: Session, id: str) Query[source]

Returns a catalog object associated with given id.

Parameters:
  • db (Session) – The database session in which to execute the query.

  • id (str) – The id of the required catalog object.

Returns:

The query for finding catalog object by id.

Return type:

Query

id
save(db: Session) None[source]

Save a catalog object.

Parameters:

db (Session) – The database session in which to execute the query.

status

flaskapp.models.category module

class flaskapp.models.category.CategoryModel(**kwargs)[source]

Bases: Base

ORM class for category objects.

classmethod find_all_children_query(db: Session, category_id: int)[source]

Returns all immediate children of a given category.

Parameters:
  • db (Session) – The database session in which to execute the query.

  • category_id (int) – The id of the category object whose children are required.

Returns:

The query for finding all immediate children of category object of given id.

Return type:

Query

classmethod find_all_query(db: Session) Query[source]

Returns all category objects.

Parameters:

db (Session) – The database session in which to execute the query.

Returns:

The query for finding all category objects present in the database.

Return type:

Query

classmethod find_by_id_query(db: Session, id: int) Query[source]

Returns a category object associated with given id.

Parameters:
  • db (Session) – The database session in which to execute the query.

  • id (int) – The id of the required category object.

Returns:

The query for finding category object by id.

Return type:

Query

classmethod find_by_level_query(db: Session, level: int) Query[source]

Returns all category objects belonging to given level.

Parameters:
  • db (Session) – The database session in which to execute the query.

  • level (int) – The category level of the required category objects.

Returns:

The query for finding all category objects of the given level.

Return type:

Query

classmethod find_if_exists_query(db: Session, parent_id: Optional[int] = None, name: Optional[str] = None, level: Optional[int] = None) Query[source]

Check existence of a given category object.

Parameters:
  • db (Session) – The database session in which to execute the query.

  • parent_id (int, optional) – The parent id of the category object.

  • name (str, optional) – The name of the category object.

  • level (int, optional) – The level of the category object.

Returns:

The query for returning all matching objects.

Return type:

Query

id
level
name
parent_id
product_category
save(db: Session) None[source]

Save a category object.

Parameters:

db (Session) – The database session in which to execute the query.

flaskapp.models.color module

class flaskapp.models.color.ColorModel(**kwargs)[source]

Bases: Base

ORM class for color objects.

product
product_color
product_id

flaskapp.models.product module

class flaskapp.models.product.ProductModel(**kwargs)[source]

Bases: Base

ORM class for product objects.

availability
categories
colors
classmethod count(q: Query) int[source]

Calculate total number of products resulting from a query.

Parameters:

q (Query) – The query for which number of products need to be calculated.

Returns:

The number of products resulting from the query.

Return type:

int

classmethod find_all_query(db: Session) Query[source]

Returns all product objects.

Parameters:

db (Session) – The database session in which to execute the query.

Returns:

The query for finding all product objects present in the database.

Return type:

Query

classmethod find_by_category_id_query(db: Session, category_id: int) Query[source]

Returns all product objects belonging to a specific category.

Parameters:
  • db (Session) – The database session in which to execute the query.

  • category_id (int) – The id of the category of the required products.

Returns:

The query for finding all product objects belonging to a specific category.

Return type:

Query

classmethod find_by_id_query(db: Session, id: str) Query[source]

Returns a product object associated with given id.

Parameters:
  • db (Session) – The database session in which to execute the query.

  • id (str) – The id of the required product object.

Returns:

The query for finding product object by id.

Return type:

Query

id
imageURL
classmethod order_by_price_query(q: Query, reverse: Optional[bool] = False) Query[source]

Orders queried products by price.

Parameters:
  • q (Query) – The query whose results need to be ordered.

  • reverse (bool, optional) – If reverse is True, sort in descending order else in ascending order. Defaults to False.

Returns:

The query for ordering results of the original query.

Return type:

Query

classmethod paginate_query(q: Query, rows: int, page: int) Query[source]

Paginates resulting products.

Parameters:
  • q (Query) – The query whose results need to be paginated.

  • rows (int) – Number of products to display at a time on a single page.

  • page (int) – Offset or page number from which products are displayed.

Returns:

The query for paginating results of the original query.

Return type:

Query

price
productDescription
save(db: Session) None[source]

Save a product object.

Parameters:

db (Session) – The database session in which to execute the query.

sizes
title

flaskapp.models.product_category module

class flaskapp.models.product_category.ProductCategoryModel(**kwargs)[source]

Bases: Base

ORM class for product-category association objects.

category
category_id
product
product_id

flaskapp.models.size module

class flaskapp.models.size.SizeModel(**kwargs)[source]

Bases: Base

ORM class for size objects.

product
product_id
product_size

Module contents