def delete(post_id="None"): #username and password of the current user #compares the person who posts to the person trying to delete if 'user' in session: uname = session['user'] if utils.post_info(post_id)['user'] == uname: utils.delete_post(post_id) return redirect(url_for("profile",username=uname)) return redirect(url_for("login",message="Login before you delete your post."))
def post(post_id="1"): if request.method == "POST": if 'user' in session and session['user'] != '': comment = request.form['comment'] # add comment to database utils.add_comment(post_id,session['user'],comment) else: return redirect(url_for("login",message="Login before you post.")) d = utils.post_info(post_id) comment_list = utils.comments(post_id) return(render_template("post.html",d=d,comment_list=comment_list,post_id=post_id))