Example #1
0
def updateBooking(bookingNo):
    bkMgr = BookingManager()
    newBkVal = bkMgr.keepValidFieldsOnly(request.json, throw=True)
    # pop None values
    newBkVal = {k: v for k, v in newBkVal.items() if v is not None and v != ""}
    success = bkMgr.updateOne(bookingNo, newBkVal)
    result = {"success": success}
    return result
Example #2
0
def addBooking():
    bkMgr = BookingManager()
    newBkVal = bkMgr.keepValidFieldsOnly(request.json, throw=True)
    # pop primary key
    if "booking_id" in newBkVal:
        newBkVal.pop("booking_id")
    # pop 'None' values
    newBkVal = {k: v for k, v in newBkVal.items() if v is not None and v != ""}
    bookingNo = bkMgr.addOne(newBkVal)
    return {"booking_id": bookingNo}
Example #3
0
def bookings():
    bkMgr = BookingManager()
    # get filter from url args
    filt = bkMgr.keepValidFieldsOnly(request.json, throw=True)
    filt = {
        k: v
        for k, v in filt.items() if v is not None and v != "" and v != []
    }
    bookings = bkMgr.getMany(filt)
    return bookings