Beispiel #1
0
def index():
    if request.method == 'POST':
        if 'username' not in session:
            return redirect(url_for('login'))
        utils.new_post(session['username'], request.form['post'],
                       request.form['heading'])
        return render_template('index.html',
                               posts=utils.get_recent_posts(),
                               user_posts=utils.get_user_posts(
                                   session['username']))
    if 'username' in session:
        return render_template('index.html',
                               posts=utils.get_recent_posts(),
                               user_posts=utils.get_user_posts(
                                   session['username']))
    return redirect(url_for('login'))
Beispiel #2
0
def user(username=""):
    if username == "":
        return "<h1> 404 Error </h1>"
    elif request.method == "GET":
        prevposts = utils.get_user_posts(username)
        return render_template("user.html", username=username, posts=prevposts)
    elif request.form["Submit"] == "Change Password":
        status = utils.modify_password(username, request.form["password"], request.form["newpassowrd"], request.form["confirm_passwd"])
        if status != None:
            return render_template("user.html", status=status)
    elif request.form["Submit"] == "Change Email":
        status = utils.modify_email(username, request.form["password"], request.form["email"])
        if status != None:
            return render_template("user.html", status=status)
    elif request.form["Submit"] == "Post":
        utils.new_post(username, request.form["post"], request.form["heading"])
        return render_template("user.html")
    return render_template("user.html")
Beispiel #3
0
def blog(postid):
    if postid <= 0:
        return "<h1> 404 Error </h1>"
    elif request.method == "GET":
        return render_template("blog.html", post=utils.get_post(postid), comments=utils.get_comments(postid))
    elif request.form["Submit"] == "Comment":
        postid = utils.new_post(session["username"], comment)
        post = utils.get_post(postid)
        return render_template("/blog/", post)
Beispiel #4
0
def blog(postid):
    if postid <= 0:
        return "<h1> 404 Error </h1>"
    elif request.method == "GET":
        return render_template("blog.html",
                               post=utils.get_post(postid),
                               comments=utils.get_comments(postid))
    elif request.form["Submit"] == "Comment":
        postid = utils.new_post(session["username"], comment)
        post = utils.get_post(postid)
        return render_template("/blog/", post)
Beispiel #5
0
def user(username=""):
    if username == "":
        return "<h1> 404 Error </h1>"
    elif request.method == "GET":
        prevposts = utils.get_user_posts(username)
        return render_template("user.html", username=username, posts=prevposts)
    elif request.form["Submit"] == "Change Password":
        status = utils.modify_password(username, request.form["password"],
                                       request.form["newpassowrd"],
                                       request.form["confirm_passwd"])
        if status != None:
            return render_template("user.html", status=status)
    elif request.form["Submit"] == "Change Email":
        status = utils.modify_email(username, request.form["password"],
                                    request.form["email"])
        if status != None:
            return render_template("user.html", status=status)
    elif request.form["Submit"] == "Post":
        utils.new_post(username, request.form["post"], request.form["heading"])
        return render_template("user.html")
    return render_template("user.html")
Beispiel #6
0
def index():
	if request.method == 'POST':
		if 'username' not in session:
			return redirect(url_for('login'))
		utils.new_post(
			session['username'],
			request.form['post'],
			request.form['heading']
			)
		return render_template(
			'index.html',
			posts=utils.get_recent_posts(),
			user_posts=utils.get_user_posts(session['username'])
			)
	if 'username' in session:
		return render_template(
			'index.html',
			posts=utils.get_recent_posts(),
			user_posts=utils.get_user_posts(session['username'])
			)
	return redirect(url_for('login'))