def admin_view(): errmsg = request.args.get("errmsg","") try : v = biz.visit_dir(session["dir"]) status = v.data.status except KeyError: status = 0 if status<5: return "没有权限" return render_template(config.VIEW+'/admin.html', errmsg=errmsg)
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 box_set_view(account_dir, box_dir): re = biz.box_usable(account_dir, box_dir) ar = biz.visit_dir(account_dir) if re.errcode == model.HAVEDIR : try: re = biz.box_biz.box_user_level(account_dir, box_dir,session['dir']) if re.errcode != model.OK : lev = 0 else : lev = re.data except KeyError: lev = 0 v = biz.account_biz.visit_dir(account_dir) box = biz.box_biz.get_box(account_dir, box_dir) if lev<3 : return "权限不足" return render_template(config.VIEW+'/box_set.html', accounttype=ar.errmsg, box = box.data, account=v.data, account_dir=account_dir, box_dir=box_dir, lev=lev) else : return render_template(config.VIEW+'/404.html')
def box_add(account_dir): dir = request.form['dir'] name = request.form['name'] v = biz.visit_dir(session["dir"]) if dir == "": errmsg = "目录不能为空" elif biz.re_box_dir(dir) == False: errmsg = "目录格式不正确" elif name == "": errmsg = "名称不能为空" elif len(dir)<1 or len(dir)>16 : errmsg = "目录长度不符" elif len(name)<1 or len(name)>20 : errmsg = "名称长度不符" elif v.data.status<3: errmsg = "没有此权限,请联系管理员" else: box = model.Box(dir, account_dir, name, session["dir"]) user_dir = session['dir'] re = biz.add_box(box) errmsg = re.errmsg return render_template(config.VIEW+'/signupBox.html', errmsg = errmsg)