Exemple #1
0
def Makerequest(id):
    user = session.query(User).filter_by(id=id).first()
    if request.method=='POST':
        location=request.form['location']
        if location=="" or request.form['meal_type']==""or request.form['date']=="" or request.form['time']=="":
           flash('this two input should not be empty')
           return render_template('RequestPage.html',user=user)
        latitude,longitude=getGeocodeLocation(location)
        if latitude=="zero":
           flash('Sorry,can not find your location')
           return render_template('RequestPage.html',user=user)
        restaurant_info=findARestaurant(request.form['meal_type'],location)
        if restaurant_info=="No Restaurants Found":
           flash('Sorry,can not find the target restaurant according your meal type')
           return render_template('RequestPage.html',user=user)
        meal_time=request.form['date']+request.form['time']
        Re=Request(user_id=id)
        Re.meal_type=request.form['meal_type']
        Re.latitude=latitude
        Re.longitude=longitude
        Re.location_string=location
        session.add(Re)
        session.commit()
        return render_template('RequestPage.html',user=user)
    else:
        return render_template('RequestPage.html',user=user)
Exemple #2
0
def Makerequest(id):
    user = session.query(User).filter_by(id=id).first()
    if request.method == 'POST':
        location = request.form['location']
        latitude, longitude = getGeocodeLocation(location)
        meal_time = request.form['location']
        Re = Request(user_id=id)
        Re.meal_type = request.form['meal_type']
        Re.latitude = latitude
        Re.longitude = longitude
        Re.location_string = location
        session.add(Re)
        session.commit()
        return render_template('RequestPage.html', user=user)
    else:
        return render_template('RequestPage.html', user=user)