Connected frontend new contact, new address and shipments to backend
This commit is contained in:
@ -137,12 +137,12 @@ dewars = [
|
||||
number_of_samples=33,
|
||||
return_address=[return_addresses[1]],
|
||||
contact_person=[contacts[1]],
|
||||
status='In Transit',
|
||||
status='In Preparation',
|
||||
ready_date='2023-10-01',
|
||||
shipping_date='2023-10-02',
|
||||
arrival_date='2023-10-04',
|
||||
shippingStatus='In Transit',
|
||||
arrivalStatus='Pending',
|
||||
shippingStatus='not shipped',
|
||||
arrivalStatus='not arrived',
|
||||
qrcode='QR123DEWAR002'
|
||||
),
|
||||
Dewar(
|
||||
@ -158,6 +158,32 @@ dewars = [
|
||||
arrivalStatus='Pending',
|
||||
qrcode='QR123DEWAR003'
|
||||
),
|
||||
Dewar(
|
||||
id='DEWAR004',
|
||||
dewar_name='Dewar Four',
|
||||
tracking_number='',
|
||||
number_of_pucks=4,
|
||||
number_of_samples=47,
|
||||
return_address=[return_addresses[0]],
|
||||
contact_person=[contacts[2]],
|
||||
status='In Preparation',
|
||||
shippingStatus='not shipped',
|
||||
arrivalStatus='not arrived',
|
||||
qrcode='QR123DEWAR003'
|
||||
),
|
||||
Dewar(
|
||||
id='DEWAR005',
|
||||
dewar_name='Dewar Five',
|
||||
tracking_number='',
|
||||
number_of_pucks=4,
|
||||
number_of_samples=47,
|
||||
return_address=[return_addresses[0]],
|
||||
contact_person=[contacts[2]],
|
||||
status='Ready for Shipping',
|
||||
shippingStatus='shipped',
|
||||
arrivalStatus='not arrived',
|
||||
qrcode='QR123DEWAR003'
|
||||
),
|
||||
]
|
||||
|
||||
# Proposal data inspired by the Lord of the Rings
|
||||
@ -171,11 +197,15 @@ proposals = [
|
||||
|
||||
# Example: Attach specific Dewars by their ids to shipments
|
||||
specific_dewar_ids1 = ['DEWAR003'] # The IDs of the Dewars you want to attach to the first shipment
|
||||
specific_dewar_ids2 = ['DEWAR001', 'DEWAR002'] # The IDs of the Dewars you want to attach to the second shipment
|
||||
specific_dewar_ids2 = ['DEWAR001', 'DEWAR002']
|
||||
specific_dewar_ids3 = ['DEWAR003', 'DEWAR004', 'DEWAR005']
|
||||
# The IDs of the Dewars you want to attach to the second shipment
|
||||
|
||||
# Find the Dewars with the matching ids
|
||||
specific_dewars1 = [dewar for dewar in dewars if dewar.id in specific_dewar_ids1]
|
||||
specific_dewars2 = [dewar for dewar in dewars if dewar.id in specific_dewar_ids2]
|
||||
specific_dewars3 = [dewar for dewar in dewars if dewar.id in specific_dewar_ids3]
|
||||
|
||||
|
||||
# Define shipments with the selected Dewars
|
||||
shipments = [
|
||||
@ -200,7 +230,19 @@ shipments = [
|
||||
return_address=[return_addresses[1]], # Changed index to a valid one
|
||||
comments='Contains the one ring',
|
||||
dewars=specific_dewars2 # Attach specific Dewars for this shipment
|
||||
),
|
||||
Shipment(
|
||||
shipment_id='SHIPMORDOR3',
|
||||
shipment_date='2024-10-28',
|
||||
shipment_name='Shipment from Mordor',
|
||||
shipment_status='In Transit',
|
||||
contact_person=[contacts[4]],
|
||||
proposal_number=[proposals[3]],
|
||||
return_address=[return_addresses[0]], # Changed index to a valid one
|
||||
comments='Contains the one ring',
|
||||
dewars=specific_dewars3
|
||||
)
|
||||
|
||||
]
|
||||
|
||||
@app.get("/contacts", response_model=List[ContactPerson])
|
||||
@ -239,13 +281,6 @@ async def create_dewar(shipment: Dewar):
|
||||
|
||||
return dewars # Return the list of all dewars
|
||||
|
||||
|
||||
# Endpoint to get the number of dewars in each shipment
|
||||
@app.get("/shipment_dewars")
|
||||
async def get_shipment_dewars():
|
||||
return [{"shipment_id": shipment.shipment_id, "number_of_dewars": shipment.get_number_of_dewars()} for shipment in
|
||||
shipments]
|
||||
|
||||
@app.get("/shipment_contact_persons")
|
||||
async def get_shipment_contact_persons():
|
||||
return [{"shipment_id": shipment.shipment_id, "contact_person": shipment.get_shipment_contact_persons()} for shipment in
|
||||
|
Reference in New Issue
Block a user