def user_change_info(user_dir): name = request.form['name'] email = request.form['email'] desc = request.form['desc'] try : s = session['dir'] rlev = biz.get_account_user_level(user_dir, s) lev = rlev.data except KeyError: lev = 0 if(lev>2): if name == "": errmsg = "名称不能为空" elif email == "": errmsg = "邮箱不能为空" elif len(email)<5 or len(email)>30 : errmsg = "邮箱长度不符" elif match("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$", email) == None : errmsg = "邮箱格式不正确" else: user = model.User(email, user_dir, name, desc=desc) biz.change_user(user) return redirect(url_for('account_set_view', account_dir=user_dir))
def user_setpw_view(user_dir): re = biz.visit_dir(user_dir) errmsg = request.args.get("errmsg","") try : s = session['dir'] rlev = biz.get_account_user_level(user_dir, s) lev = rlev.data except KeyError: lev = 0 if re.errcode == model.NODIR or re.errmsg == "organ": return render_template(config.VIEW+'/404.html') elif lev<3: return "权限不足" return render_template(config.VIEW+'/user_setpw.html', user = re.data, errmsg=errmsg)
def account_set_view(account_dir): re = biz.visit_dir(account_dir) try : s = session['dir'] rlev = biz.get_account_user_level(account_dir, s) lev = rlev.data except KeyError: lev = 0 if re.errcode == model.NODIR: return render_template(config.VIEW+'/404.html') elif lev<3: return "权限不足" if re.errmsg == "user": return render_template(config.VIEW+'/user_set.html', user = re.data) else: return render_template(config.VIEW+'/organ_set.html', organ = re.data)
def organ_people_view(organ_dir): dir = biz.account_biz.dir_usable(organ_dir) errmsg = request.args.get("errmsg","") try : s = session['dir'] rlev = biz.get_account_user_level(organ_dir, s) lev = rlev.data except KeyError: lev = 0 users = biz.get_organ_users(organ_dir) if dir.errcode==model.OK : return "无此目录" elif dir.data == "user" : return "个人目录无法添加成员" else: re = biz.visit_dir(organ_dir) return render_template(config.VIEW+'/peoples.html', lev=lev, organ=re.data, users = users.data, errmsg=errmsg)
def account_show(account_dir): re = biz.visit_dir(account_dir) if re.errcode == model.NODIR : return render_template(config.VIEW+'/404.html') elif re.errcode == model.OK : boxs = biz.get_account_boxs(account_dir) try : s = session['dir'] rlev = biz.get_account_user_level(account_dir, s) lev = rlev.data except KeyError: lev = 0 if re.errmsg == "user" : organs = biz.get_user_organs(account_dir) pushs = biz.show_recent_user_pushs(account_dir, 5) return render_template(config.VIEW+'/user.html', user=re.data, lev=lev,boxs=boxs.data, organs=organs.data, pushs=pushs.data) elif re.errmsg == "organ" : admins = biz.get_organ_admins(account_dir) return render_template(config.VIEW+'/organ.html', organ = re.data, lev=lev, boxs=boxs.data, admins = admins.data) else : return render_template(config.VIEW+'/error.html')
def organ_change_info(organ_dir): name = request.form['name'] desc = request.form['desc'] try : s = session['dir'] rlev = biz.get_account_user_level(organ_dir, s) lev = rlev.data except KeyError: lev = 0 if(lev>2): if name == "": errmsg = "名称不能为空" elif len(name)<5 or len(name)>20 : errmsg = "名称长度不符" else: organ = model.Organ(organ_dir, name, desc=desc) biz.change_organ(organ) return redirect(url_for('account_set_view', account_dir=organ_dir))
def user_change_pw(user_dir): passwd = request.form['pw'] passwd2 = request.form['pw2'] try : s = session['dir'] rlev = biz.get_account_user_level(user_dir, s) lev = rlev.data except KeyError: lev = 0 if(lev>2): if passwd == "": errmsg = "密码不能为空" elif passwd2 == "": errmsg = "重复密码不能为空" elif len(passwd)<6 or len(passwd)>20 : errmsg = "密码长度不符" elif passwd!=passwd2 : errmsg = "两次密码不一致" else: errmsg = biz.change_user_pw(user_dir, passwd).errmsg return redirect(url_for('user_change_pw', user_dir=user_dir, errmsg = errmsg))