changed models and schemasa
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
from typing import List, Optional
|
||||
from pydantic import BaseModel, EmailStr, constr
|
||||
from pydantic import BaseModel, EmailStr, constr, Field
|
||||
from datetime import date
|
||||
|
||||
|
||||
@ -35,9 +35,11 @@ class DataCollectionParameters(BaseModel):
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class Results(BaseModel):
|
||||
# Define attributes for Results here
|
||||
pass # Placeholder for now, should be expanded later with actual fields
|
||||
pass
|
||||
|
||||
|
||||
# Contact Person schemas
|
||||
class ContactPersonBase(BaseModel):
|
||||
@ -57,12 +59,14 @@ class ContactPerson(ContactPersonBase):
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class ContactPersonUpdate(BaseModel):
|
||||
firstname: str | None = None
|
||||
lastname: str | None = None
|
||||
phone_number: str | None = None
|
||||
email: EmailStr | None = None
|
||||
|
||||
|
||||
# Address schemas
|
||||
class AddressCreate(BaseModel):
|
||||
street: str
|
||||
@ -77,21 +81,31 @@ class Address(AddressCreate):
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class AddressUpdate(BaseModel):
|
||||
street: str | None = None
|
||||
city: str | None = None
|
||||
zipcode: str | None = None
|
||||
country: str | None = None
|
||||
|
||||
# Sample schemas
|
||||
|
||||
class Sample(BaseModel):
|
||||
id: int
|
||||
sample_name: str
|
||||
data_collection_parameters: Optional[DataCollectionParameters] = None
|
||||
results: Optional[Results] = None
|
||||
position: int # Position within the puck
|
||||
puck_id: int
|
||||
crystalname: Optional[str] = Field(None)
|
||||
positioninpuck: Optional[int] = Field(None)
|
||||
|
||||
|
||||
class SampleCreate(BaseModel):
|
||||
sample_name: str = Field(..., alias="crystalname")
|
||||
position: int = Field(..., alias="positioninpuck")
|
||||
data_collection_parameters: DataCollectionParameters
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
populate_by_name = True
|
||||
|
||||
|
||||
|
||||
# Puck schemas
|
||||
@ -102,7 +116,7 @@ class PuckBase(BaseModel):
|
||||
|
||||
|
||||
class PuckCreate(PuckBase):
|
||||
positions: List[int] = []
|
||||
pass
|
||||
|
||||
|
||||
class PuckUpdate(BaseModel):
|
||||
@ -110,12 +124,15 @@ class PuckUpdate(BaseModel):
|
||||
puck_type: Optional[str] = None
|
||||
puck_location_in_dewar: Optional[int] = None
|
||||
dewar_id: Optional[int] = None
|
||||
positions: Optional[List[int]] = None
|
||||
|
||||
|
||||
class Puck(PuckBase):
|
||||
class Puck(BaseModel):
|
||||
id: int
|
||||
positions: List[Sample] = []
|
||||
puck_name: str
|
||||
puck_type: str
|
||||
puck_location_in_dewar: int
|
||||
dewar_id: int
|
||||
samples: List[Sample] = [] # List of samples within this puck
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
@ -137,8 +154,13 @@ class DewarBase(BaseModel):
|
||||
return_address_id: Optional[int]
|
||||
|
||||
|
||||
class DewarCreate(DewarBase):
|
||||
pass
|
||||
class DewarCreate(BaseModel):
|
||||
dewar_name: str = Field(..., alias="dewarname")
|
||||
tracking_number: Optional[str]
|
||||
status: Optional[str] = None
|
||||
contact_person_id: Optional[int] = None
|
||||
return_address_id: Optional[int] = None
|
||||
pucks: List[PuckCreate] = []
|
||||
|
||||
|
||||
class Dewar(DewarBase):
|
||||
@ -146,7 +168,7 @@ class Dewar(DewarBase):
|
||||
shipment_id: Optional[int]
|
||||
contact_person: Optional[ContactPerson]
|
||||
return_address: Optional[Address]
|
||||
pucks: Optional[List[Puck]] = []
|
||||
pucks: List[Puck] = [] # List of pucks within this dewar
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
@ -184,7 +206,7 @@ class Shipment(BaseModel):
|
||||
contact_person: Optional[ContactPerson]
|
||||
return_address: Optional[Address]
|
||||
proposal: Optional[Proposal]
|
||||
dewars: Optional[List[Dewar]] = []
|
||||
dewars: List[Dewar] = []
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
@ -198,11 +220,11 @@ class ShipmentCreate(BaseModel):
|
||||
contact_person_id: int
|
||||
return_address_id: int
|
||||
proposal_id: int
|
||||
dewars: Optional[List[DewarUpdate]] = []
|
||||
dewars: List[DewarCreate] = []
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class UpdateShipmentComments(BaseModel):
|
||||
comments: str
|
||||
comments: str
|
||||
|
Reference in New Issue
Block a user