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")
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 )
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 )
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 )
def index(): if not authcheck(): return template_response("/page/lan/index.mako")
def logout(): if not authcheck(): return local.session["authed"] = False redirect("admin.login_form")
def index(): if not authcheck(): return template_response("/page/index.mako")
def delete(uid): if not authcheck(): return user.delete(uid) redirect("user.list")