generateur_v3/backend/api_old/config.py

59 lines
2.3 KiB
Python
Raw Normal View History

2022-09-16 21:50:55 +02:00
from tortoise.contrib.pydantic import pydantic_model_creator
from database.decorators import as_form
from database.auth.models import UserModel
from database.exercices.models import Exercice, Tag
from database.room.models import Room, Parcours, AnonymousMember
from tortoise import Tortoise
Tortoise.init_models(['database.exercices.models',
'database.auth.models', "database.room.models"], "models")
Exercice_schema = pydantic_model_creator(Exercice, name="exercice", include=[
"name", "tags", 'id_code', "consigne", 'pdfSupport', "csvSupport", 'examples'])
ExerciceIn_schema = pydantic_model_creator(
Exercice, name="exerciceIn", exclude_readonly=True, exclude=['id_code', 'exo_source', "tags_id", 'author_id', 'origin'])
Exo_schema = pydantic_model_creator(Exercice, name="exerciceszzz", include=[
'name', 'id_code', 'tags'])
@as_form
class ExerciceIn_form(ExerciceIn_schema):
pass
Tag_schema = pydantic_model_creator(Tag, name="tag", exclude=['owner', "id", ])
TagIn_schema = pydantic_model_creator(
Tag, name="tagIn", exclude_readonly=True, exclude=['owner_id'])
User_schema = pydantic_model_creator(UserModel, name='users', include=[
'username', 'email', "name", "firstname"])
UserIn_schema = pydantic_model_creator(
UserModel, name='usersIn', exclude_readonly=True)
@as_form
class UserIn_Form(UserIn_schema):
pass
Room_schema = pydantic_model_creator(
Room, name='room', include=["id", 'name', 'id_code'])
RoomIn_schema = pydantic_model_creator(Room, name='roomIn', exclude_readonly=True, exclude=[
'created_at', 'online', 'id_code', 'users_waiters'])
Anonymous_schema = pydantic_model_creator(
AnonymousMember, name='anonymousMember')
AnonymousIn_schema = pydantic_model_creator(
AnonymousMember, name='anonymousMemberIn', exclude_readonly=True, exclude=['id_code', 'room_id'])
Parcours_schema = pydantic_model_creator(Parcours, name='parcours')
ParcoursIn_schema = pydantic_model_creator(
Parcours, name='parcoursIn', exclude_readonly=True)
SECRET_KEY = "6323081020d8939e6385dd688a26cbca0bb34ed91997959167637319ba4f6f3e"
ALGORITHM = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES = 30