コード例 #1
0
ファイル: test_card.py プロジェクト: huhuchen/luffy
    def test_add_card(self):

        title = "vim"
        content = "how to learn vim"
        author_uid = "huhuchen"

        c = Card.add(title, content, author_uid)
        
        assert title == c.title

        c_id = c.id
        c.delete()

        c = Card.get(c_id)
        assert c is None
コード例 #2
0
ファイル: card.py プロジェクト: huhuchen/luffy
def new_card():
    if request.method == "POST":
        title = request.form.get("title", "")
        content = request.form.get("content", "")
        if not title:
            return st("new_card.html")
        card = Card.add(title, content, "huhuchen")
        return redirect("/card/%s" % card.id)
    return st("new_card.html")
コード例 #3
0
ファイル: card.py プロジェクト: huhuchen/luffy
def edit_card(cid):
    c = Card.get(cid)
    if not c:
        return redirect("/")
    if request.method == "POST":
        title = request.form.get("title", "")
        content = request.form.get("content", "")
        if not title:
            return st("new_card.html")
        c.update(title, content)
        return redirect("/card/%s" % c.id)
    return st("edit_card.html", **locals())
コード例 #4
0
ファイル: index.py プロジェクト: huhuchen/luffy
def index():
    page = request.args.get('page', 0) 
    start = page * PER_PAGE_LIMIT_IN_INDEX
    cards = Card.gets(start, PER_PAGE_LIMIT_IN_INDEX)
    return st('index.html', **locals()) 
コード例 #5
0
ファイル: card.py プロジェクト: huhuchen/luffy
def card(cid):
    c = Card.get(cid)
    if not c:
        return redirect("/")
    return st("card.html", **locals())