Ejemplo n.º 1
0
def post(postid):
    if request.method == "GET":
        return render_template("/post.html",
                               current_user=session.get('user'),
                               blogitem=database.getPost("postid", postid)[0],
                               comments=database.getComments("postid", postid))
    else:
        if 'user' in session:
            database.addComment(request.form.get("comment_text"), postid,
                                session['user'])
            return redirect("/post/" + postid)
        else:
            return render_template("/post.html",
                                   current_user=session.get('user'),
                                   blogitem=database.getPost("postid",
                                                             postid)[0],
                                   comments=database.getComments(
                                       "postid", postid),
                                   error="You must be logged in to do that")
Ejemplo n.º 2
0
def post(post_title):
    posts = database.getPost(post_title)
    comment_button = request.args.get("comment_button",None)

    if comment_button == None:
        comments = database.getComments(post_title)
        return render_template("post.html",
                               post_title=post_title, 
                               posts=posts,comments=comments)
    else:
        newComment = request.args.get("comment",None)
        database.insert('comments',post_title,newComment)
        comments = database.getComments(post_title)
        return render_template("post.html",
                               post_title=post_title,
                               posts=posts,comments=comments)
Ejemplo n.º 3
0
def post(postid):
    if request.method == "GET":
        return render_template("/post.html", current_user=session.get('user'), blogitem=database.getPost("postid", postid)[0], comments=database.getComments("postid", postid))
    else:
        if 'user' in session:
            database.addComment(request.form.get(
                "comment_text"), postid, session['user'])
            return redirect("/post/" + postid)
        else:
            return render_template("/post.html", current_user=session.get('user'),  blogitem=database.getPost("postid", postid)[0], comments=database.getComments("postid", postid), error="You must be logged in to do that")
Ejemplo n.º 4
0
def profile(userid):
    return render_template("profile.html", current_user=session.get('user'), profile_user=userid, blogitems=database.getPost("userid", userid), comments=database.getComments("userid", userid))
Ejemplo n.º 5
0
def profile(userid):
    return render_template("profile.html", current_user = session.get('user'), profile_user = userid, blogitems = database.getPost("userid",userid), comments = database.getComments("userid",userid));