Esempio n. 1
0
def order():
    city_name = insert_db.get_g_res_city()
    res_data = insert_db.retrieve_restaurant_data(city_name)
    user_name=insert_db.get_g_user_name()
    orders=insert_db.retrieve_order_user(user_name);
    favourites=insert_db.retrieve_favourites(user_name);
    if request.method == 'POST':
        for i,d in res_data.iteritems():
            temp = str(i)
            if temp in request.form:
                insert_db.set_g_res_name(str(d[0]))
                insert_db.set_g_res_id(str(d[3]))
                # print i
                insert_db.set_g_user_name(user_name)
                return redirect(url_for('menu'))
        
        for i,d in orders.iteritems():
            temp = "cancel"+str(d[0])
            if temp in request.form:
                insert_db.remove_order(d[0])
                break
                
        
        if "logout" in request.form:
            return redirect(url_for('login'))

            
    return render_template('order.html',restaurant=res_data,username=user_name,orders=orders,favourites=favourites)
Esempio n. 2
0
def restaurant_home():
    res_name = insert_db.get_g_res_name()
    res_id = insert_db.get_g_res_id()

    res_data = insert_db.retrieve_restaurant_data_from_id(res_id)
    order_data = insert_db.retrieve_order_res(res_id)
    menu_data = insert_db.retrieve_menu(res_id)
    res_rname = insert_db.retrieve_restaurant_rname(res_id)
    address = insert_db.retrieve_address_from_res_id(res_id)

    if request.method == 'POST':
        if 'logout' in request.form:
            return redirect(url_for('login'))
        if 'add_item' in request.form:
            insert_db.insert_menu_item(request.form['item_name'],
                                       request.form['price'], res_id)
            return redirect(url_for('restaurant_home'))
        if "save_changes" in request.form:
            resname = request.form['res_name']
            #print resname
            email = request.form['email']
            phone = request.form['phone_no']
            start = request.form['start']
            end = request.form['end']
            category = request.form['category']
            insert_db.modify_res_details(res_id, resname, email, phone, start,
                                         end, category)
            return redirect(url_for('restaurant_home'))

        if "logout" in request.form:
            return redirect(url_for('login'))

        for i, d in menu_data.iteritems():
            temp = "delete_item" + str(d[2])
            if temp in request.form:
                insert_db.delete_menu_item(d[2])
                return redirect(url_for('restaurant_home'))

        for i, d in order_data.iteritems():
            name = "name" + str(d[0])
            temp1 = "save_item" + str(d[0])
            temp2 = "cancel_item" + str(d[0])
            if temp1 in request.form:
                insert_db.modify_status_update(d[0], request.form[name])
                return redirect(url_for('restaurant_home'))

            if temp2 in request.form:
                insert_db.remove_order(d[0])
                return redirect(url_for('restaurant_home'))

    return render_template('restaurant_home.html',
                           res_name=res_rname,
                           order_data=order_data,
                           menu_data=menu_data,
                           address=address,
                           phone_number=res_data['phone_number'],
                           email_id=res_data['email_id'],
                           start=res_data['start_time'],
                           end=res_data['end_time'],
                           category=res_data['category'])
Esempio n. 3
0
def order():
    city_name = insert_db.get_g_res_city()
    category = insert_db.get_g_res_cat()
    flag = 0
    res_data = insert_db.retrieve_restaurant_data(city_name,category)
    user_name=insert_db.get_g_user_name()
    orders=insert_db.retrieve_order_user(user_name);
    favourites=insert_db.retrieve_favourites(user_name);
    
    print "f**k"
    
    if request.method == 'POST':
        print "reeeeeee"
        print res_data
        if "search" in request.form:
            city_name = request.form["dd1"]
            category = request.form["dd2"]
            insert_db.set_g_res_city(city_name)
            insert_db.set_g_res_cat(category)
            res_data = insert_db.retrieve_restaurant_data(city_name,category)
        
            print "sdssfsfs"
            
            
            print res_data
            flag = 1
            print "ssssssss"  


        if "logout" in request.form:
            return redirect(url_for('login'))          
           
        for i,d in res_data.iteritems():
            temp = str(i)
            print "for" + temp
            if temp in request.form:
                insert_db.set_g_res_name(str(d[0]))
                insert_db.set_g_res_id(int(d[2]))
                # print i
                insert_db.set_g_user_name(user_name)
                return redirect(url_for('menu'))
                print "fukkkkkkk"
        
        for i,d in orders.iteritems():
            temp = "cancel"+str(d[0])
            if temp in request.form:
                insert_db.remove_order(d[0])
                orders=insert_db.retrieve_order_user(user_name);
                break
                
        
        
        

   
    return render_template('order.html',restaurant=res_data,username=user_name,orders=orders,favourites=favourites)