def more_jokes(): a = u.user_followers(mongo, session['username']) d = [] for i in a['following']: d.append(i['user']) return json.dumps( j.load_more_jokes(mongo, d, ObjectId(request.form['oid'])))
def submit_joke(): try: if session['loggedin'] == True: joke_title = request.form['joke_title'] joke_desc = request.form['joke_desc'] joke_tags_bf = request.form['joke_tags'].split(',') joke_tags = [] for i in joke_tags_bf: joke_tags.append(i.strip()) joke_date = request.form['joke_date'] avatar = "http://gravatar.com/avatar/" + get_userinfo('email_hash') a = j.new(mongo, session['username'], joke_title, joke_desc, joke_tags, joke_date, avatar) if a == True: return json.dumps({ "status": "success", "msg": "Joke added successfully" }) else: return json.dumps({ "status": "error", "msg": "There was an error, please try again later" }) except KeyError: return redirect(url_for('login'))
def subscribed_jokes(): try: a = u.user_followers(mongo, session['username']) d = [] for i in a['following']: d.append(i['user']) return json.dumps(j.my_wall(mongo, d)) except KeyError: return json.dumps({"status": "error"})
def subscribed_jokes(): try: a=u.user_followers(mongo,session['username']) d=[] for i in a['following']: d.append(i['user']) return json.dumps(j.my_wall(mongo,d)) except KeyError: return json.dumps({"status": "error"})
def submit_joke(): try: if session['loggedin']==True: joke_title=request.form['joke_title'] joke_desc=request.form['joke_desc'] joke_tags_bf=request.form['joke_tags'].split(',') joke_tags=[] for i in joke_tags_bf: joke_tags.append(i.strip()) joke_date=request.form['joke_date'] avatar="http://gravatar.com/avatar/"+get_userinfo('email_hash') a=j.new(mongo,session['username'],joke_title,joke_desc,joke_tags,joke_date,avatar) if a == True: return json.dumps({"status": "success", "msg": "Joke added successfully"}) else: return json.dumps({"status": "error", "msg": "There was an error, please try again later"}) except KeyError: return redirect(url_for('login'))
def delete_joke(): joke_id = request.form['id'] return json.dumps({"status": j.delete_joke(mongo, ObjectId(joke_id))})
def tags(tag): tag = tag.replace("+", " ") a = j.get_tagged(mongo, tag) return render_template("tagged.html", info=(a), tagged=tag)
def public_jokes(): return json.dumps(j.view_with_id(mongo, request.form['username']))
def complete_joke(): try: if session['loggedin'] == True: return json.dumps(j.get_joke(mongo, ObjectId(request.form['oid']))) except KeyError: return json.dumps({"status": "success"})
def get_jokes(): try: if session['loggedin'] == True: return json.dumps(j.view_with_id(mongo, session['username'])) except KeyError: return redirect(url_for('login'))
def delete_joke(): joke_id=request.form['id'] return json.dumps({"status": j.delete_joke(mongo,ObjectId(joke_id))})
def tags(tag): tag=tag.replace("+"," ") a=j.get_tagged(mongo,tag) return render_template("tagged.html", info=(a), tagged=tag)
def more_jokes(): a=u.user_followers(mongo,session['username']) d=[] for i in a['following']: d.append(i['user']) return json.dumps(j.load_more_jokes(mongo,d,ObjectId(request.form['oid'])))
def public_jokes(): return json.dumps(j.view_with_id(mongo,request.form['username']))
def complete_joke(): try: if session['loggedin']==True: return json.dumps(j.get_joke(mongo,ObjectId(request.form['oid']))) except KeyError: return json.dumps({"status": "success"})
def get_jokes(): try: if session['loggedin']==True: return json.dumps(j.view_with_id(mongo,session['username'])) except KeyError: return redirect(url_for('login'))