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)
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)
def login(): if request.method == 'POST': if 'submit_login_user' in request.form: uname = request.form['username'] p = request.form['password'] h_p = hashlib.sha224(p).hexdigest() if request.form['login_type'] == 'user': # login user match = insert_db.match_user_login(uname, h_p) if match == -1: return redirect(url_for('login')) else: # insert_db.set_g_res_city('Kolkata') # insert_db.set_g_res_city('d') insert_db.set_g_user_name(uname) db = pymysql.connect( "10.5.18.101", "14CS10061", "btech14", "14CS10061", cursorclass=pymysql.cursors.DictCursor) c = db.cursor() query = "select user_id from user where username = '******'".format( uname) c.execute(query) result = c.fetchall() insert_db.set_g_user_id(result[0]['user_id']) insert_db.set_g_res_city('Select a city') insert_db.set_g_res_cat('Select a category') flash_message = [ "Restaurant viewing options :", "1. See all : Choose nothing in city and category", "2. See all of one category : Select category and nothing in city", "3. See all from one city : Select city and nothing in category", " ", "It shows all restaurants by default when user first logs in" ] flash(flash_message) return redirect(url_for('order')) elif request.form['login_type'] == 'sysadmin': # login user match = insert_db.match_sysadmin_login(uname, h_p) if match == -1: return redirect(url_for('login')) else: # insert_db.set_g_res_city('Kolkata') # insert_db.set_g_res_city('d') #insert_db.set_g_sysadmin_name(uname) return redirect(url_for('sys_admin_home')) else: # login restaurant match = insert_db.match_restaurant_login(uname, h_p) if match == -1: return redirect(url_for('login')) else: db = pymysql.connect( "10.5.18.101", "14CS10061", "btech14", "14CS10061", cursorclass=pymysql.cursors.DictCursor) c = db.cursor() query = "select res_id,name from restaurant where username = '******'".format( uname) c.execute(query) result = c.fetchall() insert_db.set_g_res_id(result[0]['res_id']) insert_db.set_g_res_name(result[0]['name']) return redirect(url_for('restaurant_home')) # sign up user if 'submit_sign_up_user' in request.form: check = 1 # while True: username = request.form['username'] name = request.form['name'] email = request.form['email'] password = request.form['password'] cpassward = request.form['cpassword'] address = request.form['address'] # check = check_sign_up_user(email,password,cpassward) if check: hashed_password = hashlib.sha224(password).hexdigest() insert_db.insert_user(username, name, hashed_password, email, address) # break # return render_template('login.html') # else : # return render_template('login.html') #print "reached2" # sign up restaurant if 'submit_sign_up_restaurant' in request.form: #print "here" check = 1 username = request.form['username'] name = request.form['name'] email = request.form['email'] password = request.form['password'] cpassword = request.form['cpassword'] phone = request.form['phoneno'] timings = request.form['timings'] address = request.form['address'] city = request.form['city'] category = request.form['category'] image_link = request.form['image_link'] # check = check_sign_up_restaurant(email,password,cpassword,phone,timings) #print "check = " + str(check) if check: timings = timings.split('-') start_time = timings[0] end_time = timings[1] hashed_password = hashlib.sha224(password).hexdigest() #print "here0" insert_db.insert_restaurant(username, name, hashed_password, email, phone, start_time, end_time, category, address, city, image_link) #print "reached3" return render_template('login.html')
def login(): if request.method == 'POST': if 'submit_login_user' in request.form: uname = request.form['username'] p = request.form['password'] h_p = hashlib.sha224(p).hexdigest() if request.form['login_type'] == 'user': # login user match = insert_db.match_user_login(uname,h_p) if match == -1: return redirect(url_for('login')) else : # insert_db.set_g_res_city('Kolkata') # insert_db.set_g_res_city('d') insert_db.set_g_user_name(uname) db = pymysql.connect("10.5.18.101","14CS10061","btech14","14CS10061",cursorclass=pymysql.cursors.DictCursor ) c = db.cursor() query = "select user_id from user where username = '******'".format(uname) c.execute(query) result = c.fetchall() insert_db.set_g_user_id(result[0]['user_id']) return redirect(url_for('order')) else : # login restaurant match = insert_db.match_restaurant_login(uname,h_p) if match == -1: return redirect(url_for('login')) else : db = pymysql.connect("10.5.18.101","14CS10061","btech14","14CS10061",cursorclass=pymysql.cursors.DictCursor ) c = db.cursor() query = "select res_id,name from restaurant where username = '******'".format(uname) c.execute(query) result = c.fetchall() insert_db.set_g_res_id(result[0]['res_id']) insert_db.set_g_res_name(result[0]['name']) return redirect(url_for('restaurant_home')) # sign up user if 'submit_sign_up_user' in request.form: check = 1 # while True: username = request.form['username'] name = request.form['name'] email = request.form['email'] password = request.form['password'] cpassward = request.form['cpassword'] check = check_sign_up_user(email,password,cpassward) if check: hashed_password = hashlib.sha224(password).hexdigest() insert_db.insert_user(username,name,hashed_password,email) # break # return render_template('login.html') # else : # return render_template('login.html') print "reached2" # sign up restaurant if 'submit_sign_up_restaurant' in request.form: print "here" check = 1 username = request.form['username'] name = request.form['name'] email = request.form['email'] password = request.form['password'] cpassward = request.form['cpassword'] phone = request.form['phoneno'] timings = request.form['timings'] address = request.form['address'] city = request.form['city'] category = request.form['category'] # check = check_sign_up_restaurant(email,password,cpassward,phone,timings) print "check = " + str(check) if check: timings = timings.split('-') start_time = timings[0] end_time = timings[1] hashed_password = hashlib.sha224(password).hexdigest() print "here0" insert_db.insert_restaurant(username,name,hashed_password,email,phone,start_time,end_time,category,address,city) print "reached3" return render_template('login.html')