Example #1
0
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'])))
Example #2
0
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'))
Example #3
0
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"})
Example #4
0
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"})
Example #5
0
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'))
Example #6
0
def delete_joke():
    joke_id = request.form['id']
    return json.dumps({"status": j.delete_joke(mongo, ObjectId(joke_id))})
Example #7
0
def tags(tag):
    tag = tag.replace("+", " ")
    a = j.get_tagged(mongo, tag)
    return render_template("tagged.html", info=(a), tagged=tag)
Example #8
0
def public_jokes():
    return json.dumps(j.view_with_id(mongo, request.form['username']))
Example #9
0
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"})
Example #10
0
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'))
Example #11
0
def delete_joke():
	joke_id=request.form['id']
	return json.dumps({"status": j.delete_joke(mongo,ObjectId(joke_id))})
Example #12
0
def tags(tag):
	tag=tag.replace("+"," ")
	a=j.get_tagged(mongo,tag)
	return render_template("tagged.html", info=(a), tagged=tag)
Example #13
0
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'])))
Example #14
0
def public_jokes():
	return json.dumps(j.view_with_id(mongo,request.form['username']))
Example #15
0
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"})
Example #16
0
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'))