示例#1
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")
示例#2
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())
示例#3
0
文件: user.py 项目: huhuchen/luffy
def new_user():
    if request.method == "POST":
        uid = request.form.get('uid', '')
        name = request.form.get('name', '')
        if any((not uid, not name, not is_char_string(uid))):
            return st('new_user.html') 

        user = User.get_by_uid(uid)
        if user:
            return st('new_user.html') 
        
        user = User.add(uid, name, 0)
    return st('new_user.html') 
示例#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())