def favorites(): url = request.form['url'] userid = request.form['prompt'] tag = request.form['tag'] title = request.form['title'] mongoFunctions.add_to_favorites(userid, url, title) favList = mongoFunctions.get_favorites(userid) return render_template('index.html', url = url, tag = tag, user = userid, favorites = favList)
def dislike(): url = request.form['url'] userid = request.form['prompt'] tag = request.form['tag'] tags = [] tags.append(tag) favList = mongoFunctions.get_favorites(userid) mongoFunctions.update_tags(userid, tags, -1) return render_template('index.html', url = url, tag = tag, user = userid, favorites = favList)
def stumbl(): userid = request.form['prompt'] tags = request.form['interests'] if userid == '': return render_template('index.html', user = '', tag = '', url='http://tumblr.com') tags = tags.split(',') if " separated by commas" in tags and len(mongoFunctions.get_tags(userid)) <= 1: tags = ['hacking'] for i in range(0,len(tags)): tags[i] = tags[i].strip() try: for tag in backend.retrieveLikes(userid): tags.append(tag) except urllib2.HTTPError: tags = tags mongoFunctions.insert_user(userid, tags) mongoFunctions.update_tags(userid, tags, 0) url, tag = backend.getUrl(mongoFunctions.get_tags(userid), userid) mongoFunctions.add_to_recently_visited(userid, url) favList = mongoFunctions.get_favorites(userid) return render_template('index.html', url = url, tag = tag, user = userid, favorites = favList)