Finishing ForeignKey Migration and handling of their None values
This commit is contained in:
@@ -27,11 +27,11 @@ class ContractDraftStatus(str, Enum):
|
|||||||
|
|
||||||
|
|
||||||
class DraftParty(BaseModel):
|
class DraftParty(BaseModel):
|
||||||
entity_id: PydanticObjectId = ForeignKey("entities", "Entity", default="", title="Partie")
|
entity_id: Optional[PydanticObjectId] = ForeignKey("entities", "Entity", default=None, title="Partie")
|
||||||
entity: SkipJsonSchema[Entity] = Field(default=None, exclude=True, )
|
|
||||||
part: str = Field(title="Rôle")
|
part: str = Field(title="Rôle")
|
||||||
representative_id: PydanticObjectId = ForeignKey("entities", "Entity", default="", title="Représentant")
|
representative_id: Optional[PydanticObjectId] = ForeignKey("entities", "Entity", default=None, title="Représentant")
|
||||||
|
|
||||||
|
entity: SkipJsonSchema[Entity] = Field(default=None, exclude=True, )
|
||||||
class Config:
|
class Config:
|
||||||
title = 'Partie'
|
title = 'Partie'
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ class ContractProvisionTemplateReference(BaseModel):
|
|||||||
"ProvisionTemplate",
|
"ProvisionTemplate",
|
||||||
displayed_fields=['title', 'body'],
|
displayed_fields=['title', 'body'],
|
||||||
props={"parametrized": True},
|
props={"parametrized": True},
|
||||||
default="",
|
default=None,
|
||||||
title="Template de clause"
|
title="Template de clause"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from typing import List, Literal, Optional
|
|||||||
from pydantic import Field, BaseModel
|
from pydantic import Field, BaseModel
|
||||||
from beanie import Indexed, PydanticObjectId
|
from beanie import Indexed, PydanticObjectId
|
||||||
|
|
||||||
from firm.core.models import CrudDocument
|
from firm.core.models import CrudDocument, ForeignKey
|
||||||
from firm.core.filter import Filter, FilterSchema
|
from firm.core.filter import Filter, FilterSchema
|
||||||
|
|
||||||
|
|
||||||
@@ -39,16 +39,7 @@ class Individual(EntityType):
|
|||||||
|
|
||||||
class Employee(BaseModel):
|
class Employee(BaseModel):
|
||||||
position: Indexed(str) = Field(title='Poste')
|
position: Indexed(str) = Field(title='Poste')
|
||||||
entity_id: PydanticObjectId = Field(
|
entity_id: PydanticObjectId = ForeignKey("entities", "Entity", title='Employé')
|
||||||
foreignKey={
|
|
||||||
"reference": {
|
|
||||||
"resource": "entities",
|
|
||||||
"schema": "Entity",
|
|
||||||
"condition": "entity_data.type=individual"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
title='Employé'
|
|
||||||
)
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
title = 'Fiche Employé'
|
title = 'Fiche Employé'
|
||||||
|
|||||||
@@ -1,35 +1,17 @@
|
|||||||
from typing import List
|
from typing import List, Optional
|
||||||
from html import unescape
|
from html import unescape
|
||||||
|
|
||||||
from beanie import PydanticObjectId
|
from beanie import PydanticObjectId
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
from firm.core.models import CrudDocument, RichtextMultiline, RichtextSingleline, DictionaryEntry
|
from firm.core.models import CrudDocument, RichtextMultiline, RichtextSingleline, DictionaryEntry, ForeignKey
|
||||||
from firm.core.filter import Filter, FilterSchema
|
from firm.core.filter import Filter, FilterSchema
|
||||||
|
|
||||||
|
|
||||||
class PartyTemplate(BaseModel):
|
class PartyTemplate(BaseModel):
|
||||||
entity_id: PydanticObjectId = Field(
|
entity_id: Optional[PydanticObjectId] = ForeignKey("entities", "Entity", default=None, title="Partie")
|
||||||
foreignKey={
|
|
||||||
"reference": {
|
|
||||||
"resource": "entities",
|
|
||||||
"schema": "Entity",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
default="",
|
|
||||||
title="Partie"
|
|
||||||
)
|
|
||||||
part: str = Field(title="Rôle")
|
part: str = Field(title="Rôle")
|
||||||
representative_id: PydanticObjectId = Field(
|
representative_id: Optional[PydanticObjectId] = ForeignKey("entities", "Entity", default=None, title="Représentant")
|
||||||
foreignKey={
|
|
||||||
"reference": {
|
|
||||||
"resource": "entities",
|
|
||||||
"schema": "Entity",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
default="",
|
|
||||||
title="Représentant"
|
|
||||||
)
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
title = 'Partie'
|
title = 'Partie'
|
||||||
@@ -62,14 +44,10 @@ class ProvisionTemplate(CrudDocument):
|
|||||||
|
|
||||||
|
|
||||||
class ProvisionTemplateReference(BaseModel):
|
class ProvisionTemplateReference(BaseModel):
|
||||||
provision_template_id: PydanticObjectId = Field(
|
provision_template_id: PydanticObjectId = ForeignKey(
|
||||||
foreignKey={
|
"templates/provisions",
|
||||||
"reference": {
|
"TemplateProvision",
|
||||||
"resource": "templates/provisions",
|
['title', 'body'],
|
||||||
"schema": "ProvisionTemplate",
|
|
||||||
"displayedFields": ['title', 'body']
|
|
||||||
},
|
|
||||||
},
|
|
||||||
props={"parametrized": True},
|
props={"parametrized": True},
|
||||||
title="Template de clause"
|
title="Template de clause"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user