def view(req): groups = list(loadGroupsFromDB()) order = getSortCol(req) actfilter = getFilter(req) # filter if actfilter != "": if actfilter in ("all", t(lang(req), "admin_filter_all"), "*"): None # all groups elif actfilter == "0-9": num = re.compile(r'([0-9])') groups = filter(lambda x: num.match(x.getName()), groups) elif actfilter == "else" or actfilter == t(lang(req), "admin_filter_else"): all = re.compile(r'([a-z]|[A-Z]|[0-9])') groups = filter(lambda x: not all.match(x.getName()), groups) else: groups = filter( lambda x: x.getName().lower().startswith(actfilter), groups) pages = Overview(req, groups) # sorting if order != "": if int(order[0:1]) == 0: groups.sort(lambda x, y: cmp(x.getName().lower(), y.getName().lower())) elif int(order[0:1]) == 1: groups.sort(lambda x, y: cmp(getNumUsers(x.getName()), getNumUsers(y.getName()))) elif int(order[0:1]) == 2: gl = {} for g in groups: gl[g.id] = g.getSchemas() groups.sort(lambda x, y: cmp(len(gl[x.id]), len(gl[y.id]))) elif int(order[0:1]) == 3: groups.sort(lambda x, y: cmp(x.getHideEdit() == "", y.getHideEdit() == "")) if int(order[1:]) == 1: groups.reverse() # else: # groups.sort(lambda x, y: cmp(x.getName().lower(),y.getName().lower())) v = getAdminStdVars(req) v["sortcol"] = pages.OrderColHeader([ t(lang(req), "admin_usergroup_col_1"), t(lang(req), "admin_usergroup_col_2"), t(lang(req), "admin_usergroup_col_3"), t(lang(req), "admin_usergroup_col_4") ]) v["options"] = list(groupoption) v["groups"] = groups v["pages"] = pages v["actfilter"] = actfilter return req.getTAL("/web/admin/modules/usergroup.html", v, macro="view")
def viewlist(req, id): mapping = getMapping(id) fields = list(mapping.getFields()) order = getSortCol(req) actfilter = getFilter(req) # filter if actfilter != "": if actfilter in ("all", "*", (lang(req), "admin_filter_all")): None # all mappings elif actfilter == "0-9": num = re.compile(r'([0-9])') fields = filter(lambda x: num.match(x.getName()), fields) elif actfilter == "else" or actfilter == t(lang(req), "admin_filter_else"): all = re.compile(r'([a-z]|[A-Z]|[0-9])') fields = filter(lambda x: not all.match(x.getName()), fields) else: fields = filter( lambda x: x.getName().lower().startswith(actfilter), fields) pages = Overview(req, fields) # sorting if order != "": if int(order[0:1]) == 0: fields.sort(lambda x, y: cmp(x.getName().lower(), y.getName().lower())) elif int(order[0:1]) == 1: fields.sort(lambda x, y: cmp(x.getDescription().lower(), y.getDescription().lower())) elif int(order[0:1]) == 2: fields.sort(lambda x, y: cmp(x.getMandatory(), y.getMandatory())) if int(order[1:]) == 1: fields.reverse() else: fields.sort(lambda x, y: cmp(x.getName().lower(), y.getName().lower())) v = getAdminStdVars(req) v["sortcol"] = pages.OrderColHeader([ t(lang(req), "admin_mappingfield_col_1"), t(lang(req), "admin_mappingfield_col_2"), t(lang(req), "admin_mappingfield_col_3") ], addparams="&detailof=" + str(mapping.id)) v["fields"] = fields v["mapping"] = mapping v["options"] = [] v["pages"] = pages v["actfilter"] = actfilter return req.getTAL("web/admin/modules/mapping.html", v, macro="viewlist")
def view(req): workflows = list(getWorkflowList()) order = getSortCol(req) actfilter = getFilter(req) # filter if actfilter != "": if actfilter in ("all", "*", t(lang(req), "admin_filter_all")): None # all users elif actfilter == "0-9": num = re.compile(r'([0-9])') workflows = filter(lambda x: num.match(x.getName()), workflows) elif actfilter == "else" or actfilter == t(lang(req), "admin_filter_else"): all = re.compile(r'([a-z]|[A-Z]|[0-9])') workflows = filter(lambda x: not all.match(x.getName()), workflows) else: workflows = filter( lambda x: x.getName().lower().startswith(actfilter), workflows) pages = Overview(req, workflows) # sorting if order != "": if int(order[0:1]) == 1: workflows.sort(lambda x, y: cmp(x.getName(), y.getName())) elif int(order[0:1]) == 2: workflows.sort( lambda x, y: cmp(x.getDescription(), y.getDescription())) elif int(order[0:1]) == 3: workflows.sort( lambda x, y: cmp(x.getAccess("read"), y.getAccess("read"))) elif int(order[0:1]) == 4: workflows.sort( lambda x, y: cmp(x.getAccess("write"), y.getAccess("write"))) if int(order[1:]) == 1: workflows.reverse() v = getAdminStdVars(req) v["sortcol"] = pages.OrderColHeader([ t(lang(req), "admin_wf_col_1"), t(lang(req), "admin_wf_col_2"), t(lang(req), "admin_wf_col_3"), t(lang(req), "admin_wf_col_4") ]) v["workflows"] = workflows v["pages"] = pages v["actfilter"] = actfilter return req.getTAL("web/admin/modules/workflows.html", v, macro="view")
def view(req): rules = acl.getRuleList() actfilter = getFilter(req) order = getSortCol(req) # filter if actfilter != "": if actfilter in ("all", "*", t(lang(req), "admin_filter_all")): None # all users elif actfilter == "0-9": num = re.compile(r'([0-9])') rules = filter(lambda x: num.match(x.getName()), rules) elif actfilter == "else" or actfilter == t(lang(req), "admin_filter_else"): all = re.compile(r'([a-z]|[A-Z]|[0-9])') rules = filter(lambda x: not all.match(x.getName()), rules) else: rules = filter(lambda x: x.getName().lower().startswith(actfilter), rules) pages = Overview(req, rules) # sorting if order != "": if int(order[0:1]) == 0: rules.sort(lambda x, y: cmp(x.getName().lower(), y.getName().lower())) elif int(order[0:1]) == 1: rules.sort(lambda x, y: cmp(x.rulestr, y.rulestr)) elif int(order[0:1]) == 2: rules.sort(lambda x, y: cmp(x.description, y.description)) if int(order[1:]) == 1: rules.reverse() else: rules.sort(lambda x, y: cmp(x.getName().lower(), y.getName().lower())) v = getAdminStdVars(req) v["sortcol"] = pages.OrderColHeader([ t(lang(req), "admin_acl_col_1"), t(lang(req), "admin_acl_col_2"), t(lang(req), "admin_acl_col_3") ]) v["rules"] = rules v["pages"] = pages v["missing_rules"] = acl.getMissingRuleNames() v["actfilter"] = actfilter return req.getTAL("web/admin/modules/acls.html", v, macro="view")
def showMaskList(req, id): metadatatype = getMetaType(id) masks = metadatatype.getMasks() order = getSortCol(req) actfilter = getFilter(req) # resets filter to all if adding mask in /metatype view # if req.params.get('acttype') == 'mask' or req.params.get('acttype') == 'schema': # if req.path == '/metatype' and 'filterbutton' not in req.params: # actfilter = '*' # resets filter when going to a new view if 'filterbutton' not in req.params: actfilter = '*' # filter if actfilter != "": if actfilter in ("all", "*", t(lang(req), "admin_filter_all")): None # all users elif actfilter == "0-9": num = re.compile(r'([0-9])') masks = filter(lambda x: num.match(x.name), masks) elif actfilter == "else" or actfilter == t(lang(req), "admin_filter_else"): all = re.compile(r'([a-z]|[A-Z]|[0-9])') masks = filter(lambda x: not all.match(x.name), masks) else: masks = filter(lambda x: x.name.lower().startswith(actfilter), masks) pages = Overview(req, masks) defaults = {} for mask in masks: if mask.getDefaultMask(): defaults[mask.getMasktype()] = mask.id # sorting if order != "": if int(order[0:1]) == 0: masks.sort(lambda x, y: cmp(x.name.lower(), y.name.lower())) elif int(order[0:1]) == 1: masks.sort(lambda x, y: cmp(x.getMasktype(), y.getMasktype())) elif int(order[0:1]) == 2: masks.sort(lambda x, y: cmp(x.getDescription(), y.getDescription())) elif int(order[0:1]) == 3: masks.sort(lambda x, y: cmp(x.getDefaultMask(), y.getDefaultMask())) elif int(order[0:1]) == 4: masks.sort(lambda x, y: cmp(x.getLanguage(), y.getLanguage())) if int(order[1:]) == 1: masks.reverse() else: masks.sort(lambda x, y: cmp(x.getOrderPos(), y.getOrderPos())) v = getAdminStdVars(req) v["filterattrs"] = [] v["filterarg"] = req.params.get("filtertype", "name") v["sortcol"] = pages.OrderColHeader( [ t( lang(req), "admin_mask_col_1"), t( lang(req), "admin_mask_col_2"), t( lang(req), "admin_mask_col_3"), t( lang(req), "admin_mask_col_4"), t( lang(req), "admin_mask_col_5"), t( lang(req), "admin_mask_col_6")]) v["metadatatype"] = metadatatype v["masktypes"] = getMaskTypes() v["lang_icons"] = {"de": "/img/flag_de.gif", "en": "/img/flag_en.gif", "no": "/img/emtyDot1Pix.gif"} v["masks"] = masks v["pages"] = pages v["order"] = order v["defaults"] = defaults v["order"] = order v["actfilter"] = actfilter return req.getTAL("web/admin/modules/metatype_mask.html", v, macro="view_mask")
def showDetailList(req, id): metadatatype = getMetaType(id) metafields = metadatatype.getMetaFields() order = getSortCol(req) actfilter = getFilter(req) # resets filter to all if adding mask in /metatype view # if req.params.get('acttype') == 'mask' or req.params.get('acttype') == 'schema': # if req.path == '/metatype' and 'filterbutton' not in req.params: # actfilter = '*' # resets filter when going to a new view if 'filterbutton' not in req.params: actfilter = '*' # filter if actfilter != "": if actfilter in ("all", "*", t(lang(req), "admin_filter_all")): None # all users elif actfilter == "0-9": num = re.compile(r'([0-9])') if req.params.get("filtertype", "") == "name": metafields = filter(lambda x: num.match(x.getName()), metafields) else: metafields = filter(lambda x: num.match(x.getLabel()), metafields) elif actfilter == "else" or actfilter == t(lang(req), "admin_filter_else"): all = re.compile(r'([a-z]|[A-Z]|[0-9]|\.)') if req.params.get("filtertype", "") == "name": metafields = filter(lambda x: not all.match(x.getName()), metafields) else: metafields = filter(lambda x: not all.match(x.getLabel()), metafields) else: if req.params.get("filtertype", "") == "name": metafields = filter(lambda x: x.getName().lower().startswith(actfilter), metafields) else: metafields = filter(lambda x: x.getLabel().lower().startswith(actfilter), metafields) pages = Overview(req, metafields) # sorting if order != "": if int(order[0:1]) == 0: metafields.sort(lambda x, y: cmp(x.orderpos, y.orderpos)) elif int(order[0:1]) == 1: metafields.sort(lambda x, y: cmp(x.getName().lower(), y.getName().lower())) elif int(order[0:1]) == 2: metafields.sort(lambda x, y: cmp(x.getLabel().lower(), y.getLabel().lower())) elif int(order[0:1]) == 3: metafields.sort( lambda x, y: cmp(getMetaFieldTypeNames()[ustr(x.getFieldtype())], getMetaFieldTypeNames()[ustr(y.getFieldtype())])) if int(order[1:]) == 1: metafields.reverse() else: metafields.sort(lambda x, y: cmp(x.orderpos, y.orderpos)) v = getAdminStdVars(req) v["filterattrs"] = [("name", "admin_metafield_filter_name"), ("label", "admin_metafield_filter_label")] v["filterarg"] = req.params.get("filtertype", "name") v["sortcol"] = pages.OrderColHeader( ["", t(lang(req), "admin_metafield_col_1"), t(lang(req), "admin_metafield_col_2"), t(lang(req), "admin_metafield_col_3")]) v["metadatatype"] = metadatatype v["metafields"] = metafields v["fieldoptions"] = fieldoption v["fieldtypes"] = getMetaFieldTypeNames() v["pages"] = pages v["order"] = order v["actfilter"] = actfilter v["actpage"] = req.params.get("actpage") if ustr(req.params.get("page", "")).isdigit(): v["actpage"] = req.params.get("page") return req.getTAL("web/admin/modules/metatype_field.html", v, macro="view_field")
def view(req): """show all users""" global users_cache users = [] order = getSortCol(req) actfilter = getFilter(req) showdetails = 0 searchterm_was = "" macro = "view" usertype = req.params.get("usertype", "") if "action" in req.params: macro = "details" if req.params.get( "action") == "details": # load all users of given type if 1: # len(users_cache)<1: # load users in cache # always load users anew: cache-update for dynamic users seems # uneconomic: loading users seems to run fast users = list(loadUsersFromDB()) for _usertype in list(getExternalUsers()): users += list(_usertype.getChildren()) users_cache = users else: # use users from cache users = users_cache if req.params.get("usertype") == "intern": users = filter(lambda x: x.getUserType() == 'users', users) elif req.params.get("usertype") == "all": pass else: users = filter( lambda x: x.getUserType() == req.params.get("usertype"), users) elif req.params.get( "action") == "search": # load all users with matching search req.params["page"] = "0" searchterm = req.params.get('searchterm') users = searchUser(searchterm) if searchterm: searchterm_was = searchterm if 'use_macro' in req.params: if "searchterm_was" in req.params and searchterm == req.params.get( "searchterm_was"): macro = req.params.get('use_macro') elif "actpage" in req.params or "actfilter" in req.params or "filterbutton" in req.params: users = users_cache showdetails = 1 if "cancel" in req.params: showdetails = 0 # filter if actfilter != "": if actfilter in ("all", "*", t(lang(req), "admin_filter_all")): None elif actfilter == "0-9": num = re.compile(r'([0-9])') if req.params.get("filtertype", "") == "username": users = filter(lambda x: num.match(x.getName()), users) else: users = filter(lambda x: num.match(x.get("lastname")), users) elif actfilter == "else" or actfilter == t(lang(req), "admin_filter_else"): all = re.compile(r'([a-z]|[A-Z]|[0-9])') if req.params.get("filtertype", "") == "username": users = filter(lambda x: not all.match(x.getName()), users) else: users = filter(lambda x: not all.match(x.get("lastname")), users) else: if req.params.get("filtertype", "") == "username": users = filter( lambda x: x.getName().lower().startswith(actfilter), users) else: users = filter( lambda x: x.get("lastname").lower().startswith(actfilter), users) # sorting if order != "": if int(order[0:1]) == 0: users.sort(lambda x, y: cmp(x.getName().lower(), y.getName().lower())) elif int(order[0:1]) == 1: users.sort(lambda x, y: cmp(x.getLastName().lower(), y.getLastName().lower())) elif int(order[0:1]) == 2: users.sort(lambda x, y: cmp(x.getFirstName().lower(), y.getFirstName().lower())) elif int(order[0:1]) == 3: users.sort(lambda x, y: cmp(x.getEmail().lower(), y.getEmail().lower())) elif int(order[0:1]) == 4: users.sort( lambda x, y: cmp(x.getOrganisation(), y.getOrganisation())) elif int(order[0:1]) == 5: users.sort(lambda x, y: cmp(x.getGroups(), y.getGroups())) elif int(order[0:1]) == 6: users.sort(lambda x, y: cmp(x.stdPassword(), y.stdPassword())) if int(order[1:]) == 1: users.reverse() else: users.sort(lambda x, y: cmp(x.getName().lower(), y.getName().lower())) def getUsers(req, users): if req.params.get("usertype") == "intern": users = filter(lambda x: x.getUserType() == 'users', users) elif req.params.get("usertype") == "all": pass else: users = filter( lambda x: x.getUserType() == req.params.get("usertype"), users) return users if usertype: users = getUsers(req, users) pages = Overview(req, users) v = pages.getStdVars() v["filterattrs"] = [("username", "admin_user_filter_username"), ("lastname", "admin_user_filter_lastname")] v["filterarg"] = req.params.get("filtertype", "username") v["sortcol"] = pages.OrderColHeader( [t(lang(req), "admin_user_col_" + str(i)) for i in range(1, 9)]) v["options"] = list(useroption) v["users"] = users v["pages"] = pages v["actfilter"] = actfilter v["auth"] = getExternalAuthentificators() v["details"] = showdetails v["language"] = lang(req) v["t"] = t v["now"] = datetime.datetime.now v["usertype"] = usertype v["id_func"] = id # make sure, this is the python built-in v["searchterm_was"] = searchterm_was v["execute_search"] = req.params.get("execute_search", "") return req.getTAL("web/admin/modules/user.html", v, macro=macro)
def view(req): mtypes = q(Metadatatypes).one().children.order_by("name").all() actfilter = getFilter(req) # filter if actfilter != "": if actfilter in ("all", "*", t(lang(req), "admin_filter_all")): None # all users elif actfilter == "0-9": num = re.compile(r'([0-9])') if req.params.get("filtertype", "") == "id": mtypes = filter(lambda x: num.match(x.name), mtypes) else: mtypes = filter(lambda x: num.match(x.getLongName()), mtypes) elif actfilter == "else" or actfilter == t(lang(req), "admin_filter_else"): all = re.compile(r'([a-z]|[A-Z]|[0-9]|\.)') if req.params.get("filtertype", "") == "id": mtypes = filter(lambda x: not all.match(x.name), mtypes) else: mtypes = filter(lambda x: not all.match(x.getLongName()), mtypes) else: if req.params.get("filtertype", "") == "id": mtypes = filter(lambda x: x.name.lower().startswith(actfilter), mtypes) else: mtypes = filter( lambda x: x.getLongName().lower().startswith(actfilter), mtypes) pages = Overview(req, mtypes) order = getSortCol(req) # sorting if order != "": if int(order[0:1]) == 0: mtypes.sort(lambda x, y: cmp(x.name.lower(), y.name.lower())) elif int(order[0:1]) == 1: mtypes.sort(lambda x, y: cmp(x.getLongName().lower(), y.getLongName().lower())) elif int(order[0:1]) == 2: mtypes.sort(lambda x, y: cmp(x.getDescription().lower(), y.getDescription().lower())) elif int(order[0:1]) == 3: mtypes.sort(lambda x, y: cmp(x.getActive(), y.getActive())) elif int(order[0:1]) == 4: mtypes.sort(lambda x, y: cmp(x.getDatatypeString().lower(), y.getDatatypeString().lower())) if int(order[1:]) == 1: mtypes.reverse() else: mtypes.sort(lambda x, y: cmp(x.name.lower(), y.name.lower())) v = getAdminStdVars(req) v["sortcol"] = pages.OrderColHeader([ t(lang(req), "admin_meta_col_1"), t(lang(req), "admin_meta_col_2"), t(lang(req), "admin_meta_col_3"), t(lang(req), "admin_meta_col_4"), t(lang(req), "admin_meta_col_5"), t(lang(req), "admin_meta_col_6") ]) v["metadatatypes"] = mtypes v["get_classname_for_typestring"] = Node.get_classname_for_typestring v['dtypes'] = Node.__mapper__.polymorphic_map # is used to prevent missing plugins from causing error v["pages"] = pages v["actfilter"] = actfilter v["filterattrs"] = [("id", "admin_metatype_filter_id"), ("name", "admin_metatype_filter_name")] v["filterarg"] = req.params.get("filtertype", "id") v["csrf"] = req.csrf_token.current_token return req.getTAL("web/admin/modules/metatype.html", v, macro="view_type")
def WorkflowStepList(req, wid): global _cssclass, _page workflow = getWorkflow(wid) workflowsteps = list(workflow.getSteps()) order = getSortCol(req) actfilter = getFilter(req) # filter if actfilter != "": if actfilter in ("all", "*", t(lang(req), "admin_filter_all")): None # all users elif actfilter == "0-9": num = re.compile(r'([0-9])') workflowsteps = filter(lambda x: num.match(x.name), workflowsteps) elif actfilter == "else" or actfilter == t(lang(req), "admin_filter_else"): all = re.compile(r'([a-z]|[A-Z]|[0-9])') workflowsteps = filter(lambda x: not all.match(x.name), workflowsteps) else: workflowsteps = filter( lambda x: x.name.lower().startswith(actfilter), workflowsteps) pages = Overview(req, workflowsteps) # sorting if order != "": if int(order[0]) == 0: workflowsteps.sort( lambda x, y: cmp(x.name.lower(), y.name.lower())) elif int(order[0]) == 1: workflowsteps.sort(lambda x, y: cmp(x.type, y.type)) elif int(order[0]) == 2: workflowsteps.sort(lambda x, y: cmp(x.getTrueId(), y.getTrueId())) elif int(order[0]) == 3: workflowsteps.sort( lambda x, y: cmp(x.getFalseId(), y.getFalseId())) elif int(order[0]) == 4: workflowsteps.sort(lambda x, y: cmp(len(x.get("description")), len(y.get("description")))) # elif int(order[0]) == 5: # workflowstep.sort(lambda x, y: cmp(x.getAccess("read"), y.getAccess("read"))) # elif int(order[0]) == 6: # workflowstep.sort(lambda x, y: cmp(x.getAccess("write"), y.getAccess("write"))) if int(order[1]) == 1: workflowsteps.reverse() else: workflowsteps.sort(lambda x, y: cmp(x.name.lower(), y.name.lower())) v = getAdminStdVars(req) v["sortcol"] = pages.OrderColHeader([ t(lang(req), "admin_wfstep_col_1"), t(lang(req), "admin_wfstep_col_2"), t(lang(req), "admin_wfstep_col_3"), t(lang(req), "admin_wfstep_col_4"), t(lang(req), "admin_wfstep_col_5"), t(lang(req), "admin_wfstep_col_6"), t(lang(req), "admin_wfstep_col_7") ]) v["workflow"] = workflow v["workflowsteps"] = workflowsteps v["pages"] = pages v["actfilter"] = actfilter return req.getTAL("web/admin/modules/workflows.html", v, macro="view_step")
def view(req): mappings = list(getMappings()) order = getSortCol(req) actfilter = getFilter(req) # filter if actfilter != "": if actfilter in ("all", "*", t(lang(req), "admin_filter_all")): None # all users elif actfilter == "0-9": num = re.compile(r'([0-9])') mappings = filter(lambda x: num.match(x.getName()), mappings) elif actfilter == "else" or actfilter == t(lang(req), "admin_filter_else"): all = re.compile(r'([a-z]|[A-Z]|[0-9])') mappings = filter(lambda x: not all.match(x.getName()), mappings) else: mappings = filter( lambda x: x.getName().lower().startswith(actfilter), mappings) pages = Overview(req, mappings) # sorting if order != "": if int(order[0:1]) == 0: mappings.sort(lambda x, y: cmp(x.getName().lower(), y.getName().lower())) elif int(order[0:1]) == 1: mappings.sort(lambda x, y: cmp(x.getNamespace().lower(), y.getNamespace().lower())) elif int(order[0:1]) == 2: mappings.sort(lambda x, y: cmp(x.getNamespaceUrl().lower(), y.getNamespaceUrl().lower())) elif int(order[0:1]) == 3: mappings.sort(lambda x, y: cmp(x.getDescription().lower(), y.getDescription().lower())) elif int(order[0:1]) == 4: mappings.sort( lambda x, y: cmp(len(x.getFields()), len(y.getFields()))) elif int(order[0:1]) == 5: mappings.sort( lambda x, y: cmp(x.getMappingType(), y.getMappingType())) elif int(order[0:1]) == 6: mappings.sort(lambda x, y: cmp(x.getActive(), y.getActive())) if int(order[1:]) == 1: mappings.reverse() else: mappings.sort(lambda x, y: cmp(x.getName().lower(), y.getName().lower())) v = getAdminStdVars(req) v["sortcol"] = pages.OrderColHeader([ t(lang(req), "admin_mapping_col_1"), t(lang(req), "admin_mapping_col_2"), t(lang(req), "admin_mapping_col_3"), t(lang(req), "admin_mapping_col_4"), t(lang(req), "admin_mapping_col_5"), t(lang(req), "admin_mapping_col_6"), t(lang(req), "admin_mapping_col_7") ]) v["mappings"] = mappings v["options"] = [] v["pages"] = pages v["actfilter"] = actfilter v["mappingtypes"] = "\n".join(getMappingTypes()) return req.getTAL("web/admin/modules/mapping.html", v, macro="view")
def view(req): mtypes = loadTypesFromDB() actfilter = getFilter(req) # filter if actfilter != "": if actfilter in ("all", "*", t(lang(req), "admin_filter_all")): None # all users elif actfilter == "0-9": num = re.compile(r'([0-9])') if req.params.get("filtertype", "") == "id": mtypes = filter(lambda x: num.match(x.getName()), mtypes) else: mtypes = filter(lambda x: num.match(x.getLongName()), mtypes) elif actfilter == "else" or actfilter == t(lang(req), "admin_filter_else"): all = re.compile(r'([a-z]|[A-Z]|[0-9]|\.)') if req.params.get("filtertype", "") == "id": mtypes = filter(lambda x: not all.match(x.getName()), mtypes) else: mtypes = filter(lambda x: not all.match(x.getLongName()), mtypes) else: if req.params.get("filtertype", "") == "id": mtypes = filter(lambda x: x.getName().lower().startswith(actfilter), mtypes) else: mtypes = filter(lambda x: x.getLongName().lower().startswith(actfilter), mtypes) pages = Overview(req, mtypes) order = getSortCol(req) # sorting if order != "": if int(order[0:1]) == 0: mtypes.sort(lambda x, y: cmp(x.getName().lower(), y.getName().lower())) elif int(order[0:1]) == 1: mtypes.sort(lambda x, y: cmp(x.getLongName().lower(), y.getLongName().lower())) elif int(order[0:1]) == 2: mtypes.sort(lambda x, y: cmp(x.getDescription().lower(), y.getDescription().lower())) elif int(order[0:1]) == 3: mtypes.sort(lambda x, y: cmp(x.getActive(), y.getActive())) elif int(order[0:1]) == 4: mtypes.sort(lambda x, y: cmp(x.getDatatypeString().lower(), y.getDatatypeString().lower())) elif int(order[0:1]) == 5: mtypes.sort(lambda x, y: cmp(x.metadatatype.getAccess("read"), y.metadatatype.getAccess("read"))) elif int(order[0:1]) == 6: mtypes.sort(lambda x, y: cmp(x.searchIndexCorrupt(), y.searchIndexCorrupt())) elif int(order[0:1]) == 7: mtypes.sort(lambda x, y: cmp(len(x.getAllItems()), len(y.getAllItems()))) if int(order[1:]) == 1: mtypes.reverse() else: mtypes.sort(lambda x, y: cmp(x.getName().lower(), y.getName().lower())) v = getAdminStdVars(req) v["sortcol"] = pages.OrderColHeader( [ t( lang(req), "admin_meta_col_1"), t( lang(req), "admin_meta_col_2"), t( lang(req), "admin_meta_col_3"), t( lang(req), "admin_meta_col_4"), t( lang(req), "admin_meta_col_5"), t( lang(req), "admin_meta_col_6")]) v["metadatatypes"] = mtypes v["datatypes"] = loadAllDatatypes() v["datatypes"].sort(lambda x, y: cmp(t(lang(req), x.getLongName()), t(lang(req), y.getLongName()))) v["pages"] = pages v["actfilter"] = actfilter v["filterattrs"] = [("id", "admin_metatype_filter_id"), ("name", "admin_metatype_filter_name")] v["filterarg"] = req.params.get("filtertype", "id") return req.getTAL("web/admin/modules/metatype.html", v, macro="view_type")