Пример #1
0
def WorkflowDetail(req, id, err=0):
    v = getAdminStdVars(req)
    if err == 0 and id == "":
        # new workflow
        workflow = tree.Node("", type="workflow")
        v["original_name"] = ""

    elif id != "" and err == 0:
        # edit workflow
        workflow = getWorkflow(id)
        v["original_name"] = workflow.getName()

    else:
        # error
        workflow = tree.Node("", type="workflow")
        workflow.setName(req.params.get("name", ""))
        workflow.setDescription(req.params.get("description", ""))
        #workflow.setAccess("write", req.params.get("writeaccess", ""))
        v["original_name"] = req.params.get("orig_name", "")
        workflow.id = req.params.get("id")

    rule = {"read": str(workflow.getAccess("read") or "").split(","), "write": str(workflow.getAccess("write") or "").split(",")}

    v["acl_read"] = makeList(req, "read", removeEmptyStrings(rule["read"]), {}, overload=0, type="read")
    v["acl_write"] = makeList(req, "write", removeEmptyStrings(rule["write"]), {}, overload=0, type="write")
    v["workflow"] = workflow
    v["languages"] = config.get("i18n.languages", "en").split(",")
    v["error"] = err
    v["rules"] = getRuleList()
    v["actpage"] = req.params.get("actpage")
    return req.getTAL("web/admin/modules/workflows.html", v, macro="modify")
Пример #2
0
def WorkflowDetail(req, id, err=0):
    v = getAdminStdVars(req)
    if err == 0 and id == "":
        # new workflow
        workflow = Workflow(u"")
        db.session.commit()
        v["original_name"] = ""

    elif id != "" and err == 0:
        # edit workflow
        workflow = getWorkflow(id)
        v["original_name"] = workflow.name

    else:
        # error
        workflow = Workflow(u"")
        workflow.name = req.params.get("name", "")
        workflow.set("description", req.params.get("description", ""))
        #workflow.setAccess("write", req.params.get("writeaccess", ""))
        v["original_name"] = req.params.get("orig_name", "")
        workflow.id = req.params.get("id")
        db.session.commit()

    try:
        rule = {
            "read": [
                r.ruleset_name
                for r in workflow.access_ruleset_assocs.filter_by(
                    ruletype='read')
            ],
            "write": [
                r.ruleset_name
                for r in workflow.access_ruleset_assocs.filter_by(
                    ruletype='write')
            ]
        }
    except:
        rule = {"read": [], "write": []}

    v["acl_read"] = makeList(req,
                             "read",
                             removeEmptyStrings(rule["read"]), {},
                             overload=0,
                             type="read")
    v["acl_write"] = makeList(req,
                              "write",
                              removeEmptyStrings(rule["write"]), {},
                              overload=0,
                              type="write")
    v["workflow"] = workflow
    v["languages"] = config.languages
    v["error"] = err
    v["actpage"] = req.params.get("actpage")
    v["csrf"] = req.csrf_token.current_token
    return req.getTAL("web/admin/modules/workflows.html", v, macro="modify")
Пример #3
0
def MetatypeDetail(req, id, err=0):
    v = getAdminStdVars(req)

    if err == 0 and id == "":
        # new metadatatype
        metadatatype = Metadatatype(u"")
        db.session.commit()
        v["original_name"] = ""

    elif id != "" and err == 0:
        # edit metadatatype
        metadatatype = getMetaType(id)
        v["original_name"] = metadatatype.getName()

    else:
        # error
        metadatatype = Metadatatype(req.params["mname"])
        metadatatype.set("description", req.params["description"])
        metadatatype.set("longname", req.params["mlongname"])
        metadatatype.set("active", "mactive" in req.params)
        metadatatype.set("datatypes",
                         req.params.get("mdatatypes", "").replace(";", ", "))
        metadatatype.set("bibtexmapping", req.params.get("mbibtex", ""))
        metadatatype.set("citeprocmapping", req.params.get("mciteproc", ""))
        db.session.commit()
        v["original_name"] = req.params["mname_orig"]
    d = Data()
    v["datatypes"] = d.get_all_datatypes()
    v["datatypes"].sort(
        lambda x, y: cmp(t(lang(req), x.__name__), t(lang(req), y.__name__)))
    v["metadatatype"] = metadatatype
    v["error"] = err
    v["bibtextypes"] = getAllBibTeXTypes()
    v["bibtexselected"] = metadatatype.get("bibtexmapping").split(";")
    v["citeproctypes"] = citeproc.TYPES
    v["citeprocselected"] = metadatatype.get("citeprocmapping").split(";")

    try:
        rules = [
            r.ruleset_name
            for r in metadatatype.access_ruleset_assocs.filter_by(
                ruletype=u'read')
        ]
    except:
        rules = []

    v["acl"] = makeList(req,
                        "read",
                        removeEmptyStrings(rules), {},
                        overload=0,
                        type="read")
    v["filtertype"] = req.params.get("filtertype", "")
    v["actpage"] = req.params.get("actpage")
    v["csrf"] = req.csrf_token.current_token
    return req.getTAL("web/admin/modules/metatype.html",
                      v,
                      macro="modify_type")
Пример #4
0
def WorkflowDetail(req, id, err=0):
    v = getAdminStdVars(req)
    if err == 0 and id == "":
        # new workflow
        workflow = tree.Node("", type="workflow")
        v["original_name"] = ""

    elif id != "" and err == 0:
        # edit workflow
        workflow = getWorkflow(id)
        v["original_name"] = workflow.getName()

    else:
        # error
        workflow = tree.Node("", type="workflow")
        workflow.setName(req.params.get("name", ""))
        workflow.setDescription(req.params.get("description", ""))
        #workflow.setAccess("write", req.params.get("writeaccess", ""))
        v["original_name"] = req.params.get("orig_name", "")
        workflow.id = req.params.get("id")

    rule = {
        "read": str(workflow.getAccess("read") or "").split(","),
        "write": str(workflow.getAccess("write") or "").split(",")
    }

    v["acl_read"] = makeList(req,
                             "read",
                             removeEmptyStrings(rule["read"]), {},
                             overload=0,
                             type="read")
    v["acl_write"] = makeList(req,
                              "write",
                              removeEmptyStrings(rule["write"]), {},
                              overload=0,
                              type="write")
    v["workflow"] = workflow
    v["languages"] = config.get("i18n.languages", "en").split(",")
    v["error"] = err
    v["rules"] = getRuleList()
    v["actpage"] = req.params.get("actpage")
    return req.getTAL("web/admin/modules/workflows.html", v, macro="modify")
Пример #5
0
def WorkflowDetail(req, id, err=0):
    v = getAdminStdVars(req)
    if err == 0 and id == "":
        # new workflow
        workflow = Workflow(u"")
        db.session.commit()
        v["original_name"] = ""

    elif id != "" and err == 0:
        # edit workflow
        workflow = getWorkflow(id)
        v["original_name"] = workflow.name

    else:
        # error
        workflow = Workflow(u"")
        workflow.name = req.params.get("name", "")
        workflow.set("description", req.params.get("description", ""))
        #workflow.setAccess("write", req.params.get("writeaccess", ""))
        v["original_name"] = req.params.get("orig_name", "")
        workflow.id = req.params.get("id")
        db.session.commit()

    try:
        rule = {"read": [r.ruleset_name for r in workflow.access_ruleset_assocs.filter_by(ruletype='read')],
                "write": [r.ruleset_name for r in workflow.access_ruleset_assocs.filter_by(ruletype='write')]}
    except:
        rule = {"read": [], "write": []}

    v["acl_read"] = makeList(req, "read", removeEmptyStrings(rule["read"]), {}, overload=0, type="read")
    v["acl_write"] = makeList(req, "write", removeEmptyStrings(rule["write"]), {}, overload=0, type="write")
    v["workflow"] = workflow
    v["languages"] = config.languages
    v["error"] = err
    v["actpage"] = req.params.get("actpage")
    v["csrf"] = req.csrf_token.current_token
    return req.getTAL("web/admin/modules/workflows.html", v, macro="modify")
Пример #6
0
def MetatypeDetail(req, id, err=0):
    v = getAdminStdVars(req)

    if err == 0 and id == "":
        # new metadatatype
        metadatatype = tree.Node("", type="metadatatype")
        v["original_name"] = ""

    elif id != "" and err == 0:
        # edit metadatatype
        metadatatype = getMetaType(id)
        v["original_name"] = metadatatype.getName()

    else:
        # error
        metadatatype = tree.Node(req.params["mname"], type="metadatatype")
        metadatatype.setDescription(req.params["description"])
        metadatatype.setLongName(req.params["mlongname"])
        metadatatype.setActive("mactive" in req.params)
        metadatatype.setDatatypeString(req.params.get("mdatatypes", "").replace(";", ", "))
        metadatatype.set("bibtexmapping", req.params.get("mbibtex", ""))
        metadatatype.set("citeprocmapping", req.params.get("mciteproc", ""))

        v["original_name"] = req.params["mname_orig"]

    v["datatypes"] = loadNonSystemTypes()
    v["datatypes"].sort(lambda x, y: cmp(t(lang(req), x.getLongName()), t(lang(req), y.getLongName())))
    v["metadatatype"] = metadatatype
    v["error"] = err
    v["bibtextypes"] = getAllBibTeXTypes()
    v["bibtexselected"] = metadatatype.get("bibtexmapping").split(";")
    v["citeproctypes"] = citeproc.TYPES
    v["citeprocselected"] = metadatatype.get("citeprocmapping").split(";")

    rule = metadatatype.getAccess("read")
    if rule:
        rule = rule.split(",")
    else:
        rule = []

    rights = removeEmptyStrings(rule)
    v["acl"] = makeList(req, "read", rights, {}, overload=0, type="read")
    v["filtertype"] = req.params.get("filtertype", "")
    v["actpage"] = req.params.get("actpage")
    return req.getTAL("web/admin/modules/metatype.html", v, macro="modify_type")
Пример #7
0
def MetatypeDetail(req, id, err=0):
    v = getAdminStdVars(req)

    if err == 0 and id == "":
        # new metadatatype
        metadatatype = Metadatatype(u"")
        db.session.commit()
        v["original_name"] = ""

    elif id != "" and err == 0:
        # edit metadatatype
        metadatatype = getMetaType(id)
        v["original_name"] = metadatatype.getName()

    else:
        # error
        metadatatype = Metadatatype(req.params["mname"])
        metadatatype.set("description", req.params["description"])
        metadatatype.set("longname", req.params["mlongname"])
        metadatatype.set("active", "mactive" in req.params)
        metadatatype.set("datatypes", req.params.get("mdatatypes", "").replace(";", ", "))
        metadatatype.set("bibtexmapping", req.params.get("mbibtex", ""))
        metadatatype.set("citeprocmapping", req.params.get("mciteproc", ""))
        db.session.commit()
        v["original_name"] = req.params["mname_orig"]
    d = Data()
    v["datatypes"] = d.get_all_datatypes()
    v["datatypes"].sort(lambda x, y: cmp(t(lang(req), x.__name__), t(lang(req), y.__name__)))
    v["metadatatype"] = metadatatype
    v["error"] = err
    v["bibtextypes"] = getAllBibTeXTypes()
    v["bibtexselected"] = metadatatype.get("bibtexmapping").split(";")
    v["citeproctypes"] = citeproc.TYPES
    v["citeprocselected"] = metadatatype.get("citeprocmapping").split(";")

    try:
        rules = [r.ruleset_name for r in metadatatype.access_ruleset_assocs.filter_by(ruletype=u'read')]
    except:
        rules = []

    v["acl"] = makeList(req, "read", removeEmptyStrings(rules), {}, overload=0, type="read")
    v["filtertype"] = req.params.get("filtertype", "")
    v["actpage"] = req.params.get("actpage")
    v["csrf"] = req.csrf_token.current_token
    return req.getTAL("web/admin/modules/metatype.html", v, macro="modify_type")
Пример #8
0
def MaskDetails(req, pid, id, err=0):
    mtype = getMetaType(pid)

    if err == 0 and id == "":
        # new mask
        mask = Mask(u"")
        db.session.commit()
    elif id != "" and err == 0:
        # edit mask
        if id.isdigit():
            mask = q(Mask).get(id)
            db.session.commit()
        else:
            mask = mtype.getMask(id)

    else:
        # error filling values
        mask = Mask(req.params.get("mname", ""))
        mask.setDescription(req.params.get("mdescription", ""))
        mask.setMasktype(req.params.get("mtype"))
        mask.setLanguage(req.params.get("mlanguage", ""))
        mask.setDefaultMask(req.params.get("mdefault", False))
        db.session.commit()

    v = getAdminStdVars(req)
    v["mask"] = mask
    v["mappings"] = getMappings()
    v["mtype"] = mtype
    v["error"] = err
    v["pid"] = pid
    v["masktypes"] = getMaskTypes()
    v["id"] = id
    v["langs"] = config.languages
    v["actpage"] = req.params.get("actpage")

    try:
        rules = [r.ruleset_name for r in mask.access_ruleset_assocs.filter_by(ruletype=u'read')]
    except:
        rules = []

    v["acl"] = makeList(req, "read", removeEmptyStrings(rules), {}, overload=0, type=u"read")
    v["csrf"] = req.csrf_token.current_token

    return req.getTAL("web/admin/modules/metatype_mask.html", v, macro="modify_mask")
Пример #9
0
def MaskDetails(req, pid, id, err=0):
    mtype = getMetaType(pid)

    if err == 0 and id == "":
        # new mask
        mask = tree.Node("", type="mask")

    elif id != "" and err == 0:
        # edit mask
        if id.isdigit():
            mask = tree.getNode(id)
        else:
            mask = mtype.getMask(id)

    else:
        # error filling values
        mask = tree.Node(req.params.get("mname", ""), type="mask")
        mask.setDescription(req.params.get("mdescription", ""))
        mask.setMasktype(req.params.get("mtype"))
        mask.setLanguage(req.params.get("mlanguage", ""))
        mask.setDefaultMask(req.params.get("mdefault", False))

    v = getAdminStdVars(req)
    v["mask"] = mask
    v["mappings"] = getMappings()
    v["mtype"] = mtype
    v["error"] = err
    v["pid"] = pid
    v["masktypes"] = getMaskTypes()
    v["id"] = id
    v["langs"] = config.get("i18n.languages").split(",")
    v["actpage"] = req.params.get("actpage")

    rule = mask.getAccess("read")
    if rule:
        rule = rule.split(",")
    else:
        rule = []

    rights = removeEmptyStrings(rule)
    v["acl"] = makeList(req, "read", rights, {}, overload=0, type="read")

    return req.getTAL("web/admin/modules/metatype_mask.html", v, macro="modify_mask")
Пример #10
0
def getContent(req, ids):
    ret = ""
    user = users.getUserFromRequest(req)
    access = acl.AccessData(req)
    for id in ids:
        if not access.hasWriteAccess(tree.getNode(id)) or "acls" in users.getHideMenusForUser(user):
            req.setStatus(httpstatus.HTTP_FORBIDDEN)
            return req.getTAL("web/edit/edit.html", {}, macro="access_error")

    idstr = ",".join(ids)

    if "save" in req.params:
        # save acl level

        userdir = users.getHomeDir(user)
        logging.getLogger('usertracing').info(access.user.name + " change access " + idstr)

        if req.params.get("type") == "acl":
            for type in acl_types:
                rights = req.params.get("left" + type, "").replace(";", ",")
                for id in ids:
                    node = tree.getNode(id)
                    error = 0
                    if access.hasWriteAccess(node) and userdir.id != node.id:
                        node.setAccess(type, rights)
                    else:
                        error = 1
                    if error:
                        req.setStatus(httpstatus.HTTP_FORBIDDEN)
                        return req.getTAL("web/edit/edit.html", {}, macro="access_error")

        # save userlevel
        elif req.params.get("type") == "user":

            for type in acl_types:
                for id in ids:
                    node = tree.getNode(id)
                    error = 0
                    if access.hasWriteAccess(node) and userdir.id != node.id:
                        r = []
                        r_acls = []
                        if req.params.get("leftuser" + type, "") != "":
                            for right in req.params.get("leftuser" + type, "").split(";"):
                                if len(right.split(": ")) == 2:
                                    r.append("(user " + right.split(": ")[1] + ")")
                                else:
                                    r_acls.append(right)

                                if len(r) > 0:
                                    rstr = "{" + " OR ".join(r) + "}"
                                else:
                                    rstr = req.params.get("leftuser" + type, "")

                                if len(rstr) > 0:
                                    rstr += ","

                                for x in r_acls:
                                    rstr += x + ","

                                rstr = rstr[:-1]
                        else:
                            rstr = ""
                        node.setAccess(type, rstr)
                    else:
                        error = 1
                    if error:
                        req.setStatus(httpstatus.HTTP_FORBIDDEN)
                        return req.getTAL("web/edit/edit.html", {}, macro="access_error")

    runsubmit = "\nfunction runsubmit(){\n"
    retacl = ""
    rights = {}
    parent_rights = {}
    overload = {}
    for type in acl_types:
        s = None
        parent_rights[type] = {}
        overload[type] = 0

        runsubmit += "\tmark(document.myform.left" + type + ");\n"
        runsubmit += "\tmark(document.myform.leftuser" + type + ");\n"

        if type in ("read", "data"):
            overload[type] = 1

        for id in ids:
            node = tree.getNode(id)
            r = node.getAccess(type)
            if r is None:
                r = ""
            log.debug(node.name + " " + type + " " + r)
            if not s or r == s:
                s = r
            else:
                s = ""

            def addNode(node):
                for p in node.getParents():
                    aclright = p.getAccess(type)
                    for right in removeEmptyStrings((aclright or "").split(",")):
                        parent_rights[type][right] = None
                    if aclright and overload[type]:
                        return
                    else:
                        addNode(p)
            addNode(node)
        rights[type] = removeEmptyStrings(s.split(","))

    for type in acl_types:
        retacl += req.getTAL("web/edit/modules/acls.html",
                             makeList(req,
                                      type,
                                      rights[type],
                                      parent_rights[type].keys(),
                                      overload[type],
                                      type=type),
                             macro="edit_acls_selectbox")

    if "action" in req.params.keys():  # load additional rights by ajax
        retuser = ""
        for type in acl_types:
            retuser += req.getTAL("web/edit/modules/acls.html",
                                  makeUserList(req,
                                               type,
                                               rights[type],
                                               parent_rights[type].keys(),
                                               overload[type],
                                               type=type),
                                  macro="edit_acls_userselectbox")
        req.write(retuser)
        return ""

    runsubmit += "\tdocument.myform.submit();\n}\n"

    return req.getTAL("web/edit/modules/acls.html", {"runsubmit": runsubmit, "idstr": idstr,
                                                     "contentacl": retacl, "adminuser": access.getUser().isAdmin()}, macro="edit_acls")
Пример #11
0
def getContent(req, ids):
    ret = ""
    user = users.getUserFromRequest(req)
    access = acl.AccessData(req)
    for id in ids:
        if not access.hasWriteAccess(
                tree.getNode(id)) or "acls" in users.getHideMenusForUser(user):
            req.setStatus(httpstatus.HTTP_FORBIDDEN)
            return req.getTAL("web/edit/edit.html", {}, macro="access_error")

    idstr = ",".join(ids)

    if "save" in req.params:
        # save acl level

        userdir = users.getHomeDir(user)
        logging.getLogger('usertracing').info(access.user.name +
                                              " change access " + idstr)

        if req.params.get("type") == "acl":
            for type in acl_types:
                rights = req.params.get("left" + type, "").replace(";", ",")
                for id in ids:
                    node = tree.getNode(id)
                    error = 0
                    if access.hasWriteAccess(node) and userdir.id != node.id:
                        node.setAccess(type, rights)
                    else:
                        error = 1
                    if error:
                        req.setStatus(httpstatus.HTTP_FORBIDDEN)
                        return req.getTAL("web/edit/edit.html", {},
                                          macro="access_error")

        # save userlevel
        elif req.params.get("type") == "user":

            for type in acl_types:
                for id in ids:
                    node = tree.getNode(id)
                    error = 0
                    if access.hasWriteAccess(node) and userdir.id != node.id:
                        r = []
                        r_acls = []
                        if req.params.get("leftuser" + type, "") != "":
                            for right in req.params.get("leftuser" + type,
                                                        "").split(";"):
                                if len(right.split(": ")) == 2:
                                    r.append("(user " + right.split(": ")[1] +
                                             ")")
                                else:
                                    r_acls.append(right)

                                if len(r) > 0:
                                    rstr = "{" + " OR ".join(r) + "}"
                                else:
                                    rstr = req.params.get(
                                        "leftuser" + type, "")

                                if len(rstr) > 0:
                                    rstr += ","

                                for x in r_acls:
                                    rstr += x + ","

                                rstr = rstr[:-1]
                        else:
                            rstr = ""
                        node.setAccess(type, rstr)
                    else:
                        error = 1
                    if error:
                        req.setStatus(httpstatus.HTTP_FORBIDDEN)
                        return req.getTAL("web/edit/edit.html", {},
                                          macro="access_error")

    runsubmit = "\nfunction runsubmit(){\n"
    retacl = ""
    rights = {}
    parent_rights = {}
    overload = {}
    for type in acl_types:
        s = None
        parent_rights[type] = {}
        overload[type] = 0

        runsubmit += "\tmark(document.myform.left" + type + ");\n"
        runsubmit += "\tmark(document.myform.leftuser" + type + ");\n"

        if type in ("read", "data"):
            overload[type] = 1

        for id in ids:
            node = tree.getNode(id)
            r = node.getAccess(type)
            if r is None:
                r = ""
            log.debug(node.name + " " + type + " " + r)
            if not s or r == s:
                s = r
            else:
                s = ""

            def addNode(node):
                for p in node.getParents():
                    aclright = p.getAccess(type)
                    for right in removeEmptyStrings((aclright
                                                     or "").split(",")):
                        parent_rights[type][right] = None
                    if aclright and overload[type]:
                        return
                    else:
                        addNode(p)

            addNode(node)
        rights[type] = removeEmptyStrings(s.split(","))

    for type in acl_types:
        retacl += req.getTAL("web/edit/modules/acls.html",
                             makeList(req,
                                      type,
                                      rights[type],
                                      parent_rights[type].keys(),
                                      overload[type],
                                      type=type),
                             macro="edit_acls_selectbox")

    if "action" in req.params.keys():  # load additional rights by ajax
        retuser = ""
        for type in acl_types:
            retuser += req.getTAL("web/edit/modules/acls.html",
                                  makeUserList(req,
                                               type,
                                               rights[type],
                                               parent_rights[type].keys(),
                                               overload[type],
                                               type=type),
                                  macro="edit_acls_userselectbox")
        req.write(retuser)
        return ""

    runsubmit += "\tdocument.myform.submit();\n}\n"

    return req.getTAL("web/edit/modules/acls.html", {
        "runsubmit": runsubmit,
        "idstr": idstr,
        "contentacl": retacl,
        "adminuser": access.getUser().isAdmin()
    },
                      macro="edit_acls")
Пример #12
0
def WorkflowStepDetail(req, wid, wnid, err=0):
    workflow = getWorkflow(wid)
    nodelist = workflow.getSteps()
    v = getAdminStdVars(req)

    if err == 0 and wnid == "":
        # new workflowstep
        workflowstep = createWorkflowStep(name="",
                                          trueid="",
                                          falseid="",
                                          truelabel="",
                                          falselabel="",
                                          comment="")
        v["orig_name"] = req.params.get("orig_name", "")

    elif err == -1:
        # update steptype
        if req.params.get("stepid", ""):
            workflowstep = updateWorkflowStep(
                workflow,
                oldname=req.params.get("nname", ""),
                newname=req.params.get("nname", ""),
                type=req.params.get("ntype", "workflowstep"),
                trueid=req.params.get("ntrueid", ""),
                falseid=req.params.get("nfalseid", ""),
                truelabel=req.params.get("ntruelabel", ""),
                falselabel=req.params.get("nfalselabel", ""),
                comment=req.params.get("ncomment", ""))
        else:
            err = 0
            workflowstep = createWorkflowStep(
                name=req.params.get("nname", ""),
                type=req.params.get("ntype", "workflowstep"),
                trueid=req.params.get("ntrueid", ""),
                falseid=req.params.get("nfalseid", ""),
                truelabel=req.params.get("ntruelabel", ""),
                falselabel=req.params.get("nfalselabel", ""),
                comment=req.params.get("ncomment", ""))
        v["orig_name"] = workflowstep.name

    elif wnid != "" and req.params.get("nname") != "":
        # edit field
        workflowstep = workflow.getStep(wnid)
        v["orig_name"] = workflowstep.name
    else:
        # error while filling values
        type = req.params.get("ntype", "workflowstep")
        if type == "":
            type = "workflowstep"
        workflowstep = createWorkflowStep(
            name=req.params.get("nname", ""),
            type=type,
            trueid=req.params.get("ntrueid", ""),
            falseid=req.params.get("nfalseid", ""),
            truelabel=req.params.get("ntruelabel", ""),
            falselabel=req.params.get("nfalselabel", ""),
            comment=req.params.get("ncomment", ""))
        v["orig_name"] = req.params.get("orig_name", "")

    if req.params.get("nytype", "") != "":
        workflowstep.setType(req.params.get("nytype", ""))

    v_part = {}
    v_part["fields"] = workflowstep.metaFields(lang(req)) or []
    v_part["node"] = workflowstep
    v_part["hiddenvalues"] = {"wnodeid": workflowstep.name}

    try:
        rule = {
            "read": [
                r.ruleset_name
                for r in workflowstep.access_ruleset_assocs.filter_by(
                    ruletype='read')
            ],
            "write": [
                r.ruleset_name
                for r in workflowstep.access_ruleset_assocs.filter_by(
                    ruletype='write')
            ]
        }
    except:
        rule = {"read": [], "write": []}

    v["acl_read"] = makeList(req,
                             "read",
                             removeEmptyStrings(rule["read"]), {},
                             overload=0,
                             type="read")
    v["acl_write"] = makeList(req,
                              "write",
                              removeEmptyStrings(rule["write"]), {},
                              overload=0,
                              type="write")
    v["editor"] = req.getTAL("web/admin/modules/workflows.html",
                             v_part,
                             macro="view_editor")
    v["workflow"] = workflow
    v["workflowstep"] = workflowstep
    v["nodelist"] = nodelist
    v["workflowtypes"] = getWorkflowTypes()
    v["error"] = err
    v["update_type"] = req.params.get("ntype", u"")
    v["actpage"] = req.params.get("actpage")
    return req.getTAL("web/admin/modules/workflows.html",
                      v,
                      macro="modify_step")
Пример #13
0
def WorkflowStepDetail(req, wid, wnid, err=0):

    workflow = getWorkflow(wid)
    nodelist = workflow.getSteps()
    v = getAdminStdVars(req)

    if err == 0 and wnid == "":
        # new workflowstep
        workflowstep = createWorkflowStep(name="", trueid="", falseid="", truelabel="", falselabel="", comment="")
        workflowstep.id = ""
        v["orig_name"] = req.params.get("orig_name", "")

    elif err == -1:
        # update steptype
        if req.params.get("stepid", ""):
            workflowstep = updateWorkflowStep(
                workflow, oldname=req.params.get(
                    "nname", ""), newname=req.params.get(
                    "nname", ""), type=req.params.get(
                    "ntype", "workflowstep"), trueid=req.params.get(
                    "ntrueid", ""), falseid=req.params.get(
                        "nfalseid", ""), truelabel=req.params.get(
                            "ntruelabel", ""), falselabel=req.params.get(
                                "nfalselabel", ""), comment=req.params.get(
                                    "ncomment", ""))
        else:
            err = 0
            workflowstep = createWorkflowStep(
                name=req.params.get(
                    "nname", ""), type=req.params.get(
                    "ntype", "workflowstep"), trueid=req.params.get(
                    "ntrueid", ""), falseid=req.params.get(
                    "nfalseid", ""), truelabel=req.params.get(
                        "ntruelabel", ""), falselabel=req.params.get(
                            "nfalselabel", ""), comment=req.params.get(
                                "ncomment", ""))
            if req.params.get("wnid", "") == "":
                workflowstep.id = ""
        v["orig_name"] = workflowstep.getName()

    elif wnid != "" and req.params.get("nname") != "":
        # edit field
        workflowstep = workflow.getStep(wnid)
        v["orig_name"] = workflowstep.getName()
    else:
        # error while filling values
        type = req.params.get("ntype", "workflowstep")
        if type == "":
            type = "workflowstep"
        workflowstep = createWorkflowStep(
            name=req.params.get(
                "nname", ""), type=type, trueid=req.params.get(
                "ntrueid", ""), falseid=req.params.get(
                "nfalseid", ""), truelabel=req.params.get(
                    "ntruelabel", ""), falselabel=req.params.get(
                        "nfalselabel", ""), comment=req.params.get(
                            "ncomment", ""))
        v["orig_name"] = req.params.get("orig_name", "")

    if req.params.get("nytype", "") != "":
        workflowstep.setType(req.params.get("nytype", ""))

    v_part = {}
    v_part["fields"] = workflowstep.metaFields(lang(req)) or []
    v_part["node"] = workflowstep
    v_part["hiddenvalues"] = {"wnodeid": workflowstep.name}

    rule = {"read": str(workflowstep.getAccess("read") or "").split(","), "write": str(workflowstep.getAccess("write") or "").split(",")}
    v["acl_read"] = makeList(req, "read", removeEmptyStrings(rule["read"]), {}, overload=0, type="read")
    v["acl_write"] = makeList(req, "write", removeEmptyStrings(rule["write"]), {}, overload=0, type="write")
    v["editor"] = req.getTAL("web/admin/modules/workflows.html", v_part, macro="view_editor")
    v["workflow"] = workflow
    v["workflowstep"] = workflowstep
    v["nodelist"] = nodelist
    v["workflowtypes"] = getWorkflowTypes()
    v["error"] = err
    v["update_type"] = req.params.get("ntype", "")
    v["actpage"] = req.params.get("actpage")
    return req.getTAL("web/admin/modules/workflows.html", v, macro="modify_step")