예제 #1
0
 def test_get_post(self):
     user = backend.add_user('user02','*****@*****.**','pass02')
     post = Post(title='post01',author_id=user['id'],content='content01',pic_small='pic_small')
     db.session.add(post)
     db.session.commit()
     
     _post = backend.get_post(post.id)
     assert _post['title'] == 'post01'
예제 #2
0
def post_delete(post_id):

    post = backend.get_post(post_id)
    if post['author_id'] != g.user_id:
        abort(403)

    post = backend.set_post(post_id,{'show':False})

    return redirect('/index')
예제 #3
0
def item_del(post_id, item_id):

    post = backend.get_post(post_id)
    item = backend.get_item(item_id)

    if g.user_id != post['author_id'] or item['post_id'] != post_id:
        abort(403)

    backend.set_item(item_id, {'show': False})

    return redirect('/post/%d' % post_id)
예제 #4
0
    def test_get_post(self):
        user = backend.add_user('user02', '*****@*****.**', 'pass02')
        post = Post(title='post01',
                    author_id=user['id'],
                    content='content01',
                    pic_small='pic_small')
        db.session.add(post)
        db.session.commit()

        _post = backend.get_post(post.id)
        assert _post['title'] == 'post01'
예제 #5
0
파일: item.py 프로젝트: notedit/missing
def item_del(post_id, item_id):

    post = backend.get_post(post_id)
    item = backend.get_item(item_id)

    if g.user_id != post["author_id"] or item["post_id"] != post_id:
        abort(403)

    backend.set_item(item_id, {"show": False})

    return redirect("/post/%d" % post_id)
예제 #6
0
파일: item.py 프로젝트: notedit/missing
def item_edit(post_id, item_id):

    post = backend.get_post(post_id)
    item = backend.get_item(item_id)

    if g.user_id != post["author_id"] or item["post_id"] != post_id:
        abort(403)

    form = ItemForm(**item)
    if form.validate_on_submit():
        title = form.title.data.encode("utf-8")
        author_id = g.user_id
        atype = ""
        content = form.content.data

        try:
            item = backend.set_item(post_id, {"title": title, "content": content})
        except BackendError, ex:
            flash("内容修改失败,请检查重试", "error")
예제 #7
0
def item_edit(post_id, item_id):

    post = backend.get_post(post_id)
    item = backend.get_item(item_id)

    if g.user_id != post['author_id'] or item['post_id'] != post_id:
        abort(403)

    form = ItemForm(**item)
    if form.validate_on_submit():
        title = form.title.data.encode('utf-8')
        author_id = g.user_id
        atype = ''
        content = form.content.data

        try:
            item = backend.set_item(post_id, {
                'title': title,
                'content': content
            })
        except BackendError, ex:
            flash('内容修改失败,请检查重试', 'error')
예제 #8
0
def post_edit(post_id):
    
    post = backend.get_post(post_id)
    if post['author_id'] != g.user_id:
        abort(403)

    form = PostForm(obj=post)

    if form.validate_on_submit():
        
        title = form.title.data.encode('utf-8')
        content = form.content.data.encode('utf-8')

        try:
            post = backend.set_post(post_id,{
                            'title':title,
                            'content':content
                        })
        except BackendError,ex:
            flash('内容修改失败,请检查重试','error')
        else:
            return redirect('/post/%d' % post_id)
예제 #9
0
def post_one(post_id):
    try:
        post = backend.get_post(post_id)
    except BackendError,ex:
        abort(404)