Exemplo n.º 1
0
def booking_detail():
    if ('logged_in' not in session or not session['logged_in']):
        return redirect(url_for('login'))

    # Bookings information
    booking_to = request.args.get('to', '')
    booking_from = request.args.get('from', '')
    booking_vehicle = request.args.get('vehicle', '')
    booking_startday = request.args.get('startdate', '')
    booking_starttime = request.args.get('starttime', '')

    if (booking_to == '' or booking_from == '' or booking_vehicle == ''
            or booking_startday == '' or booking_starttime == ''):
        # Booking details
        page['bar'] = False
        flash("Error, incorrect details provided")
        return redirect(url_for('user_bookings'))

    # Get the booking based off the information
    booking_details = database.get_booking(booking_startday, booking_starttime,
                                           booking_vehicle, booking_to,
                                           booking_from)

    return render_template('booking_detail.html',
                           user=user_details,
                           page=page,
                           session=session,
                           booking=booking_details)
Exemplo n.º 2
0
def new_booking():
    if ('logged_in' not in session or not session['logged_in']):
        return redirect(url_for('login'))

    # If we're just looking at the 'new booking' page
    if (request.method == 'GET'):
        # If somemone booked from the car
        from_car = request.args.get('car', '')
        cars = database.get_all_cars()
        if (cars is None):
            flash("Error, there is no car to book in the system")
            page['bar'] = False
            return (redirect(url_for('index')))
        times = [
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
            19, 20, 21, 22, 23
        ]
        return render_template('new_booking.html',
                               cars=cars,
                               times=times,
                               session=session,
                               page=page,
                               from_car=from_car)
    # If we're making the booking
    success = database.make_booking(user_details['email'],
                                    request.form['car_regno'],
                                    request.form['book_date'],
                                    request.form['book_hour'],
                                    request.form['duration'])
    if (success == True):
        user_details[
            'num_bookings'] = database.update_session_stat_nrofbookings(
                user_details['email'])[0]
        page['bar'] = True
        flash("Booking Successful!")
        val = database.get_booking(request.form['book_date'],
                                   request.form['book_hour'],
                                   request.form['car_regno'])
        return render_template('booking_detail.html',
                               booking=val,
                               session=session,
                               page=page)
    elif (success == False):
        page['bar'] = False
        flash("There was an error making your booking.")
        return (redirect(url_for('new_booking')))
    elif (success == 'booked'):
        page['bar'] = False
        flash(
            "Car is already booked by another member, or you already have a booking, at this time"
        )
        return (redirect(url_for('new_booking')))
    else:
        page['bar'] = False
        flash(
            "Invalid time. Please select a time greater than the current time")
        return (redirect(url_for('new_booking')))
Exemplo n.º 3
0
def my_bookings():
    if( 'logged_in' not in session or not session['logged_in']):
        return redirect(url_for('login'))

    # Check if viewing a booking detail
    b_date = request.args.get('b_date', '')
    b_hour = request.args.get('b_hour', '')
    b_car = request.args.get('regno', '')

    if(b_date != '' and b_hour != '' and b_car != ''):
        # Booking details
        val = database.get_booking(b_date, b_hour.split(':')[0], b_car)
        return render_template('booking_detail.html', booking=val, session=session, page=page)

    # If no booking, then get all the bookings made by the user
    val = database.get_all_bookings(user_details['email'])
    return render_template('bookings_list.html', bookings=val, session=session, page=page)
Exemplo n.º 4
0
def my_bookings():
    if( 'logged_in' not in session or not session['logged_in']):
        return redirect(url_for('login'))

    # Check if viewing a booking detail
    b_date = request.args.get('b_date', '')
    b_hour = request.args.get('b_hour', '')
    b_car = request.args.get('regno', '')

    if(b_date != '' and b_hour != '' and b_car != ''):
        # Booking details
        val = database.get_booking(b_date, b_hour, b_car)
        return render_template('booking_detail.html', booking=val, session=session, page=page)

    # If no booking, then get all the bookings made by the user
    val = database.get_all_bookings(user_details['email'])
    return render_template('bookings_list.html', bookings=val, session=session, page=page)
Exemplo n.º 5
0
def my_bookings():
    if ('logged_in' not in session or not session['logged_in']):
        return redirect(url_for('login'))

    # Check if viewing a booking detail
    booking_id = request.args.get('booking', '')

    if (booking_id != ''):
        # Booking details
        val = database.get_booking(booking_id)
        return render_template('booking_detail.html',
                               booking=val,
                               session=session,
                               page=page)

    # If no booking, then get all the bookings made by the user
    val = database.get_all_bookings(user_details['member_no'])
    return render_template('bookings_list.html',
                           bookings=val,
                           session=session,
                           page=page)