Importing RJSF lib with first application

This commit is contained in:
2025-04-07 22:54:05 +02:00
parent f93a59b27e
commit 661841ceef
19 changed files with 662 additions and 24 deletions

View File

@@ -1,19 +1,19 @@
import os
from datetime import datetime
from beanie import init_beanie
from motor.motor_asyncio import AsyncIOMotorClient
from beanie import Document, PydanticObjectId
from pydantic import Field, computed_field
from hub.user import User
from hub.auth import AccessToken
MONGO_USERNAME = os.getenv("MONGO_INITDB_ROOT_USERNAME")
MONGO_PASSWORD = os.getenv("MONGO_INITDB_ROOT_PASSWORD")
class CrudDocument(Document):
_id: str
created_at: datetime = Field(default=datetime.utcnow(), nullable=False, title="Créé le")
created_by: PydanticObjectId = Field()
updated_at: datetime = Field(default_factory=datetime.utcnow, nullable=False, title="Modifié le")
updated_by: PydanticObjectId = Field()
DATABASE_URL = f"mongodb://{MONGO_USERNAME}:{MONGO_PASSWORD}@mongo:27017"
@computed_field
def label(self) -> str:
return self.compute_label()
async def init_db():
client = AsyncIOMotorClient(DATABASE_URL, uuidRepresentation="standard")
await init_beanie(database=client.hub,
document_models=[User, AccessToken],
allow_index_dropping=True)
def compute_label(self) -> str:
return ""