def edit(id): """Display a form to edit a booking""" b = Booking.select().where(Booking.id == id) booking = prefetch(b, Order, Dish, Caterer, Contact, Organization, BookingRoom, Room, User)[0] dishes = prefetch(Dish.select().where(Dish.isDeleted == False), Caterer.select().where(Caterer.isDeleted == False)) orgs = Organization.select().where((Organization.isDeleted == False) | ( Organization.id == booking.contact.organization_id)) cons = Contact.select().where((Contact.isDeleted == False) | (Contact.id == booking.contact_id)) print(booking.startTime, booking.endTime, type(booking.endTime)) rooms = Room.openRooms(booking.startTime, booking.endTime, booking.id).execute() contactjson = {} for c in cons: oid = c.organization_id if c.organization_id is not None else 0 if oid not in contactjson: contactjson[oid] = {} contactjson[oid][c.id] = c.name roomjson = {} for room in rooms: roomjson[room.id] = { 'capacity': room.capacity, 'rate': float(room.price), 'adjacentRooms': room.adjacentRoomIds(), 'name': room.name, 'id': room.id } return render_template('bookings/edit.html', booking=booking, dishes=dishes, orgs=orgs, contacts=cons, contactjson=contactjson, rooms=rooms, roomjson=roomjson)
def index(): """List all caterers and their dishes""" caterer = Caterer.select().where(Caterer.isDeleted == False) dishes = Dish.select().where(Dish.isDeleted == False) caterers = prefetch(caterer, dishes) return render_template('admin/caterers/index.html', caterers=caterers)
def edit(id): """Display a dish edit form""" dish = Dish.select().where(Dish.id == id).get() return render_template('admin/dishes/edit.html', dish=dish, caterers=Caterer.select().where((Caterer.isDeleted == False) | (Caterer.id == dish.caterer_id)))