Adding multi tenant check and Starting firm initialization

This commit is contained in:
2025-04-12 18:12:56 +02:00
parent 9ef599bbd5
commit c7e946f963
14 changed files with 205 additions and 39 deletions

View File

@@ -0,0 +1,45 @@
from typing import Any
from pydantic import Field
from firm.core.models import CrudDocument
from firm.core.schemas import Writer, Reader
from firm.entity.schemas import EntityIndividualCreate, EntityCorporationCreate
class CurrentFirmModel(CrudDocument):
instance: str
firm: str
name: str = Field(nullable=False)
# primary_color: str = Field()
# secondary_color: str = Field()
def __eq__(self, other: Any) -> bool:
if isinstance(other, dict):
return self.instance == other["instance"] and self.firm == other["firm"]
return super().__eq__(other)
def compute_label(self) -> str:
return self.name
@classmethod
async def get(cls, db):
document = await cls._get_collection(db).find_one({})
if not document:
return None
document["id"] = document.pop("_id")
return cls.model_validate(document)
class CurrentFirmSchemaRead(Reader):
pass
class CurrentFirmSchemaCreate(Writer):
corporation: EntityCorporationCreate = Field(title="Informations sur la firme")
owner: EntityIndividualCreate = Field(title="Informations sur le dirigeant")
class CurrentFirmSchemaUpdate(Writer):
pass