:recycle: Refactor backend, settings, DB sessions, types, configs, plugins (#158)
* :recycle: Refactor backend, update DB session handling
* :sparkles: Add mypy config and plugins
* :heavy_plus_sign: Use Python-jose instead of PyJWT
as it has some extra functionalities and features
* :sparkles: Add/update scripts for test, lint, format
* :wrench: Update lint and format configs
* :art: Update import format, comments, and types
* :art: Add types to config
* :sparkles: Add types for all the code, and small fixes
* :art: Use global imports to simplify exploring with Jupyter
* :recycle: Import schemas and models, instead of each class
* :truck: Rename db_session to db for simplicity
* :pushpin: Update dependencies installation for testing
2020-04-20 19:03:13 +02:00
|
|
|
from typing import Optional
|
|
|
|
|
2020-01-19 22:40:50 +01:00
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
|
|
|
|
|
|
# Shared properties
|
|
|
|
class ItemBase(BaseModel):
|
:recycle: Refactor backend, settings, DB sessions, types, configs, plugins (#158)
* :recycle: Refactor backend, update DB session handling
* :sparkles: Add mypy config and plugins
* :heavy_plus_sign: Use Python-jose instead of PyJWT
as it has some extra functionalities and features
* :sparkles: Add/update scripts for test, lint, format
* :wrench: Update lint and format configs
* :art: Update import format, comments, and types
* :art: Add types to config
* :sparkles: Add types for all the code, and small fixes
* :art: Use global imports to simplify exploring with Jupyter
* :recycle: Import schemas and models, instead of each class
* :truck: Rename db_session to db for simplicity
* :pushpin: Update dependencies installation for testing
2020-04-20 19:03:13 +02:00
|
|
|
title: Optional[str] = None
|
|
|
|
description: Optional[str] = None
|
2020-01-19 22:40:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Properties to receive on item creation
|
|
|
|
class ItemCreate(ItemBase):
|
|
|
|
title: str
|
|
|
|
|
|
|
|
|
|
|
|
# Properties to receive on item update
|
|
|
|
class ItemUpdate(ItemBase):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
# Properties shared by models stored in DB
|
|
|
|
class ItemInDBBase(ItemBase):
|
|
|
|
id: int
|
|
|
|
title: str
|
|
|
|
owner_id: int
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
orm_mode = True
|
|
|
|
|
|
|
|
|
|
|
|
# Properties to return to client
|
|
|
|
class Item(ItemInDBBase):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
# Properties properties stored in DB
|
|
|
|
class ItemInDB(ItemInDBBase):
|
|
|
|
pass
|