def adduser(): if request.method =="GET": return render_template("adduser.html") #前端post请求,逻辑端通过request.form获取整个表单的值 if request.method =="POST": name=request.form['username'] name_cn=request.form['username_cn'] passwd=request.form['password'] repasswd=request.form['re_password'] email=request.form['email'] mobile=request.form['mobile'] role=request.form['role'] status=request.form['status'] userlist=get_userlist(["name"]) print userlist if len(name)==0 or len(name_cn)==0 or len(passwd) == 0 or len(email) == 0 or len(mobile) == 0: content="这个值不能为空" return render_template("adduser.html",content=content) if name in map(lambda x:x["name"],userlist): content=u"用户已存在" return render_template("adduser.html",content=content) if passwd !=repasswd: content=u"您输入的两次密码不一致,请重新输入!" return render_template("adduser.html",content=content) userinfo=[name,name_cn,passwd,email,mobile,role,status] add_user(userinfo) return redirect("/")
def adduser(): if request.method == "GET": return render_template("adduser.html") #前端post请求,逻辑端通过request.form获取整个表单的值 if request.method == "POST": name = request.form['username'] name_cn = request.form['username_cn'] passwd = request.form['password'] repasswd = request.form['re_password'] email = request.form['email'] mobile = request.form['mobile'] role = request.form['role'] status = request.form['status'] userlist = get_userlist(["name"]) print userlist if len(name) == 0 or len(name_cn) == 0 or len(passwd) == 0 or len( email) == 0 or len(mobile) == 0: content = "这个值不能为空" return render_template("adduser.html", content=content) if name in map(lambda x: x["name"], userlist): content = u"用户已存在" return render_template("adduser.html", content=content) if passwd != repasswd: content = u"您输入的两次密码不一致,请重新输入!" return render_template("adduser.html", content=content) userinfo = [name, name_cn, passwd, email, mobile, role, status] add_user(userinfo) return redirect("/")
def eventinfo(id): if session: list = events.event_info(id) userlist = participants.get_participants(id) event_owner = False if list[5] == session["name"]: event_owner = True allusers = users.get_userlist() invitees = participants.get_invitees(id) not_yet_invited = [user for user in allusers if user not in invitees] else: invitees = [] not_yet_invited = [] past = date.today() > list[1] return render_template("eventinfo.html", info=list, users=userlist[0], user_is_participant = userlist[1], past=past, event_owner=event_owner, not_yet_invited=not_yet_invited, invitees=invitees) else: return render_template("error.html", message="Et ole kirjautunut sisään")
def event(): if session: userlist = users.get_userlist() now = date.today() datenow = now.isoformat() if request.method == "GET": return render_template("event.html", userlist=userlist, today=datenow, message=None) if request.method == "POST": users.csrf_check(request.form["csrf_token"]) name = request.form["name"] if name == "": return render_template("event.html", userlist=userlist, today=datenow, message="Anna tapahtumalle nimi") if len(name) > 30 or len(name) < 1: return render_template("event.html", userlist=userlist, today=datenow, message="Anna nimi 1-30 merkin pituisena") eventdate = request.form["date"] if eventdate == "": return render_template("event.html", userlist=userlist, today=datenow, message="Anna päivämäärä") location = request.form["location"] if len(location) > 100 or len(location) < 1: return render_template("event.html", userlist=userlist, today=datenow, message="Anna paikka 1-100 merkin pituisena") description = request.form["description"] if len(description) > 200: return render_template("event.html", userlist=userlist, today=datenow, message="Anna enintään 200 merkin kuvaus") type = int(request.form["type"]) open = int(request.form["open"]) user_id = session["user_id"] participant_list = request.form.getlist("invites") event_id = events.add_event(name, eventdate, description, type, open, user_id, location) if event_id != -1: if participants.add_participants(participant_list, event_id): return redirect("/") else: return render_template("error.html", message="Ongelma kutsujen lähettämisessä") else: return render_template("error.html", message="Ongelma tapahtuman lisäämisessä") else: return render_template("error.html", message="Et ole kirjautunut sisään")
def userlist(): user_items=["id","name","name_cn","email","mobile","role","status"] userlist=get_userlist(user_items) return render_template("userlist.html",users=userlist)
def userlist(): user_items = ["id", "name", "name_cn", "email", "mobile", "role", "status"] userlist = get_userlist(user_items) return render_template("userlist.html", users=userlist)