37 lines
736 B
Python
37 lines
736 B
Python
import uuid
|
|
from datetime import datetime
|
|
from typing import List
|
|
|
|
from pydantic import BaseModel, validator
|
|
|
|
from beanie import PydanticObjectId
|
|
|
|
from .models import Contract, ContractType, Clause
|
|
from ..entity.models import Entity
|
|
from ..core.schemas import Writer
|
|
|
|
|
|
class ContractRead(Contract):
|
|
pass
|
|
|
|
|
|
class PartyCreate(BaseModel):
|
|
entity: PydanticObjectId
|
|
part: str
|
|
|
|
|
|
class ContractCreate(Writer):
|
|
type: ContractType
|
|
parties: List[PartyCreate]
|
|
clauses: List[Clause]
|
|
|
|
async def validate_foreign_key(self):
|
|
for p in self.parties:
|
|
p.entity = await Entity.get(p.entity)
|
|
if p.entity is None:
|
|
raise ValueError
|
|
|
|
|
|
class ContractUpdate(BaseModel):
|
|
status: str
|