Beispiel #1
0
def output_format_update_attributes(req,
                                    bfo,
                                    ln=CFG_SITE_LANG,
                                    name="",
                                    description="",
                                    code="",
                                    content_type="",
                                    names_trans=[],
                                    visibility="0"):
    """
    Update the name, description and code of given output format

    @param req: the request object
    @param ln: language
    @param description: the new description
    @param name: the new name
    @param code: the new short code (== new bfo) of the output format
    @param content_type: the new content_type of the output format
    @param bfo: the filename of the output format to update
    @param names_trans: the translations in the same order as the languages from get_languages()
    @param visibility: the visibility of the output format in the output formats list (public pages)
    @return: a web page (or redirection to a web page)
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    try:
        uid = getUid(req)
    except:
        return error_page('Error', req)

    (auth_code, auth_msg) = check_user(req, 'cfgbibformat')
    if not auth_code:

        name = wash_url_argument(name, 'str')
        description = wash_url_argument(description, 'str')
        bfo = wash_url_argument(bfo, 'str')
        code = wash_url_argument(code, 'str')
        visibility = wash_url_argument(visibility, 'int')
        bfo = bibformatadminlib.update_output_format_attributes(
            bfo, name, description, code, content_type, names_trans,
            visibility)

        redirect_to_url(
            req, "output_format_show?ln=%(ln)s&bfo=%(bfo)s" % {
                'ln': ln,
                'bfo': bfo,
                'names_trans': names_trans
            })
    else:
        return page_not_authorized(req=req, text=auth_msg)
Beispiel #2
0
def output_format_update_attributes(req, bfo, ln=CFG_SITE_LANG,
                                    name = "", description="",
                                    code="", content_type="",
                                    names_trans=[], visibility="0"):
    """
    Update the name, description and code of given output format

    @param req: the request object
    @param ln: language
    @param description: the new description
    @param name: the new name
    @param code: the new short code (== new bfo) of the output format
    @param content_type: the new content_type of the output format
    @param bfo: the filename of the output format to update
    @param names_trans: the translations in the same order as the languages from get_languages()
    @param visibility: the visibility of the output format in the output formats list (public pages)
    @return: a web page (or redirection to a web page)
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    try:
        uid = getUid(req)
    except:
        return error_page('Error', req)

    (auth_code, auth_msg) = check_user(req, 'cfgbibformat')
    if not auth_code:

        name = wash_url_argument(name, 'str')
        description = wash_url_argument(description, 'str')
        bfo = wash_url_argument(bfo, 'str')
        code = wash_url_argument(code, 'str')
        visibility = wash_url_argument(visibility, 'int')
        bfo = bibformatadminlib.update_output_format_attributes(bfo,
                                                                name,
                                                                description,
                                                                code,
                                                                content_type,
                                                                names_trans,
                                                                visibility)

        redirect_to_url(req, "output_format_show?ln=%(ln)s&bfo=%(bfo)s" % {'ln':ln,
                                                                           'bfo':bfo,
                                                                           'names_trans':names_trans})
    else:
        return page_not_authorized(req=req,
                                   text=auth_msg)
    try:
        uid = getUid(req)
    except MySQLdb.Error, e:
        return error_page(req)

    (auth_code, auth_msg) = check_user(req, "cfgbibformat")
    if not auth_code:

        name = wash_url_argument(name, "str")
        description = wash_url_argument(description, "str")
        bfo = wash_url_argument(bfo, "str")
        code = wash_url_argument(code, "str")
        visibility = wash_url_argument(visibility, "int")
        bfo = bibformatadminlib.update_output_format_attributes(
            bfo, name, description, code, content_type, names_trans, visibility
        )

        redirect_to_url(
            req, "output_format_show?ln=%(ln)s&bfo=%(bfo)s" % {"ln": ln, "bfo": bfo, "names_trans": names_trans}
        )
    else:
        return page_not_authorized(req=req, text=auth_msg)


def output_format_delete(req, bfo, ln=CFG_SITE_LANG, chosen_option=""):
    """
    Delete an output format

    @param req: the request object
    @param bfo: the filename of the output format to delete
Beispiel #4
0
    try:
        uid = getUid(req)
    except MySQLdb.Error, e:
        return error_page(req)

    (auth_code, auth_msg) = check_user(req, 'cfgbibformat')
    if not auth_code:

        name = wash_url_argument(name, 'str')
        description = wash_url_argument(description, 'str')
        bfo = wash_url_argument(bfo, 'str')
        code = wash_url_argument(code, 'str')
        visibility = wash_url_argument(visibility, 'int')
        bfo = bibformatadminlib.update_output_format_attributes(
            bfo, name, description, code, content_type, names_trans,
            visibility)

        redirect_to_url(
            req, "output_format_show?ln=%(ln)s&bfo=%(bfo)s" % {
                'ln': ln,
                'bfo': bfo,
                'names_trans': names_trans
            })
    else:
        return page_not_authorized(req=req, text=auth_msg)


def output_format_delete(req, bfo, ln=CFG_SITE_LANG, chosen_option=""):
    """
    Delete an output format