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'): 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', user=user_details, times=times, session=session, page=page) # If we're making the booking success = database.make_booking( user_details['member_id'], request.form['member_id'], request.form['vehicle_regno'], request.form['book_date'], request.form['book_hour'], request.form['from_place'], request.form['to_place']) if (success == True): page['bar'] = True flash("Booking Successful!") return (redirect(url_for('index'))) else: page['bar'] = False flash("There was an error making your booking.") return (redirect(url_for('new_booking')))
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): page['bar'] = True flash("Booking Successful!") user_details['num_bookings'] += 1 # increment num_bookings if booking is made successfully return(redirect(url_for('index'))) else: page['bar'] = False flash("There was an error making your booking.") return(redirect(url_for('new_booking')))
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')))
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 == 0): user_details[ 'num_bookings'] += 1 #we need to reflect the successful booking in the session as well as database page['bar'] = True flash("Booking Successful!") return (redirect(url_for('my_bookings'))) elif (success == 1): page['bar'] = False flash("Car already booked for this period!") return (redirect(url_for('new_booking'))) elif (success == 2): page['bar'] = False flash("You already have a booking for this period!") return (redirect(url_for('new_booking'))) elif (success == 3): page['bar'] = False flash("Please enter an appropriate time.") return (redirect(url_for('new_booking'))) else: page['bar'] = False flash("There was an error making your booking.") return (redirect(url_for('new_booking')))
def new_booking(): if ('logged_in' not in session or not session['logged_in']): return redirect(url_for('login')) b_date = request.args.get('b_date', '') if (request.method == 'GET'): if (b_date != ''): times = ["09:00", "10:30", "12:00", "13:30", "15:00", "16:30"] grooming_options = [ "wash only", "wash and nail clipping", "deluxe grooming" ] booked_times = list(database.get_booked_times(b_date)) for i in range(len(booked_times)): booked_times[i] = str(booked_times[i][0]) return render_template('new_booking.html', b_date=b_date, dogs=dogs_details, times=[ time for time in times if (time + ':00') not in booked_times ], options=grooming_options, session=session, page=page) return render_template('booking_date.html', session=session, page=page) # If we're making the booking outcome = database.make_booking( user_details['member_no'], request.form['dog_name'], request.form['book_date'], request.form['book_hour'], request.form['duration'], request.form['grooming_type'], request.form['description']) if (outcome): page['bar'] = True flash("You have made a booking successfully.") return (redirect(url_for('my_bookings'))) else: page['bar'] = False flash("There was an error making your booking.") return (redirect(url_for('new_booking')))
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): page['bar'] = True user_details['num_bookings'] +=1 newbook_url=url_for('my_bookings') newbook_url+='?regno='+request.form['car_regno'] newbook_url+='&b_date='+request.form['book_date'] newbook_url+='&b_hour='+request.form['duration'] flash("Booking Successful!") return(redirect(newbook_url)) else: page['bar'] = False flash("There was an error making your booking.") return(redirect(url_for('new_booking')))