예제 #1
0
def foundPost(post_id):
    if request.method=="GET":
        post = utils.getPost(post_id,"found")
        comments = utils.getCommentsOnPost(post_id, 'found')
        return render_template("post.html",post=post,comments=comments)
    else:
        post = utils.getPost(post_id,"found")
        comment = request.form['newComment']
        prof = request.form['profile']
        pic = request.form['picture']
        name = request.form['variables']
        id = request.form['url']
        utils.writeComment(post_id,name,id,comment,prof,pic,'found')
        comments = utils.getCommentsOnPost(post_id,'found')
        return render_template("post.html", post=post, comments=comments)
예제 #2
0
파일: app.py 프로젝트: snady/blag
def delete(pid=0,cid=0):
        if 'user' not in session:
                return redirect ("/login")
        if cid != 0 and utils.getComment(cid)[5] == session['user']:
                utils.deleteComment(cid)
                return redirect(url_for('post',postid=pid))
        elif pid != 0 and utils.getPost(pid)[5] == session['user']:
                utils.deletePost(pid)
        return redirect("/home")
예제 #3
0
파일: app.py 프로젝트: ldalynyc/blag
def delete(pid=0,cid=0):
        if 'user' not in session:
                return redirect ("/login")
        if cid != 0 and utils.getComment(cid)[5] == session['user']:
                utils.deleteComment(cid)
                return redirect(url_for('post',postid=pid))
        elif pid != 0 and utils.getPost(pid)[5] == session['user']:
                utils.deletePost(pid)
        return redirect("/home")
예제 #4
0
파일: app.py 프로젝트: snady/blag
def post(postid):
        if usersession() == "":
                return redirect("/login")
        if request.method == 'POST':
                content = str(request.form['name'])
                utils.writeComment(content, utils.getUserId(session['user']), postid)
        postrow = utils.getPost(postid)
        commentrow = utils.getCommentsOnPost(postid)
        users = []
        for comment in commentrow:
                users.append(comment[2])
        size = len(users)
        return render_template("post.html", postrow = postrow, commentrow = commentrow, users = users, size = size)
예제 #5
0
파일: app.py 프로젝트: ldalynyc/blag
def post(postid):
        if usersession() == "":
                return redirect("/login")
        if request.method == 'POST':
                content = str(request.form['name'])
                utils.writeComment(content, utils.getUserId(session['user']), postid)
        postrow = utils.getPost(postid)
        commentrow = utils.getCommentsOnPost(postid)
        users = []
        for comment in commentrow:
                users.append(comment[2])
        size = len(users)
        return render_template("post.html", postrow = postrow, commentrow = commentrow, users = users, size = size)
예제 #6
0
파일: app.py 프로젝트: darwinchiu/SoftDevHW
def story(title=""):
    if request.method=="GET":
        if 'un' not in session or session['un']==0:
            return redirect(url_for("home"))
        else:
            user = session['un']
            story = utils.getPost(title)
            if len(story) == 0:
                return redirect(url_for("blog"))
                #return render_template("home.html")
            else:
                story = story[0]
                return render_template("story.html",un=user,title=story[1],user=story[0],content=story[2])
    else:
        content = request.form['post_content']
        utils.edit(session['un'], title, content)
        return redirect(url_for("profile"))
예제 #7
0
파일: app.py 프로젝트: lihelennn/Donaldify
def story(title=""):
    if request.method == "GET":
        if 'un' not in session or session['un'] == 0:
            return redirect(url_for("home"))
        else:
            user = session['un']
            story = utils.getPost(title)
            if len(story) == 0:
                return redirect(url_for("blog"))
                #return render_template("home.html")
            else:
                story = story[0]
                return render_template("story.html",
                                       un=user,
                                       title=story[1],
                                       user=story[0],
                                       content=story[2])
    else:
        content = request.form['post_content']
        utils.edit(session['un'], title, content)
        return redirect(url_for("profile"))
예제 #8
0
def delpost(n):
    post = getPost(n)
    thread = getThread(post['tid'])
    forum = getForum(thread["fid"])
    nav = utils.nav([
            ["/",app.getFn()],
            ["/forum-%d"%(forum['id']),forum["name"]],
            ["thread-%d"%(thread['id']),thread["title"]],
            ["Delete Post"]
            ])

    r = """
<div id="header">Are you sure you wish to delete this post?</div>%s
<form method="post">
<input type="hidden" name="pid" value="%d" />
<div style="text-align:center">
<input type="submit" value="Yes, delete this post" class="btn btn-danger" name="del" />
<br /><br /><a href="thread-%d">No, take me back to the thread</a>
</div>
</form>%s"""%(nav,n,thread['id'],nav)
    return r
예제 #9
0
def editpost(n):
    post = getPost(n)
    thread = getThread(post["tid"])
    forum = getForum(thread["fid"])
    nav = utils.nav([
            ["/",app.getFn()],
            ["/forum-%d"%(forum['id']),forum["name"]],
            ["thread-%d"%(thread['id']),thread["title"]],
            ["Edit Post"]
            ])

    r = """
<div id="header">Edit Post</div>%s
<form method="post">
<input type="hidden" name="pid" value="%d" />
<table class="table">
<tr class="active"><td><textarea name="content" class="form-control" rows="12" placeholder="Enter your post here...">%s</textarea></td></tr>
<tr class="active"><td style="text-align:center;">
  <input type="submit" class="btn btn-primary" value="Edit Post" name="reply" />
  <a class="btn btn-primary" href="thread-%d">Cancel</a>
</td></tr>
</table>
</form>%s"""%(nav,n,cgi.escape(post["content"]),n,nav)
    return r
예제 #10
0
def post(postTitle):
        post = utils.getPost(postTitle)
        if post is not None:
                return render_template("post.html", post = post)
        return error()