Beispiel #1
0
def editMapping_mask(req, id, err=0):
    if err == 0 and id == "":
        # new mapping
        mapping = tree.Node("", type="mapping")
    elif id != "":
        # edit mapping
        mapping = getMapping(id)
    else:
        # error while filling values
        mapping = tree.Node("", type="mapping")
        mapping.setName(req.params.get("name", ""))
        mapping.setDescription(req.params.get("description", ""))
        mapping.setNamespace(req.params.get("namespace", ""))
        mapping.setNamespaceUrl(req.params.get("namespaceurl", ""))
        mapping.setHeader(req.params.get("header"))
        mapping.setFooter(req.params.get("footer"))
        mapping.setSeparator(req.params.get("separator"))
        mapping.setStandardFormat(req.params.get("standardformat"))

    v = getAdminStdVars(req)
    v["error"] = err
    v["mapping"] = mapping
    v["id"] = id
    v["actpage"] = req.params.get("actpage")
    v["mappingtypes"] = getMappingTypes()
    return req.getTAL("web/admin/modules/mapping.html", v, macro="modify")
Beispiel #2
0
def editMapping_mask(req, id, err=0):
    if err == 0 and id == "":
        # new mapping
        mapping = tree.Node("", type="mapping")
    elif id != "":
        # edit mapping
        mapping = getMapping(id)
    else:
        # error while filling values
        mapping = tree.Node("", type="mapping")
        mapping.setName(req.params.get("name", ""))
        mapping.setDescription(req.params.get("description", ""))
        mapping.setNamespace(req.params.get("namespace", ""))
        mapping.setNamespaceUrl(req.params.get("namespaceurl", ""))
        mapping.setHeader(req.params.get("header"))
        mapping.setFooter(req.params.get("footer"))
        mapping.setSeparator(req.params.get("separator"))
        mapping.setStandardFormat(req.params.get("standardformat"))

    v = getAdminStdVars(req)
    v["error"] = err
    v["mapping"] = mapping
    v["id"] = id
    v["actpage"] = req.params.get("actpage")
    v["mappingtypes"] = getMappingTypes()
    return req.getTAL("web/admin/modules/mapping.html", v, macro="modify")
Beispiel #3
0
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")
Beispiel #4
0
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")