Initializable Firm
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from typing import Any
|
||||
|
||||
from beanie import PydanticObjectId
|
||||
from pydantic import Field
|
||||
|
||||
from firm.core.models import CrudDocument
|
||||
@@ -8,12 +9,11 @@ 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()
|
||||
instance: str = Field()
|
||||
firm: str = Field()
|
||||
entity_id: PydanticObjectId = Field()
|
||||
primary_color: str = Field()
|
||||
secondary_color: str = Field()
|
||||
|
||||
def __eq__(self, other: Any) -> bool:
|
||||
if isinstance(other, dict):
|
||||
@@ -21,10 +21,10 @@ class CurrentFirmModel(CrudDocument):
|
||||
return super().__eq__(other)
|
||||
|
||||
def compute_label(self) -> str:
|
||||
return self.name
|
||||
return f"{self.instance} / {self.firm}"
|
||||
|
||||
@classmethod
|
||||
async def get(cls, db):
|
||||
async def get_current(cls, db):
|
||||
document = await cls._get_collection(db).find_one({})
|
||||
if not document:
|
||||
return None
|
||||
@@ -39,7 +39,15 @@ class CurrentFirmSchemaRead(Reader):
|
||||
class CurrentFirmSchemaCreate(Writer):
|
||||
corporation: EntityCorporationCreate = Field(title="Informations sur la firme")
|
||||
owner: EntityIndividualCreate = Field(title="Informations sur le dirigeant")
|
||||
position: str = Field(title="Poste")
|
||||
|
||||
primary_color: str = Field()
|
||||
secondary_color: str = Field()
|
||||
|
||||
|
||||
class CurrentFirmSchemaUpdate(Writer):
|
||||
pass
|
||||
|
||||
class Partner(CrudDocument):
|
||||
user_id: PydanticObjectId = Field()
|
||||
entity_id: PydanticObjectId = Field()
|
||||
|
||||
Reference in New Issue
Block a user