Ejemplo n.º 1
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))
Ejemplo n.º 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))
Ejemplo n.º 3
0
def editpost(postid=-1):
    if postid < 0:
        return "<h1> 404 Error </h1>"
    elif request.method == "GET":
        return render_template("editpost.html", post=utils.get_post(postid))
    elif request.form["Submit"] == "Update":
        status = utils.modify_post(postid, request.form["post"])
        return redirect("/blog/" + postid)
    elif request.fomr["Submit"] == "Delete":
        utils.remove_post(postid)
        return redirect(url_for("home"))
Ejemplo n.º 4
0
def editpost(postid=-1):
    if postid < 0:
        return "<h1> 404 Error </h1>"
    elif request.method == "GET":
        return render_template("editpost.html", post=utils.get_post(postid))
    elif request.form["Submit"] == "Update":
        status = utils.modify_post(postid, request.form["post"])
        return redirect("/blog/"+postid)
    elif request.fomr["Submit"] == "Delete":
        utils.remove_post(postid)
        return redirect(url_for("home"))