Exemplo n.º 1
0
    en_retard = BooleanField()
    referentiel_action_ids = JSONField()
    referentiel_indicateur_ids = JSONField()
    titre = CharField(max_length=300)
    description = TextField()
    budget = FloatField()
    personne_referente = CharField(max_length=100)
    structure_pilote = CharField(max_length=300)
    elu_referent = CharField(max_length=300)
    partenaires = CharField(max_length=300)
    commentaire = TextField()
    date_debut = CharField(max_length=36)
    date_fin = CharField(max_length=36)
    indicateur_personnalise_ids = JSONField()
    latest = BooleanField()
    deleted = BooleanField()
    created_at = DatetimeField(auto_now_add=True)
    modified_at = DatetimeField(auto_now=True)


FicheAction_Pydantic = pydantic_model_creator(
    FicheAction,
    name="FicheAction",
)
FicheActionIn_Pydantic = pydantic_model_creator(
    FicheAction,
    name="FicheActionIn",
    exclude_readonly=True,
    exclude=("latest", "deleted"),
)
from tortoise import fields, models
from tortoise.contrib.pydantic.creator import pydantic_model_creator
from tortoise.fields.data import IntField, CharField, BooleanField, DatetimeField


class MesureCustom(models.Model):
    id = IntField(pk=True)
    uid = CharField(max_length=36)
    epci_id = CharField(max_length=36)
    climat_pratic_thematic_id = CharField(max_length=100)
    name = CharField(max_length=100)
    created_at = DatetimeField(auto_now_add=True)
    modified_at = DatetimeField(auto_now=True)


MesureCustom_Pydantic = pydantic_model_creator(MesureCustom,
                                               name="MesureCustom")
MesureCustomIn_Pydantic = pydantic_model_creator(MesureCustom,
                                                 name="MesureCustomIn",
                                                 exclude_readonly=True)
from tortoise import models
from tortoise.contrib.pydantic.creator import pydantic_model_creator
from tortoise.fields.data import (
    IntField,
    CharField,
    BooleanField,
    DatetimeField,
    JSONField,
)


class ActionMeta(models.Model):
    id = IntField(pk=True)
    action_id = CharField(max_length=36)
    epci_id = CharField(max_length=36)
    meta = JSONField()
    created_at = DatetimeField(auto_now_add=True)
    modified_at = DatetimeField(auto_now=True)
    latest = BooleanField()


ActionMeta_Pydantic = pydantic_model_creator(ActionMeta, name="ActionMeta")
ActionMetaIn_Pydantic = pydantic_model_creator(ActionMeta,
                                               name="ActionMetaIn",
                                               exclude_readonly=True,
                                               exclude=("latest", ))
Exemplo n.º 4
0
from typing import Optional
from tortoise.contrib.pydantic.creator import (
    pydantic_model_creator,
    pydantic_queryset_creator,
)
from pydantic import BaseModel, EmailStr
from app.models import User

UserPydantic = pydantic_model_creator(User)
UserPydanticList = pydantic_queryset_creator(User)


class UserCreateMe(BaseModel):
    email: EmailStr
    password: str

    class Config:
        orm_mode = True


class UserUpdateMe(BaseModel):
    password: Optional[str]
    name: Optional[str]
    family_name: Optional[str]

    class Config:
        orm_mode = True


class UserCreateBySuperuser(BaseModel):
    email: EmailStr
Exemplo n.º 5
0
from tortoise import models
from tortoise.contrib.pydantic.creator import pydantic_model_creator
from tortoise.fields.data import IntField, CharField, BooleanField, DatetimeField


class ActionStatus(models.Model):
    id = IntField(pk=True)
    action_id = CharField(max_length=36)
    epci_id = CharField(max_length=36)
    avancement = CharField(max_length=36)
    created_at = DatetimeField(auto_now_add=True)
    modified_at = DatetimeField(auto_now=True)
    latest = BooleanField()


ActionStatus_Pydantic = pydantic_model_creator(ActionStatus,
                                               name="ActionStatus")
ActionStatusIn_Pydantic = pydantic_model_creator(ActionStatus,
                                                 name="ActionStatusIn",
                                                 exclude_readonly=True,
                                                 exclude=("latest", ))
Exemplo n.º 6
0
from tortoise.fields.data import (
    IntField,
    CharField,
    BooleanField,
    DatetimeField,
    JSONField,
)


class FicheActionCategorie(models.Model):
    id = IntField(pk=True)
    epci_id = CharField(max_length=36)
    uid = CharField(max_length=36)
    parent_uid = CharField(max_length=36)
    nom = CharField(max_length=300)
    fiche_actions_uids = JSONField()
    created_at = DatetimeField(auto_now_add=True)
    modified_at = DatetimeField(auto_now=True)
    latest = BooleanField()
    deleted = BooleanField()


FicheActionCategorie_Pydantic = pydantic_model_creator(
    FicheActionCategorie, name="FicheActionCategorie")
FicheActionCategorieIn_Pydantic = pydantic_model_creator(
    FicheActionCategorie,
    name="FicheActionCategorieIn",
    exclude_readonly=True,
    exclude=("latest", "deleted"),
)
Exemplo n.º 7
0
    BooleanField,
    DatetimeField,
    JSONField,
    TextField,
)


class IndicateurPersonnalise(models.Model):
    id = IntField(pk=True)
    epci_id = CharField(max_length=36)
    uid = CharField(max_length=36)
    custom_id = CharField(max_length=36)
    nom = CharField(max_length=300)
    description = TextField()
    unite = CharField(max_length=36)
    meta = JSONField()
    created_at = DatetimeField(auto_now_add=True)
    modified_at = DatetimeField(auto_now=True)
    latest = BooleanField()
    deleted = BooleanField()


IndicateurPersonnalise_Pydantic = pydantic_model_creator(
    IndicateurPersonnalise, name="IndicateurPersonnalise")
IndicateurPersonnaliseIn_Pydantic = pydantic_model_creator(
    IndicateurPersonnalise,
    name="IndicateurPersonnaliseIn",
    exclude_readonly=True,
    exclude=("latest", "deleted"),
)
Exemplo n.º 8
0
from tortoise import models
from tortoise.contrib.pydantic.creator import pydantic_model_creator
from tortoise.fields.data import IntField, CharField, DatetimeField


class AdemeUtilisateur(models.Model):
    id = IntField(pk=True)
    ademe_user_id = CharField(max_length=300)
    email = CharField(max_length=300)
    nom = CharField(max_length=300)
    prenom = CharField(max_length=300)
    created_at = DatetimeField(auto_now_add=True)
    modified_at = DatetimeField(auto_now=True)


AdemeUtilisateur_Pydantic = pydantic_model_creator(
    AdemeUtilisateur, name="AdemeUtilisateur"
)
AdemeUtilisateurrIn_Pydantic = pydantic_model_creator(
    AdemeUtilisateur, name="AdemeUtilisateurIn", exclude_readonly=True
)
Exemplo n.º 9
0
from tortoise import models
from tortoise.contrib.pydantic.creator import pydantic_model_creator
from tortoise.fields.data import IntField, CharField, BooleanField, DatetimeField


class Epci(models.Model):
    id = IntField(pk=True)
    uid = CharField(max_length=36)
    insee = CharField(max_length=5)
    siren = CharField(max_length=9)
    nom = CharField(max_length=300)
    created_at = DatetimeField(auto_now_add=True)
    modified_at = DatetimeField(auto_now=True)
    latest = BooleanField()


Epci_Pydantic = pydantic_model_creator(Epci, name="Epci")
EpciIn_Pydantic = pydantic_model_creator(Epci,
                                         name="EpciIn",
                                         exclude_readonly=True,
                                         exclude=("latest", ))
from fastapi import APIRouter, Depends
from tortoise.contrib.fastapi import HTTPNotFoundError
from tortoise.contrib.pydantic.creator import pydantic_model_creator
from api.models.tortoise.any_indicateur_values import (
    IndicateurPersonnaliseObjectif, )
from api.models.tortoise.utilisateur_droits import UtilisateurDroits_Pydantic
from api.routers.v2.auth import get_utilisateur_droits_from_header
from api.utils.get_pydantic_in_model_creator import get_pydantic_in_model_creator
from api.utils.indicateur_value_generic_api import IndicateurValueGenericAPI

router = APIRouter(prefix="/v2/indicateur_personnalise_objectif")

IndicateurPersonnaliseObjectifIn_Pydantic = get_pydantic_in_model_creator(
    IndicateurPersonnaliseObjectif)
IndicateurPersonnaliseObjectifOut_Pydantic = pydantic_model_creator(
    IndicateurPersonnaliseObjectif)
indicateur_value_generic_api = IndicateurValueGenericAPI(
    IndicateurPersonnaliseObjectif,
    IndicateurPersonnaliseObjectifIn_Pydantic,
    IndicateurPersonnaliseObjectifOut_Pydantic,
)


@router.post("/{epci_id}",
             response_model=IndicateurPersonnaliseObjectifOut_Pydantic)
async def post_epci_indicateur_value(
    epci_id: str,
    indicateur_value: IndicateurPersonnaliseObjectifIn_Pydantic,
    droits: List[UtilisateurDroits_Pydantic] = Depends(
        get_utilisateur_droits_from_header),
):
from tortoise import fields, models
from tortoise.contrib.pydantic.creator import pydantic_model_creator
from tortoise.fields.data import (
    IntField,
    CharField,
    BooleanField,
    DatetimeField,
    TextField,
)


class IndicateurReferentielCommentaire(models.Model):
    id = IntField(pk=True)
    epci_id = CharField(max_length=36)
    indicateur_id = CharField(max_length=136)
    value = TextField()
    created_at = DatetimeField(auto_now_add=True)
    modified_at = DatetimeField(auto_now=True)
    latest = BooleanField()


IndicateurReferentielCommentaire_Pydantic = pydantic_model_creator(
    IndicateurReferentielCommentaire, name="IndicateurReferentielCommentaire"
)
IndicateurReferentielCommentaireIn_Pydantic = pydantic_model_creator(
    IndicateurReferentielCommentaire,
    name="IndicateurReferentielCommentaireIn",
    exclude_readonly=True,
    exclude=("latest",),
)
Exemplo n.º 12
0
from fastapi import Body, Form
from pydantic import BaseModel, EmailStr, Field
from tortoise.contrib.pydantic.creator import pydantic_model_creator, pydantic_queryset_creator

from .models import User
from src.app.utils.enums import UserRole


class UserBaseSchema(BaseModel):
    email: Optional[EmailStr]
    first_name: Optional[str]
    last_name: Optional[str] = None
    role: Optional[UserRole]
    password: Optional[str]


class UserCreateSchema(UserBaseSchema):
    pass


class UserUpdateSchema(UserBaseSchema):
    pass


UserDetailSchema = pydantic_model_creator(User,
                                          name='UserDetail',
                                          exclude=('password', ))
UserListSchema = pydantic_queryset_creator(User,
                                           name='UserList',
                                           exclude=('password', ))
from tortoise import models
from tortoise.contrib.pydantic.creator import pydantic_model_creator
from tortoise.fields.data import IntField, CharField, BooleanField, DatetimeField


class Utilisateur(models.Model):
    id = IntField(pk=True)
    ademe_user_id = CharField(max_length=300)
    vie_privee_conditions = CharField(max_length=300)
    created_at = DatetimeField(auto_now_add=True)
    modified_at = DatetimeField(auto_now=True)


Utilisateur_Pydantic = pydantic_model_creator(Utilisateur, name="Utilisateur")
UtilisateurIn_Pydantic = pydantic_model_creator(Utilisateur,
                                                name="UtilisateurIn",
                                                exclude_readonly=True)
from tortoise import models
from tortoise.contrib.pydantic.creator import pydantic_model_creator
from tortoise.fields.data import (
    IntField,
    CharField,
    BooleanField,
    DatetimeField,
    TextField,
)


class ActionCustom(models.Model):
    id = IntField(pk=True)
    uid = CharField(max_length=36)
    epci_id = CharField(max_length=36)
    mesure_id = CharField(max_length=36)
    name = CharField(max_length=100)
    description = TextField()
    created_at = DatetimeField(auto_now_add=True)
    modified_at = DatetimeField(auto_now=True)


ActionCustom_Pydantic = pydantic_model_creator(ActionCustom,
                                               name="ActionCustom")
ActionCustomIn_Pydantic = pydantic_model_creator(ActionCustom,
                                                 name="ActionCustomIn",
                                                 exclude_readonly=True)
Exemplo n.º 15
0
from tortoise import models
from tortoise.contrib.pydantic.creator import pydantic_model_creator
from tortoise.fields.data import IntField, CharField, BooleanField, DatetimeField


class UtilisateurDroits(models.Model):
    id = IntField(pk=True)
    ademe_user_id = CharField(max_length=300)
    epci_id = CharField(max_length=36)
    ecriture = BooleanField()
    created_at = DatetimeField(auto_now_add=True)
    modified_at = DatetimeField(auto_now=True)
    latest = BooleanField()


UtilisateurDroits_Pydantic = pydantic_model_creator(UtilisateurDroits,
                                                    name="UtilisateurDroits")
UtilisateurDroitsIn_Pydantic = pydantic_model_creator(
    UtilisateurDroits,
    name="UtilisateurDroitsIn",
    exclude_readonly=True,
    exclude=("latest", ),
)