better support of add and delete dewar to a shipment
This commit is contained in:
@ -148,8 +148,8 @@ dewars = [
|
||||
id='DEWAR003',
|
||||
dewar_name='Dewar Three',
|
||||
tracking_number='TRACK125',
|
||||
number_of_pucks=4,
|
||||
number_of_samples=47,
|
||||
number_of_pucks=7,
|
||||
number_of_samples=72,
|
||||
return_address=[return_addresses[0]],
|
||||
contact_person=[contacts[2]],
|
||||
status='Not Shipped',
|
||||
@ -163,8 +163,8 @@ dewars = [
|
||||
id='DEWAR004',
|
||||
dewar_name='Dewar Four',
|
||||
tracking_number='',
|
||||
number_of_pucks=4,
|
||||
number_of_samples=47,
|
||||
number_of_pucks=7,
|
||||
number_of_samples=70,
|
||||
return_address=[return_addresses[0]],
|
||||
contact_person=[contacts[2]],
|
||||
status='Delayed',
|
||||
@ -178,8 +178,8 @@ dewars = [
|
||||
id='DEWAR005',
|
||||
dewar_name='Dewar Five',
|
||||
tracking_number='',
|
||||
number_of_pucks=4,
|
||||
number_of_samples=47,
|
||||
number_of_pucks=3,
|
||||
number_of_samples=30,
|
||||
return_address=[return_addresses[0]],
|
||||
contact_person=[contacts[2]],
|
||||
status='Returned',
|
||||
@ -312,6 +312,23 @@ async def create_dewar(dewar: Dewar) -> Dewar:
|
||||
|
||||
return dewar # Return the newly created dewar
|
||||
|
||||
@app.delete("/shipments/{shipment_id}/remove_dewar/{dewar_id}", response_model=Shipment)
|
||||
async def remove_dewar_from_shipment(shipment_id: str, dewar_id: str):
|
||||
"""Remove a dewar from a shipment."""
|
||||
# Log parameters
|
||||
logging.info(f"Received request to remove dewar {dewar_id} from shipment {shipment_id}")
|
||||
|
||||
# Find the shipment by ID
|
||||
shipment = next((sh for sh in shipments if sh.shipment_id == shipment_id), None)
|
||||
if not shipment:
|
||||
logging.error(f"Shipment with ID {shipment_id} not found")
|
||||
raise HTTPException(status_code=404, detail="Shipment not found")
|
||||
|
||||
# Remove the dewar from the shipment
|
||||
shipment.dewars = [dw for dw in shipment.dewars if dw.id != dewar_id]
|
||||
|
||||
return shipment
|
||||
|
||||
|
||||
@app.get("/shipment_contact_persons")
|
||||
async def get_shipment_contact_persons():
|
||||
|
Reference in New Issue
Block a user