コード例 #1
0
ファイル: bibformatadmin.py プロジェクト: AlbertoPeon/invenio
def output_format_show_attributes(req, bfo, ln=CFG_SITE_LANG):
    """
    Page for output format names and descrition attributes edition.

    @param req: the request object
    @param ln: language
    @param bfo: the filename of the template to show
    @return: a web page
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = bibformatadminlib.getnavtrail(''' &gt; <a class="navtrail" href="%s/admin/bibformat/bibformatadmin.py/output_formats_manage?ln=%s">%s</a>''' % (CFG_SITE_SECURE_URL, ln , _("Manage Output Formats")))

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

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

        if not bibformatadminlib.can_read_output_format(bfo): #No read permission
            try:
                raise InvenioBibFormatError(_('Output format %s cannot not be read. %s') % (bfo, ""))
            except InvenioBibFormatError, exc:
                register_exception(req=req)
                return page(title=_("Restricted Output Format"),
                            body = """You don't have permission to
                            view this output format.""",
                            language=ln,
                            navtrail = navtrail_previous_links,
                            lastupdated=__lastupdated__,
                            req=req)

        output_format = bibformat_engine.get_output_format(code=bfo,
                                                           with_attributes=True)
        name = output_format['attrs']['names']['generic']

        return page(title=_("Output Format %s Attributes" % name),
                    body=bibformatadminlib.perform_request_output_format_show_attributes(bfo, ln=ln),
                    uid=uid,
                    language=ln,
                    navtrail = navtrail_previous_links ,
                    lastupdated=__lastupdated__,
                    req=req)
コード例 #2
0
                title=_("Restricted Output Format"),
                body="""You don't have permission to
                        view this output format.""",
                language=ln,
                navtrail=navtrail_previous_links,
                errors=[("ERR_BIBFORMAT_CANNOT_READ_OUTPUT_FILE", bfo, "")],
                lastupdated=__lastupdated__,
                req=req,
            )

        output_format = bibformat_engine.get_output_format(code=bfo, with_attributes=True)
        name = output_format["attrs"]["names"]["generic"]

        return page(
            title=_("Output Format %s Attributes" % name),
            body=bibformatadminlib.perform_request_output_format_show_attributes(bfo, ln=ln),
            uid=uid,
            language=ln,
            navtrail=navtrail_previous_links,
            lastupdated=__lastupdated__,
            req=req,
        )

    else:
        return page_not_authorized(req=req, text=auth_msg)


def output_format_show_dependencies(req, bfo, ln=CFG_SITE_LANG):
    """
    Show the dependencies of the given output format.
コード例 #3
0
        if not bibformatadminlib.can_read_output_format(bfo): #No read permission
            return page(title=_("Restricted Output Format"),
                        body = """You don't have permission to
                        view this output format.""",
                        language=ln,
                        navtrail = navtrail_previous_links,
                        errors = [("ERR_BIBFORMAT_CANNOT_READ_OUTPUT_FILE", bfo ,"")],
                        lastupdated=__lastupdated__,
                        req=req)

        output_format = bibformat_engine.get_output_format(code=bfo,
                                                           with_attributes=True)
        name = output_format['attrs']['names']['generic']

        return page(title=_("Output Format %s Attributes" % name),
                    body=bibformatadminlib.perform_request_output_format_show_attributes(bfo, ln=ln),
                    uid=uid,
                    language=ln,
                    navtrail = navtrail_previous_links ,
                    lastupdated=__lastupdated__,
                    req=req)

    else:
        return page_not_authorized(req=req, text=auth_msg)

def output_format_show_dependencies(req, bfo, ln=CFG_SITE_LANG):
    """
    Show the dependencies of the given output format.

    @param ln: language
    @param bfo: the filename of the output format to show