def list(self): tt = self.param("taxonomy") if not AccountHelper.auth(self.request.current_user,{ObjectPool.treeview[tt].list}): return [] category = CategoryHelper(tt) simple_nodes = category.list() return simple_nodes
def delete(self): tt = self.param("taxonomy") if not AccountHelper.auth(self.request.current_user,{ObjectPool.treeview[tt].delete}): return ["UnAuth"] id_ = self.param("id") category = CategoryHelper(tt) return [category.remove(id_)]
def render(self, id_, target, type_="table"): """ :param id_: dom id :param target: DataTable's entity property Or DataView's view property value :param type_: 'table' or 'view' :return: """ key = Utils.md5(target) point = None if type_ == "table": point = DataTableModule.__security_points__.get(key) elif type_ == "view": point = DataViewModule.__security_points__.get(key) html = list() if AccountHelper.auth(self.current_user, {point.add, point.update, point.delete}): html.append('<div class="form-group"><div class="col-lg-9 col-lg-offset-3">') html.append( '<input type="button" class="btn btn-primary btn-sm" id="%s_form_save" onclick="%s_.form.save(this,%s);" value="保存"></button>' % (id_, id_, "''") ) html.append( ' <input type="button" class="btn btn-white btn-sm" id="%s_form_save_continue" onclick="%s_.form.save(this,%s);" value="保存并继续"></button>' % (id_, id_, "'clear'") ) html.append( ' <input type="button" class="btn btn-white btn-sm" id="%s_form_reset" onclick="%s_.form.reset(this);" value="重填"></button>' % (id_, id_) ) html.append("</div></div>") html.append("</form>") return "".join(html)
def add(self): tt = self.param("taxonomy") if not AccountHelper.auth(self.request.current_user,{ObjectPool.treeview[tt].add}): return ["UnAuth"] parent_id = self.param("parent_id") cat_name = self.param("cat_name") category = CategoryHelper(tt) if category.exists(cat_name): return ["Exists"] id = category.create(cat_name,parent_id) return [id]
def update(self): tt = self.param("taxonomy") if not AccountHelper.auth(self.request.current_user,{ObjectPool.treeview[tt].update}): return ["UnAuth"] id = self.param("id") parent_id = self.param("pId") cat_name = self.param("name") category = CategoryHelper(tt) if category.exists_other(id,cat_name): return ["Exists"] msg = category.update(id,cat_name,parent_id) return [msg]
def render(self, **prop): dom_id = prop["id"] opt = dict() opt["taxonomy"] = prop["taxonomy"] placeholder = prop.get("placeholder") self.point = ObjectPool.treeview.get(opt["taxonomy"]) if not self.point: self.point = EmptyClass() self.point.list = prop.get("point_list") ObjectPool.treeview[opt["taxonomy"]] = self.point if AccountHelper.auth(self.current_user, {self.point.list}): return self.render_string("widgets/treecombobox.html", id=dom_id, ph=placeholder, opt=opt) return ""
def render(self): points = list(AccountHelper.points(self.current_user)) if points.count("tinyms.sidebar.archives.show"): self.archives_show = True if points.count("tinyms.sidebar.role_org.show"): self.role_org_show = True if points.count("tinyms.sidebar.sys_params.show"): self.sys_params_show = True custom_menus = ObjectPool.sidebar_menus first_levels = list() for menu in custom_menus: if menu[1].count("/") == 1: first_levels.append(menu) html_builder = list() self.sort_menus(first_levels) for first in first_levels: if first[4] and points.count(first[4]) == 0: continue p = ( '<a href="' + first[2] + '"><i class="' + first[5] + ' icon-xlarge"></i><span>' + first[3] + "</span></a>" ) subs = self.children(first[1]) if len(subs) > 0: html_builder.append('<li class="dropdown-submenu">') html_builder.append(p) html_builder.append('<ul class="dropdown-menu">') self.sort_menus(subs) for sub in subs: if sub[4] and points.count(sub[4]) == 0: continue html_builder.append('<li><a href="' + sub[2] + '">' + sub[3] + "</a></li>") pass html_builder.append("</ul>") html_builder.append("</li>") else: html_builder.append("<li>" + p + "</li>") menu_html = "".join(html_builder) context = dict() context["menu"] = menu_html context["archives_show"] = self.archives_show context["role_org_show"] = self.role_org_show context["sys_params_show"] = self.sys_params_show context["dev"] = ObjectPool.mode_dev return self.render_string("workbench/sidebar.html", context=context)
def add(self, http_req): login_name = http_req.get_argument("login_name") if not login_name: return "UserLoginIdNotBlank" password = http_req.get_argument("password") if not password: return "PasswordNotBlank" repassword = http_req.get_argument("repassword") if password != repassword: return "PasswordNotSame" bind_target_user = http_req.get_argument("archives_id") enabled = Utils.parse_int(http_req.get_argument("enabled")) account_id = AccountHelper.create(login_name, password, bind_target_user, enabled) return account_id
def modify(self, id_, http_req): login_name = http_req.get_argument("login_name") if not login_name: return "UserLoginIdNotAllowedBlank" password = http_req.get_argument("password") print(password) if password: repassword = http_req.get_argument("repassword") if password != repassword: return "PasswordIsNotSame" bind_target_user = http_req.get_argument("archives_id") enabled = Utils.parse_int(http_req.get_argument("enabled")) msg = AccountHelper.update(id_, login_name, password, bind_target_user, enabled) if msg == "Updated": return "" return msg
def get_current_account_points(self): """ account security points: set('key1','key2',..) :return: """ temp = set() if not self.get_current_user(): return temp cache = CacheManager.get(500, 30 * 1000) points = cache.get(IRequest.__key_account_points__ % self.get_current_user()) if points: print("Exists Cache Account Points") return points else: temp = temp.union(AccountHelper.points(self.get_current_user())) return temp
def render(self, **p): opt = dict() dom_id = p["id"] placeholder = p["placeholder"] opt["taxonomy"] = p["taxonomy"] self.point = EmptyClass() self.point.list = p.get("point_list") self.point.add = p.get("point_add") self.point.update = p.get("point_update") self.point.delete = p.get("point_delete") if not self.point.list: self.point.list = "tinyms.view.termtaxonomy.list" if not self.point.add: self.point.add = "tinyms.view.termtaxonomy.add" if not self.point.update: self.point.update = "tinyms.view.termtaxonomy.update" if not self.point.delete: self.point.delete = "tinyms.view.termtaxonomy.delete" opt["point"] = self.point ObjectPool.treeview[opt["taxonomy"]] = self.point if AccountHelper.auth(self.current_user, {self.point.list}): return self.render_string("widgets/orgtree.html", id=dom_id, ph=placeholder, opt=opt) return ""
def render(self): return AccountHelper.name(self.current_user)
def delete(self, id_, http_req): msg = AccountHelper.delete(id_) if msg == "Success": return "" return msg