Esempio n. 1
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)
Esempio n. 2
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)
Esempio n. 3
0
    def test_set_item(self):

        user = backend.add_user('user02', '*****@*****.**', 'pass02')
        post1 = backend.add_post('title01', user['id'], content='content01')

        item = backend.add_item('item1', user['id'], post1['id'], '')

        item = backend.set_item(item['id'], {'title': 'title3'})
        assert item['title'] == 'title3'
Esempio n. 4
0
    def test_set_item(self):

        user = backend.add_user('user02','*****@*****.**','pass02')
        post1 = backend.add_post('title01',user['id'],content='content01')

        item = backend.add_item('item1',user['id'],post1['id'],'')

        item = backend.set_item(item['id'],{'title':'title3'})
        assert item['title'] ==  'title3'
Esempio n. 5
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")
Esempio n. 6
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')