title="File Permission on %s" % format_name, message="You don't have write permission " "on <i>%s</i>.<br/> You can view the template" ", but not edit it." % format_name, navtrail=navtrail_previous_links, options=[_("Ok")], ) if bft.endswith(".xsl"): format_name += " (XSL)" return page( title=_("Format Template %s" % format_name), body=bibformatadminlib.perform_request_format_template_show( format_template, code=code, ln=ln, ln_for_preview=ln_preview, pattern_for_preview=pattern_preview, content_type_for_preview=content_type_for_preview, ), uid=uid, language=ln, navtrail=navtrail_previous_links, lastupdated=__lastupdated__, req=req, ) else: return page_not_authorized(req=req, text=auth_msg, navtrail=navtrail_previous_links) def format_template_show_attributes(req, bft, ln=CFG_SITE_LANG, new=0): """
def format_template_show(req, bft, code=None, ln=CFG_SITE_LANG, ln_for_preview=CFG_SITE_LANG, pattern_for_preview="", content_type_for_preview="text/html", chosen_option=""): """ Main page for template edition. Check for authentication and print formats editor. @param req: the request object @param ln: language @param code: the code being edited @param bft: the name of the template to show @param ln_for_preview: the language for the preview (for bfo) @param pattern_for_preview: the search pattern to be used for the preview (for bfo) @param content_type_for_preview: the (MIME) content type of the preview @param chosen_option: returned value for dialog_box warning @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') ln_preview = wash_language(ln_for_preview) pattern_preview = wash_url_argument(pattern_for_preview, 'str') 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) format_name = bibformat_engine.get_format_template_attrs(bft)['name'] if not bibformatadminlib.can_write_format_template(bft) and \ chosen_option == "": #No write permission return dialog_box(req=req, ln=ln, title="File Permission on %s" % format_name, message="You don't have write permission " \ "on <i>%s</i>.<br/> You can view the template" \ ", but not edit it." % format_name, navtrail=navtrail_previous_links, options=[ _("Ok")]) if bft.endswith('.xsl'): format_name += ' (XSL)' return page( title=_("Format Template %s" % format_name), body=bibformatadminlib.perform_request_format_template_show( format_template, code=code, ln=ln, ln_for_preview=ln_preview, pattern_for_preview=pattern_preview, content_type_for_preview=content_type_for_preview), uid=uid, language=ln, navtrail=navtrail_previous_links, lastupdated=__lastupdated__, req=req)
def format_template_show(req, bft, code=None, ln=CFG_SITE_LANG, ln_for_preview=CFG_SITE_LANG, pattern_for_preview="", content_type_for_preview="text/html", chosen_option=""): """ Main page for template edition. Check for authentication and print formats editor. @param req: the request object @param ln: language @param code: the code being edited @param bft: the name of the template to show @param ln_for_preview: the language for the preview (for bfo) @param pattern_for_preview: the search pattern to be used for the preview (for bfo) @param content_type_for_preview: the (MIME) content type of the preview @param chosen_option: returned value for dialog_box warning @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') ln_preview = wash_language(ln_for_preview) pattern_preview = wash_url_argument(pattern_for_preview, 'str') 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) format_name = bibformat_engine.get_format_template_attrs(bft)['name'] if not bibformatadminlib.can_write_format_template(bft) and \ chosen_option == "": #No write permission return dialog_box(req=req, ln=ln, title="File Permission on %s" % format_name, message="You don't have write permission " \ "on <i>%s</i>.<br/> You can view the template" \ ", but not edit it." % format_name, navtrail=navtrail_previous_links, options=[ _("Ok")]) if bft.endswith('.xsl'): format_name += ' (XSL)' return page(title=_("Format Template %s"%format_name), body=bibformatadminlib.perform_request_format_template_show(format_template, code=code, ln=ln, ln_for_preview=ln_preview, pattern_for_preview=pattern_preview, content_type_for_preview=content_type_for_preview), uid=uid, language=ln, navtrail = navtrail_previous_links, lastupdated=__lastupdated__, req=req)
ln=ln, title="File Permission on %s" % format_name, message="You don't have write permission " \ "on <i>%s</i>.<br/> You can view the template" \ ", but not edit it." % format_name, navtrail=navtrail_previous_links, options=[ _("Ok")]) if bft.endswith('.xsl'): format_name += ' (XSL)' return page( title=_("Format Template %s" % format_name), body=bibformatadminlib.perform_request_format_template_show( format_template, code=code, ln=ln, ln_for_preview=ln_preview, pattern_for_preview=pattern_preview, content_type_for_preview=content_type_for_preview), uid=uid, language=ln, navtrail=navtrail_previous_links, lastupdated=__lastupdated__, req=req) else: return page_not_authorized(req=req, text=auth_msg, navtrail=navtrail_previous_links) def format_template_show_attributes(req, bft, ln=CFG_SITE_LANG, new=0):