Finishing ForeignKey Migration and handling of their None values
This commit is contained in:
@@ -1,35 +1,17 @@
|
||||
from typing import List
|
||||
from typing import List, Optional
|
||||
from html import unescape
|
||||
|
||||
from beanie import PydanticObjectId
|
||||
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
|
||||
|
||||
|
||||
class PartyTemplate(BaseModel):
|
||||
entity_id: PydanticObjectId = Field(
|
||||
foreignKey={
|
||||
"reference": {
|
||||
"resource": "entities",
|
||||
"schema": "Entity",
|
||||
}
|
||||
},
|
||||
default="",
|
||||
title="Partie"
|
||||
)
|
||||
entity_id: Optional[PydanticObjectId] = ForeignKey("entities", "Entity", default=None, title="Partie")
|
||||
part: str = Field(title="Rôle")
|
||||
representative_id: PydanticObjectId = Field(
|
||||
foreignKey={
|
||||
"reference": {
|
||||
"resource": "entities",
|
||||
"schema": "Entity",
|
||||
}
|
||||
},
|
||||
default="",
|
||||
title="Représentant"
|
||||
)
|
||||
representative_id: Optional[PydanticObjectId] = ForeignKey("entities", "Entity", default=None, title="Représentant")
|
||||
|
||||
class Config:
|
||||
title = 'Partie'
|
||||
@@ -62,14 +44,10 @@ class ProvisionTemplate(CrudDocument):
|
||||
|
||||
|
||||
class ProvisionTemplateReference(BaseModel):
|
||||
provision_template_id: PydanticObjectId = Field(
|
||||
foreignKey={
|
||||
"reference": {
|
||||
"resource": "templates/provisions",
|
||||
"schema": "ProvisionTemplate",
|
||||
"displayedFields": ['title', 'body']
|
||||
},
|
||||
},
|
||||
provision_template_id: PydanticObjectId = ForeignKey(
|
||||
"templates/provisions",
|
||||
"TemplateProvision",
|
||||
['title', 'body'],
|
||||
props={"parametrized": True},
|
||||
title="Template de clause"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user