示例#1
0
文件: user.py 项目: bjornua/dna
def create_do():
    if not authcheck():
        return
    form = local.request.form
    username = form.get("username")
    email = form.get("email")
    macaddrs_max = form.get("macaddrs_max")
    password0 = form.get("password0")
    password1 = form.get("password1")
    
    errors = set()
    if password0 != password1:
        errors.add("passwordmatch")

    try:
        macaddrs_max = int(macaddrs_max)
    except ValueError:
        errors.add("macaddrs_max_type")
    else:
        if not macaddrs_max >= 0:
            errors.add("macaddrs_max_range")
    if len(errors) > 0:
        redirect("user.create_form", errors=",".join(errors), username=username, email=email, macaddrs_max=macaddrs_max)
        return
    
    user.create(username=username, email=email, macaddrs_max=macaddrs_max, password=password0)
    redirect("user.list")
示例#2
0
文件: user.py 项目: bjornua/dna
def list():
    if not authcheck():
        return
    users = ((
        doc["_id"],
        doc["username"],
        doc["email"],
        doc["macaddrs"]
        ) for doc in user.list_docs())
    template_response("/page/user/list.mako",
        users=users
    )
示例#3
0
文件: user.py 项目: bjornua/dna
def create_form():
    if not authcheck():
        return
    args = local.request.args
    
    errors = set(filter(len, args.get(u"errors", "").split(u",")))
    username = args.get(u"username", u"")
    email = args.get(u"email", u"")
    macaddrs_max = args.get(u"macaddrs_max", u"1")
    


    template_response("/page/user/create.mako", 
        username=username,
        email=email,
        macaddrs_max=macaddrs_max,
        errors=errors
    )
示例#4
0
文件: user.py 项目: bjornua/dna
def edit_form(uid):
    if not authcheck():
        return
    try:
        doc = user.get(uid)
    except user.UserDoesntExist:
        notfound()
        return
    
    args = local.request.args
    errors = set(filter(len, args.get(u"errors", "").split(u",")))
    username = args.get(u"username", doc["username"])
    email = args.get(u"email", doc["email"])
    macaddrs_max = args.get(u"macaddrs_max", doc["macaddrs_max"])
    

    template_response("/page/user/edit.mako", 
        uid=uid,
        username=username,
        email=email,
        macaddrs_max=macaddrs_max,
        errors=errors
    )
示例#5
0
文件: lan.py 项目: bjornua/dna
def index():
    if not authcheck():
        return
    template_response("/page/lan/index.mako")
示例#6
0
文件: index.py 项目: bjornua/dna
def logout():
    if not authcheck():
        return
    local.session["authed"] = False
    redirect("admin.login_form")
示例#7
0
def index():
    if not authcheck():
        return
    template_response("/page/index.mako")
示例#8
0
def logout():
    if not authcheck():
        return
    local.session["authed"] = False
    redirect("admin.login_form")
示例#9
0
文件: user.py 项目: bjornua/dna
def delete(uid):
    if not authcheck():
        return
    user.delete(uid)
    redirect("user.list")