Better integration of sqlite3 database
This commit is contained in:
@ -1,59 +1,117 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import List, Optional
|
||||
from pydantic import BaseModel, EmailStr
|
||||
from datetime import date
|
||||
|
||||
class ContactPersonSchema(BaseModel):
|
||||
id: Optional[int]
|
||||
|
||||
# Base class for Contact Person
|
||||
class ContactPersonBase(BaseModel):
|
||||
firstname: str
|
||||
lastname: str
|
||||
phone_number: str
|
||||
email: str
|
||||
email: EmailStr
|
||||
|
||||
|
||||
# Create schema for Contact Person
|
||||
class ContactPersonCreate(ContactPersonBase):
|
||||
pass
|
||||
|
||||
|
||||
# Response schema for Contact Person with ID
|
||||
class ContactPerson(ContactPersonBase):
|
||||
id: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True # Update here
|
||||
from_attributes = True
|
||||
|
||||
class AddressSchema(BaseModel):
|
||||
id: Optional[int]
|
||||
|
||||
# Create schema for Address
|
||||
class AddressCreate(BaseModel):
|
||||
street: str
|
||||
city: str
|
||||
zipcode: str
|
||||
country: str
|
||||
|
||||
class Config:
|
||||
from_attributes = True # Update here
|
||||
|
||||
class DewarSchema(BaseModel):
|
||||
id: Optional[str]
|
||||
# Response schema for Address with ID
|
||||
class Address(AddressCreate):
|
||||
id: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
# Create schema for Dewar
|
||||
class DewarCreate(BaseModel):
|
||||
dewar_name: str
|
||||
tracking_number: Optional[str]
|
||||
tracking_number: str
|
||||
number_of_pucks: int
|
||||
number_of_samples: int
|
||||
status: str
|
||||
ready_date: Optional[str]
|
||||
shipping_date: Optional[str]
|
||||
arrival_date: Optional[str]
|
||||
returning_date: Optional[str]
|
||||
ready_date: Optional[date]
|
||||
shipping_date: Optional[date]
|
||||
arrival_date: Optional[date]
|
||||
returning_date: Optional[date]
|
||||
qrcode: str
|
||||
contact_person_id: Optional[int]
|
||||
return_address_id: Optional[int]
|
||||
|
||||
|
||||
# Response schema for Dewar
|
||||
class Dewar(BaseModel):
|
||||
id: str
|
||||
dewar_name: str
|
||||
tracking_number: str
|
||||
number_of_pucks: int
|
||||
number_of_samples: int
|
||||
status: str
|
||||
ready_date: Optional[date]
|
||||
shipping_date: Optional[date]
|
||||
arrival_date: Optional[date]
|
||||
returning_date: Optional[date]
|
||||
qrcode: str
|
||||
shipment_id: Optional[str]
|
||||
contact_person: Optional[ContactPerson]
|
||||
return_address: Optional[Address]
|
||||
|
||||
class Config:
|
||||
from_attributes = True # Update here
|
||||
from_attributes = True
|
||||
|
||||
class ProposalSchema(BaseModel):
|
||||
id: Optional[int]
|
||||
|
||||
# Proposal schema
|
||||
class Proposal(BaseModel):
|
||||
id: int
|
||||
number: str
|
||||
|
||||
class Config:
|
||||
from_attributes = True # Update here
|
||||
from_attributes = True
|
||||
|
||||
class ShipmentSchema(BaseModel):
|
||||
shipment_id: Optional[str]
|
||||
|
||||
# Response schema for Shipment
|
||||
class Shipment(BaseModel):
|
||||
shipment_id: str
|
||||
shipment_name: str
|
||||
shipment_date: str
|
||||
shipment_date: date
|
||||
shipment_status: str
|
||||
contact_person: List[ContactPersonSchema]
|
||||
proposal_number: List[ProposalSchema]
|
||||
return_address: List[AddressSchema]
|
||||
comments: Optional[str] = None
|
||||
dewars: List[DewarSchema]
|
||||
comments: Optional[str]
|
||||
contact_person: Optional[ContactPerson]
|
||||
return_address: Optional[Address]
|
||||
proposal: Optional[Proposal]
|
||||
dewars: Optional[List[Dewar]] = []
|
||||
|
||||
class Config:
|
||||
from_attributes = True # Update here
|
||||
from_attributes = True
|
||||
|
||||
|
||||
# Create schema for Shipment
|
||||
class ShipmentCreate(BaseModel):
|
||||
shipment_name: str
|
||||
shipment_date: date
|
||||
shipment_status: str
|
||||
comments: Optional[str] = ""
|
||||
contact_person_id: int
|
||||
return_address_id: int
|
||||
proposal_id: int # Change "proposal_number_id" to "proposal_id"
|
||||
dewars: Optional[List[str]] = []
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
Reference in New Issue
Block a user