updated models and schemas for shipments and dewars

This commit is contained in:
GotthardG
2024-11-11 11:43:49 +01:00
parent d5c7e7e6f3
commit 701c42c0dd
8 changed files with 96 additions and 91 deletions

View File

@ -14,23 +14,23 @@ def get_shipments(db: Session):
logging.info(f"Total of {len(shipments)} shipments fetched.")
for shipment in shipments:
if shipment.proposal_id is None:
logging.warning(f"Shipment {shipment.shipment_id} is missing proposal ID.")
logging.debug(f"Shipment ID: {shipment.shipment_id}, Shipment Name: {shipment.shipment_name}")
logging.warning(f"Shipment {shipment.id} is missing proposal ID.")
logging.debug(f"Shipment ID: {shipment.id}, Shipment Name: {shipment.shipment_name}")
return shipments
def get_shipment_by_id(db: Session, shipment_id: str):
logging.info(f"Fetching shipment with ID: {shipment_id}")
def get_shipment_by_id(db: Session, id: int):
logging.info(f"Fetching shipment with ID: {id}")
shipment = db.query(Shipment).options(
joinedload(Shipment.contact_person),
joinedload(Shipment.return_address),
joinedload(Shipment.proposal),
joinedload(Shipment.dewars)
).filter(Shipment.shipment_id == shipment_id).first()
).filter(Shipment.id == id).first()
if shipment:
if shipment.proposal_id is None:
logging.warning(f"Shipment {shipment.shipment_id} is missing proposal ID.")
logging.warning(f"Shipment {shipment.id} is missing proposal ID.")
logging.info(f"Shipment found: {shipment}")
else:
logging.warning(f"Shipment with ID {shipment_id} not found.")
logging.warning(f"Shipment with ID {id} not found.")
return shipment