def add_restaurant_review(): """ Allows user to post a review and preview it for any user """ username = sign_up.get_username() if username: add_var = dict(user=username, restaurant_name="", restaurant_address="", restaurant_item="", item_comments="", item_price="", restaurant_ranking="", restaurant_rating="", restaurant_rating_reason="", address="", restaurant_chosen="", address_chosen="") return bottle.template('add_review', add_var=add_var) else: return bottle.template( 'login', dict( user_error= "Sorry, you need to be logged in to submit a review, please log below:", pw_error=""))
def show_users_settings(): email = sign_up.get_email() restaurant_reviews = r.get_reviews_by(db, 'user_id', email) username = sign_up.get_username() return bottle.template('settings', restaurant_reviews=restaurant_reviews, username=username, user_id=email)
def post_main_page(): """ Verifies user and posts main page for navigation """ username = sign_up.get_username() if username: main_var = dict(user = username, stat_rows = STATS, location = LOCATION) return bottle.template('main', main_var = main_var) else: bottle.redirect('/login')
def post_main_page(): """ Verifies user and posts main page for navigation """ username = sign_up.get_username() if username: main_var = dict(user=username, stat_rows=STATS, location=LOCATION) return bottle.template('main', main_var=main_var) else: bottle.redirect('/login')
def add_review_to_db(): add_var = {} restaurant_review_entry = {} username = sign_up.get_username() for key, value in bottle.request.forms.items(): print "%s: %s" % (key, value) add_var[key] = value restaurant_review_entry["user"] = username add_var['user'] = username if key != 'submit' and value != "": restaurant_review_entry[key] = value restaurant_review_entry['time'] = time.strftime("%a, %b %d %Y %I:%M%p", time.localtime()) #change restaurant name and address to javascript variables add_var['restaurant_name'] = add_var['restaurant_chosen'] restaurant_review_entry['restaurant_name'] = add_var['restaurant_chosen'] add_var['address'] = add_var['address_chosen'] restaurant_review_entry['address'] = add_var['address_chosen'] #see if there's a restaurant name, otherwise send back with fields entered if 'restaurant_name' not in restaurant_review_entry: add_var['error'] = "Error: Please enter restaurant name, silly!" #print add_var['restaurant_address'] return bottle.template('add_review', add_var=add_var) if 'preview_selected' in restaurant_review_entry: print restaurant_review_entry entry_preview = r.Review(restaurant_review_entry).to_html() add_var['preview_selected'] = entry_preview #print add_var return bottle.template('add_review', add_var=add_var) #we're ready to add entry to db if username != "Anonymous User": try: db.reviews.insert(restaurant_review_entry) except pymongo.errors.PyMongoError: add_var['error'] = "Error: Couldn't add this to the db" return bottle.template('add_review', add_var=add_var) else: add_var['error'] = "Sorry, you cannot add a review because you are not signed in as a user or because of a cookie error" return bottle.template('add_review', add_var=add_var) return bottle.redirect('view')
def add_review_to_db(): add_var = {} restaurant_review_entry = {} username = sign_up.get_username() for key, value in bottle.request.forms.items(): print "%s: %s" % (key, value) add_var[key] = value restaurant_review_entry["user"] = username add_var['user'] = username if key != 'submit' and value != "": restaurant_review_entry[key] = value restaurant_review_entry['time'] = time.strftime("%a, %b %d %Y %I:%M%p", time.localtime()) #change restaurant name and address to javascript variables add_var['restaurant_name'] = add_var['restaurant_chosen'] restaurant_review_entry['restaurant_name'] = add_var['restaurant_chosen'] add_var['address'] = add_var['address_chosen'] restaurant_review_entry['address'] = add_var['address_chosen'] #see if there's a restaurant name, otherwise send back with fields entered if 'restaurant_name' not in restaurant_review_entry: add_var['error'] = "Error: Please enter restaurant name, silly!" #print add_var['restaurant_address'] return bottle.template('add_review', add_var=add_var) if 'preview_selected' in restaurant_review_entry: print restaurant_review_entry entry_preview = r.Review(restaurant_review_entry).to_html() add_var['preview_selected'] = entry_preview #print add_var return bottle.template('add_review', add_var=add_var) #we're ready to add entry to db if username != "Anonymous User": try: db.reviews.insert(restaurant_review_entry) except pymongo.errors.PyMongoError: add_var['error'] = "Error: Couldn't add this to the db" return bottle.template('add_review', add_var=add_var) else: add_var[ 'error'] = "Sorry, you cannot add a review because you are not signed in as a user or because of a cookie error" return bottle.template('add_review', add_var=add_var) return bottle.redirect('view')
def add_restaurant_review(): """ Allows user to post a review and preview it for any user """ username = sign_up.get_username() if username: add_var = dict(user=username, restaurant_name="", restaurant_address="", restaurant_item="", item_comments="", item_price="", restaurant_ranking="", restaurant_rating="", restaurant_rating_reason="", address="", restaurant_chosen="", address_chosen="") return bottle.template('add_review', add_var=add_var) else: return bottle.template('login', dict(user_error="Sorry, you need to be logged in to submit a review, please log below:", pw_error=""))
def show_users_settings(): email = sign_up.get_email() restaurant_reviews = r.get_reviews_by(db, 'user_id', email) username = sign_up.get_username() return bottle.template('settings', restaurant_reviews = restaurant_reviews, username = username, user_id = email)