def format_template_show_attributes(req, bft, ln=CFG_SITE_LANG, new=0): """ Page for template name and descrition attributes edition. This is also the first page shown when a format template has just been added. In that case new is different from False and we can offer specific option to user (for ex let him make a duplicate of existing template). @param req: the request object @param ln: language @param bft: the name of the template to show @param new: if "False", the template has not just been added @return: a web page """ ln = wash_language(ln) _ = gettext_set_language(ln) navtrail_previous_links = bibformatadminlib.getnavtrail(''' > <a class="navtrail" href="%s/admin/bibformat/bibformatadmin.py/format_templates_manage?ln=%s">%s</a>''' % (CFG_SITE_SECURE_URL, ln, _("Manage Format Templates"))) try: uid = getUid(req) except: return error_page('Error', req) (auth_code, auth_msg) = check_user(req, 'cfgbibformat') if not auth_code: format_template = wash_url_argument(bft, 'str') format_name = bibformat_engine.get_format_template_attrs(bft)['name'] is_new = wash_url_argument(new, 'int') if not bibformatadminlib.can_read_format_template(bft): #No read permission try: raise InvenioBibFormatError(_('Format template %s cannot not be read. %s') % (format_template, "")) except InvenioBibFormatError, exc: register_exception(req=req) return page(title=_("Restricted Format Template"), body = """You don't have permission to view this format template.""", language=ln, navtrail = navtrail_previous_links, lastupdated=__lastupdated__, req=req) return page(title=_("Format Template %s Attributes"%format_name), body=bibformatadminlib.perform_request_format_template_show_attributes(bft, ln=ln, new=is_new), uid=uid, language=ln, navtrail = navtrail_previous_links , lastupdated=__lastupdated__, req=req)
if not bibformatadminlib.can_read_format_template(bft): # No read permission return page( title=_("Restricted Format Template"), body="""You don't have permission to view this format template.""", language=ln, navtrail=navtrail_previous_links, errors=[("ERR_BIBFORMAT_CANNOT_READ_TEMPLATE_FILE", format_template, "")], lastupdated=__lastupdated__, req=req, ) return page( title=_("Format Template %s Attributes" % format_name), body=bibformatadminlib.perform_request_format_template_show_attributes(bft, ln=ln, new=is_new), uid=uid, language=ln, navtrail=navtrail_previous_links, lastupdated=__lastupdated__, req=req, ) else: return page_not_authorized(req=req, text=auth_msg) def format_template_show_dependencies(req, bft, ln=CFG_SITE_LANG): """ Show the dependencies (on elements) of the given format.
is_new = wash_url_argument(new, 'int') if not bibformatadminlib.can_read_format_template(bft): #No read permission return page(title=_("Restricted Format Template"), body = """You don't have permission to view this format template.""", language=ln, navtrail = navtrail_previous_links, errors = [("ERR_BIBFORMAT_CANNOT_READ_TEMPLATE_FILE", format_template , "")], lastupdated=__lastupdated__, req=req) return page(title=_("Format Template %s Attributes"%format_name), body=bibformatadminlib.perform_request_format_template_show_attributes(bft, ln=ln, new=is_new), uid=uid, language=ln, navtrail = navtrail_previous_links , lastupdated=__lastupdated__, req=req) else: return page_not_authorized(req=req, text=auth_msg) def format_template_show_dependencies(req, bft, ln=CFG_SITE_LANG): """ Show the dependencies (on elements) of the given format. @param ln: language @param bft: the filename of the template to show