now associating a dewar to a slot

This commit is contained in:
GotthardG
2024-11-19 14:43:26 +01:00
parent bf46a7ff37
commit 98d6265ae1
4 changed files with 69 additions and 10 deletions

View File

@ -87,4 +87,22 @@ async def scan_dewar(event_data: LogisticsEventCreate, db: Session = Depends(get
def log_event(db: Session, dewar_id: int, slot_id: int, event_type: str):
new_event = LogisticsEventModel(dewar_id=dewar_id, slot_id=slot_id, event_type=event_type)
db.add(new_event)
db.commit()
db.commit()
@router.post("/dewar/refill", response_model=dict)
async def refill_dewar(qr_code: str, db: Session = Depends(get_db)):
dewar = db.query(DewarModel).filter(DewarModel.unique_id == qr_code).first()
if not dewar:
raise HTTPException(status_code=404, detail="Dewar not found")
# Process refill
dewar.last_refill = datetime.now()
new_event = LogisticsEventModel(
dewar_id=dewar.id, slot_id=None, # No specific slot, as it's a refill event
event_type="refill",
action_details=f"{dewar.unique_id} refilled"
)
db.add(new_event)
db.commit()
return {"message": "Dewar refilled successfully"}