Example #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'))
Example #2
0
def edit(post_id):
    if request.method == 'POST':
        if 'modify' in request.form:
            utils.modify_post(post_id, request.form['new_post'])
        else:
            utils.remove_post(post_id)
        return redirect(url_for('index'))
    if 'username' not in session:
        return redirect(url_for('login'))
    if post_id not in utils.get_user_posts(session['username']):
        return 'Error: Invalid post id.'
    return render_template('edit.html', post=utils.get_post(post_id))
Example #3
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'))
Example #4
0
def edit(post_id):
	if request.method == 'POST':
		if 'modify' in request.form:
			utils.modify_post(post_id, request.form['new_post'])
		else:
			utils.remove_post(post_id)
		return redirect(url_for('index'))
	if 'username' not in session:
		return redirect(url_for('login'))
	if post_id not in utils.get_user_posts(session['username']):
		return 'Error: Invalid post id.'
	return render_template('edit.html', post=utils.get_post(post_id))
Example #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")
Example #6
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")