def search_results(): username = '******' try: log_user = dbUtils.get_user(current_user.user_id) username = log_user except: username = '******' if request.method == 'POST': search = request.form['looking'] profile_pic = [] try: p = dbUtils.get_place_by_name(search.title()) pic = p[6] username = dbUtils.get_user(p[1]) pic_url = 'images/' + pic js_dic = { "place_id": p[0], "pic_url": pic_url, "name": p[2], "username": username, "address": p[3], "website": p[4], "phone_number": p[5], "description": p[7], "date_posted": p[8] } profile_pic.append(js_dic) return render_template('search_results.html', username=username, profile_pic=profile_pic) except: data = dbUtils.get_place_by_name1(search.title()) if len(data) == 0: flash('place not found in website') return redirect('/') for p in data: pic = p[6] username = dbUtils.get_user(p[1]) pic_url = 'images/' + pic js_dic = { "place_id": p[0], "pic_url": pic_url, "name": p[2], "username": username, "address": p[3], "website": p[4], "phone_number": p[5], "description": p[7], "date_posted": p[8] } profile_pic.append(js_dic) return render_template('search_results.html', username=username, profile_pic=profile_pic) return render_template('search_results.html', username=username, profile_pic=profile_pic)
def all_reviews(): username1 = 'Visitor' try: log_user = dbUtils.get_user(current_user.user_id) username1 = log_user except: username1 = 'Visitor' user_id = current_user.user_id data = dbUtils.get_review_by_user(user_id) data2 = dbUtils.get_all_place_user(user_id) review_dic = [] my_rev = [] for p in data: pic = dbUtils.get_place_by_id(p[1])[6] pic_url = 'images/'+ pic date_review = p[3] rating = p[6] review = p[4] js_rev = {"date_review":date_review, "rating":rating, "review":review, "pic_loc":pic_url} my_rev.append(js_rev) for p in data2: pic_url = 'images/' + p[1] rev = dbUtils.get_place_review(p[0]) for i in rev: us_id = i[2] user_nam = dbUtils.get_username(us_id)[0] date_review = i[3] rating = i[6] review = i[4] js_rev = {"date_review":date_review, "rating":rating, "review":review, "user_name":user_nam,"pic_loc":pic_url} review_dic.append(js_rev) return render_template('user_reviews.html', my_rev = my_rev, to_me_rev = review_dic, username=username1)
def show_all_places(): data = dbUtils.get_all_places() profile_pic =[] for p in data: pic = p[6] username = dbUtils.get_user(p[1]) pic_url = 'images/'+ pic js_dic ={"place_id":p[0],"pic_url":pic_url,"name":p[2],"username":username,"address":p[3],"website":p[4],"phone_number":p[5],"description":p[7],"date_posted":p[8]} profile_pic.append(js_dic) username1 = 'Visitor' try: log_user = dbUtils.get_user(current_user.user_id) username1 = log_user except: username1 = 'Visitor' return render_template('search_results.html',username=username1, profile_pic=profile_pic)
def admin_dash(): username = dbUtils.get_user(current_user.user_id) check_admin = dbUtils.get_by_username(username)[4] if check_admin == 1: return 'admin pageeee' else: return 'Not allowed You aren\'t admin'
def about_me(): username = '******' try: log_user = dbUtils.get_user(current_user.user_id) username = log_user except: username = '******' return render_template("about.html", username=username)
def show_selected_place(place_id): data = dbUtils.get_place_by_id(place_id) all_review = dbUtils.get_all_place_review(place_id) page_rev = [] for p in all_review: user_name = dbUtils.get_user(p[2]) date_review = p[3] rating = p[6] review = p[4] js_rev = {"username":user_name, "date_review":date_review, "rating":rating, "review":review} page_rev.append(js_rev) pic = data[6] username = dbUtils.get_user(data[1]) pic_url = 'images/'+ pic js_dic ={"place_id":data[0],"pic_url":pic_url,"name":data[2],"username":username,"address":data[3],"website":data[4],"phone_number":data[5],"description":data[7],"date_posted":data[8]} username1 = 'Visitor' try: log_user = dbUtils.get_user(current_user.user_id) username1 = log_user except: username1 = 'Visitor' return render_template('place_list.html',username=username1, profile_pic = js_dic, place_rev = page_rev)
def contact_me(): username = '******' try: log_user = dbUtils.get_user(current_user.user_id) username = log_user except: username = '******' if request.method == 'POST': contact_name = request.form['contact_name'] contact_email = request.form['contact_email'] contact_message = request.form['contact_message'] send_email(contact_email, contact_name, contact_message) return 'message send' else: return render_template("contact_me.html", username=username)
def show_user_places(): username1 = 'Visitor' try: log_user = dbUtils.get_user(current_user.user_id) username1 = log_user except: username1 = 'Visitor' user_id = current_user.user_id data = dbUtils.get_place_by_user(user_id) profile_pic =[] for p in data: pic = p[6] pic_url = 'images/'+ pic js_dic ={"place_id":p[0],"pic_url":pic_url,"name":p[2],"address":p[3],"website":p[4],"phone_number":p[5],"description":p[7],"date_posted":p[8]} profile_pic.append(js_dic) return render_template('user_listing.html', data = data, profile_pic = profile_pic,username=username1)
def home(): username = '******' data = dbUtils.get_all_places() if not data: return render_template("index.html", username=username) profile_pic = [] for p in data: pic = p[6] pic_url = 'images/' + pic js_dic = {"pic_url": pic_url, "place_id": p[0]} profile_pic.append(js_dic) try: log_user = dbUtils.get_user(current_user.user_id) username = log_user except: username = '******' return render_template("index.html", username=username, profile_pic=profile_pic)
def user_dashboard(): username = dbUtils.get_user(current_user.user_id) admin = dbUtils.get_by_username(username)[4] return render_template('dashboard_user.html',username = username, admin = admin)