def update_booking(id): member_id = request.form["member_id"] session_id = request.form["session_id"] member = member_repo.select(member_id) session = session_repo.select(session_id) booking = Booking(member, session, id) booking_repo.update(booking) return redirect("/bookings")
def create_booking(): member_id = request.form["member_id"] session_id = request.form["session_id"] member = member_repo.select(member_id) session = session_repo.select(session_id) new_booking = Booking(member, session) booking_repo.save(new_booking) return redirect("/bookings")
def select_all(): bookings = [] sql = "SELECT * FROM bookings" results = run_sql(sql) for result in results: member = member_repo.select(result["member_id"]) session = session_repo.select(result["session_id"]) booking = Booking(member, session, result["id"]) bookings.append(booking) return bookings
def select(id): booking = None sql = "SELECT * FROM bookings WHERE id = %s" values = [id] result = run_sql(sql, values)[0] if result is not None: member = member_repo.select(result["member_id"]) session = session_repo.select(result["session_id"]) booking = Booking(member, session, result["id"]) return booking
def show(id): session = session_repo.select(id) members = session_repo.members(session) return render_template("sessions/show.html", session=session, members=members)
def edit_session(id): session = session_repo.select(id) return render_template('sessions/edit.html', session=session)