Example #1
0
 def test_wash_dashed_language(self):
     """messages - washing dashed language code (fr-ca)"""
     if 'fr' not in CFG_SITE_LANGS:
         self.assertEqual(messages.wash_language('fr-ca'),
                          CFG_SITE_LANG)
     else:
         self.assertEqual(messages.wash_language('fr-ca'),
                          'fr')
 def test_wash_dashed_language(self):
     """messages - washing dashed language code (fr-ca)"""
     if 'fr' not in CFG_SITE_LANGS:
         self.assertEqual(messages.wash_language('fr-ca'),
                          CFG_SITE_LANG)
     else:
         self.assertEqual(messages.wash_language('fr-ca'),
                          'fr')
Example #3
0
def regenerate(req, journal_name="", issue="", ln=CFG_SITE_LANG,
               confirmed_p="", publish_draft_articles_p=""):
    """
    Clears the cache for the given issue.
    """
    navtrail_previous_links = wjn.getnavtrail(' &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a> &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py/administrate?journal_name=%s">%s</a>' % (CFG_SITE_URL, CFG_SITE_URL, journal_name, journal_name))

    ln = wash_language(ln)
    _ = gettext_set_language(ln)

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

    try:
        journal_name = wash_journal_name(ln, journal_name)
        issue_number = wash_issue_number(ln, journal_name,
                                         issue)
        confirmed_p = wash_url_argument(confirmed_p, 'str') == "confirmed"
        publish_draft_articles_p = wash_url_argument(publish_draft_articles_p, 'str') == "move"

    except InvenioWebJournalNoJournalOnServerError, e:
        register_exception(req=req)
        return e.user_box()
Example #4
0
def output_formats_manage(req, ln=CFG_SITE_LANG, sortby="code"):
    """
    Main page for output formats management. Check for authentication and print output formats list.

    @param req: the request object
    @param ln: language
    @param sortby: the sorting crieteria (can be 'code' or 'name')
    @return: a web page
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = bibformatadminlib.getnavtrail()

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

    (auth_code, auth_msg) = check_user(req, 'cfgbibformat')
    if not auth_code:
        sortby = wash_url_argument(sortby, 'str')
        return page(
            title=_("Manage Output Formats"),
            body=bibformatadminlib.perform_request_output_formats_management(
                ln=ln, sortby=sortby),
            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)
Example #5
0
def format_elements_doc(req, ln=CFG_SITE_LANG):
    """
    Main page for format elements documentation. Check for authentication and print format elements list.

    @param req: the request object
    @param ln: language
    @return: a web page
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = bibformatadminlib.getnavtrail()

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

    (auth_code, auth_msg) = check_user(req, 'cfgbibformat')
    if not auth_code:
        return page(title=_("Format Elements Documentation"),
                    body=bibformatadminlib.
                    perform_request_format_elements_documentation(ln=ln),
                    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)
Example #6
0
def format_elements_doc(req, ln=CFG_SITE_LANG):
    """
    Main page for format elements documentation. Check for authentication and print format elements list.

    @param req: the request object
    @param ln: language
    @return: a web page
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = bibformatadminlib.getnavtrail()

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

    (auth_code, auth_msg) = check_user(req, 'cfgbibformat')
    if not auth_code:
        return page(title=_("Format Elements Documentation"),
                body=bibformatadminlib.perform_request_format_elements_documentation(ln=ln),
                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)
Example #7
0
def linkbacks(req, status, returncode=CFG_WEBLINKBACK_ACTION_RETURN_CODE['OK'], ln=CFG_SITE_LANG):
    """
    Display linkbacks
    @param ln: language
    @param status: of CFG_WEBLINKBACK_STATUS, currently only CFG_WEBLINKBACK_STATUS['PENDING'] is supported
    """
    return_code = int(returncode)
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = get_navtrail()
    navtrail_previous_links +=' &gt; <a class="navtrail" href="%s/admin/weblinkback/weblinkbackadmin.py/">' % CFG_SITE_URL
    navtrail_previous_links += _("WebLinkback Admin") + '</a>'

    uid = getUid(req)
    user_info = collect_user_info(req)
    (auth_code, auth_msg) = acc_authorize_action(user_info, 'cfgweblinkback')
    if auth_code:
        return page_not_authorized(req=req, text=auth_msg, navtrail=navtrail_previous_links)
    else:
        return page(title=_("Pending Linkbacks"),
                    body=perform_request_display_linkbacks(return_code=return_code, status=status, ln=ln),
                    uid=uid,
                    language=ln,
                    navtrail = navtrail_previous_links,
                    req=req)
def perform_request_users(ln=CFG_SITE_LANG):
    """
    """
    ln = wash_language(ln)

    users_data = query_get_users_reported()
    return webcomment_templates.tmpl_admin_users(ln=ln, users_data=users_data)
Example #9
0
def output_format_add(req, ln=CFG_SITE_LANG):
    """
    Adds a new output format

    @param req: the request object
    @param ln: language
    @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:

        bfo = bibformatadminlib.add_output_format()
        if bfo == None:
            return page(title=_("Cannot create output format"),
                        body = """BibFormat cannot add an output format.
                        Check output formats directory permissions.""",
                        language=ln,
                        lastupdated=__lastupdated__,
                        req=req)
        redirect_to_url(req, "output_format_show_attributes?ln=%(ln)s&bfo=%(bfo)s" % {'ln':ln, 'bfo':bfo})
    else:
        return page_not_authorized(req=req, text=auth_msg)
Example #10
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(
        '''
    &gt; <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 MySQLdb.Error, e:
        return error_page(req)
Example #11
0
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(
        ''' &gt; <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 MySQLdb.Error, e:
        return error_page(req)
Example #12
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 MySQLdb.Error, e:
        return error_page(req)
Example #13
0
def index(req, ln=CFG_SITE_LANG):
    """
    Main BibFormat administration page.

    Displays a warning if we find out that etc/biformat dir is not writable by us
    (as most opeation of BibFormat must write in this directory).

    @param req: the request object
    @param ln: language
    @return: a web page
    """
    warnings = []

    if not bibformatadminlib.can_write_etc_bibformat_dir():
        warnings.append(("WRN_BIBFORMAT_CANNOT_WRITE_IN_ETC_BIBFORMAT"))

    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    # Check if user is authorized to administer
    # If not, still display page but offer to log in
    try:
        uid = getUid(req)
    except MySQLdb.Error, e:
        return error_page(req)
Example #14
0
def index(req, c=CFG_SITE_NAME, ln=CFG_SITE_LANG):
    """Approval web Interface.
    GET params:

    """
    uid = getUid(req)
    (auth_code, auth_message) = acc_authorize_action(uid, 'submit')
    if auth_code > 0 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
        return page_not_authorized(req,
                                   "../approve.py/index",
                                   navmenuid='yourapprovals',
                                   text=auth_message)

    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    args = wash_urlargd(req.form, {'access': (str, '')})
    if args['access'] == "":
        return warning_page(
            _("approve.py: cannot determine document reference"), req, ln)
    url_params = get_approval_url_parameters(args['access'])
    if not url_params:
        return warning_page(_("approve.py: cannot find document in database"),
                            req, ln)
    url_params['ln'] = ln
    url = "%s/submit/direct?%s" % (CFG_SITE_SECURE_URL,
                                   urllib.urlencode(url_params))
    redirect_to_url(req, url)
def format_element_test(req, bfe, ln=CFG_SITE_LANG, param_values=None):
    """
    Allows user to test element with different parameters and check output

    'param_values' is the list of values to pass to 'format'
    function of the element as parameters, in the order ...
    If params is None, this means that they have not be defined by user yet.

    @param bfe: the name of the element to test
    @param ln: language
    @param param_values: the list of parameters to pass to element format function
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = bibformatadminlib.getnavtrail(''' &gt; <a class="navtrail" href="%s/admin/bibformat/bibformatadmin.py/format_elements_doc?ln=%s">%s</a>''' %( CFG_SITE_URL, ln , _("Format Elements Documentation")))

    (auth_code, auth_msg) = check_user(req, 'cfgbibformat')
    if not auth_code:
        bfe = wash_url_argument(bfe, 'str')
        user_info = collect_user_info(req)
        uid = user_info['uid']
        return page(title=_("Test Format Element %s" % bfe),
                body=bibformatadminlib.perform_request_format_element_test(bfe=bfe,
                                                                           ln=ln,
                                                                           param_values=param_values,
                                                                           user_info=user_info),
                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)
Example #16
0
def lists(req, urlfieldvalue='', returncode=CFG_WEBLINKBACK_ACTION_RETURN_CODE['OK'], ln=CFG_SITE_LANG):
    """
    Display whitelist and blacklist
    @param urlFieldValue: value of the url input field
    @return_code: might indicate errors from a previous action, of CFG_WEBLINKBACK_ACTION_RETURN_CODE
    @param ln: language
    """
    # is passed as a string, must be an integer
    return_code = int(returncode)
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = get_navtrail()
    navtrail_previous_links +=' &gt; <a class="navtrail" href="%s/admin/weblinkback/weblinkbackadmin.py/">' % CFG_SITE_URL
    navtrail_previous_links += _("WebLinkback Admin") + '</a>'

    uid = getUid(req)
    userInfo = collect_user_info(req)
    (auth_code, auth_msg) = acc_authorize_action(userInfo, 'cfgweblinkback')
    if auth_code:
        return page_not_authorized(req=req, text=auth_msg, navtrail=navtrail_previous_links)
    else:
        return page(title=_("Linkback Whitelist/Blacklist Manager"),
                    body=perform_request_display_list(return_code=return_code, url_field_value=urlfieldvalue, ln=ln),
                    uid=uid,
                    language=ln,
                    navtrail = navtrail_previous_links,
                    req=req)
Example #17
0
def configure(req, journal_name=None, ln=CFG_SITE_LANG, xml_config=u'', action='edit'):
    """
    Let admins configure the journal settings
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    if journal_name is None:
        navtrail_previous_links = wjn.getnavtrail(' &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a>' % CFG_SITE_URL)
    else:
        navtrail_previous_links = wjn.getnavtrail(' &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a> &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py/administrate?journal_name=%s">%s</a>' % (CFG_SITE_URL, CFG_SITE_URL, journal_name, journal_name))

    if action in ['add', 'addDone']:
        page_title = _('Add Journal')
    else:
        page_title = _("Edit Settings")

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

    try:
        journal_name = wash_journal_name(ln, journal_name, guess=False)
        xml_config = wash_url_argument(xml_config, 'str')
        action = wash_url_argument(action, 'str')
    except InvenioWebJournalNoJournalOnServerError, e:
        # Ok, no journal. Let the admin add one...
        pass
def alert(req,
          journal_name="",
          ln=CFG_SITE_LANG,
          sent="False",
          plainText=u"",
          htmlMail="",
          recipients="",
          subject="",
          issue="",
          force="False"):
    """
    Sends an email alert, in HTML/PlainText or only PlainText to a mailing
    list to alert for new journal releases.
    """
    navtrail_previous_links = wjn.getnavtrail(
        ' &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a> &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py/administrate?journal_name=%s">%s</a>'
        % (CFG_SITE_URL, CFG_SITE_URL, journal_name, journal_name))

    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    try:
        uid = getUid(req)
    except Error, e:
        return error_page(req)
Example #19
0
def users(req, ln=CFG_SITE_LANG):
    """
    View a list of all the users that have been reported, sorted by most reported
    @param req: request object to obtain user information
    @param ln: language
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = getnavtrail()
    navtrail_previous_links += ' &gt; <a class="navtrail" href="%s/admin/webcomment/webcommentadmin.py/">' % CFG_SITE_URL
    navtrail_previous_links += _("WebComment Admin") + '</a>'

    try:
        uid = getUid(req)
    except Error:
        return page(title=_("Internal Error"),
                    body = create_error_box(req, verbose=0, ln=ln),
                    description="%s - Internal Error" % CFG_SITE_NAME,
                    keywords="%s, Internal Error" % CFG_SITE_NAME,
                    language=ln,
                    req=req)

    (auth_code, auth_msg) = check_user(req,'cfgwebcomment')
    if (auth_code != 'false'):
        return page(title=_("View all reported users"),
                    body=perform_request_users(ln=ln),
                    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 configure(req,
              journal_name=None,
              ln=CFG_SITE_LANG,
              xml_config=u'',
              action='edit'):
    """
    Let admins configure the journal settings
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    if journal_name is None:
        navtrail_previous_links = wjn.getnavtrail(
            ' &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a>'
            % CFG_SITE_URL)
    else:
        navtrail_previous_links = wjn.getnavtrail(
            ' &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a> &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py/administrate?journal_name=%s">%s</a>'
            % (CFG_SITE_URL, CFG_SITE_URL, journal_name, journal_name))

    if action in ['add', 'addDone']:
        page_title = _('Add Journal')
    else:
        page_title = _("Edit Settings")

    try:
        uid = getUid(req)
    except Error, e:
        return error_page(req)
Example #21
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('''
    &gt; <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 MySQLdb.Error, e:
        return error_page(req)
def output_format_show(
    req, bfo, ln=CFG_SITE_LANG, r_fld=[], r_val=[], r_tpl=[], default="", r_upd="", chosen_option="", **args
):
    """
    Show a single output format. Check for authentication and print output format settings.

    The page either shows the output format from file, or from user's
    POST session, as we want to let him edit the rules without
    saving. Policy is: r_fld, r_val, rules_tpl are list of attributes
    of the rules.  If they are empty, load from file. Else use
    POST. The i th value of each list is one of the attributes of rule
    i. Rule i is the i th rule in order of evaluation.  All list have
    the same number of item.

    r_upd contains an action that has to be performed on rules. It
    can composed of a number (i, the rule we want to modify) and an
    operator : "save" to save the rules, "add" or "del".
    syntax: operator [number]
    For eg: r_upd = _("Save Changes") saves all rules (no int should be specified).
    For eg: r_upd = _("Add New Rule") adds a rule (no int should be specified).
    For eg: r_upd = _("Remove Rule") + " 5"  deletes rule at position 5.
    The number is used only for operation delete.

    An action can also be in **args. We must look there for string starting
    with '(+|-) [number]' to increase (+) or decrease (-) a rule given by its
    index (number).
    For example "+ 5" increase priority of rule 5 (put it at fourth position).
    The string in **args can be followed by some garbage that looks like .x
    or .y, as this is returned as the coordinate of the click on the
    <input type="image">. We HAVE to use args and reason on its keys, because for <input> of
    type image, iexplorer does not return the value of the tag, but only the name.

    Action is executed only if we are working from user's POST session
    (means we must have loaded the output format first, which is
    totally normal and expected behaviour)


    @param req: the request object
    @param bfo: the filename of the output format to show
    @param ln: language
    @param r_fld: the list of 'field' attribute for each rule
    @param r_val: the list of 'value' attribute for each rule
    @param r_tpl: the list of 'template' attribute for each rule
    @param default: the default format template used by this output format
    @param r_upd: the rule that we want to increase/decrease in order of evaluation
    @param chosen_option: emptry string when user has not yet confirmed to go on
    @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_URL, ln, _("Manage Output Formats"))
    )
    code = wash_url_argument(bfo, "str")

    try:
        uid = getUid(req)
    except MySQLdb.Error, e:
        return error_page(req)
Example #23
0
def format_template_show_dependencies(req, bft, ln=CFG_SITE_LANG):
    """
    Show the dependencies (on elements) of the given format.

    @param req: the request object
    @param ln: language
    @param bft: 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/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']

        return page(title=_("Format Template %s Dependencies" % format_name),
                    body=bibformatadminlib.perform_request_format_template_show_dependencies(bft, 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 doctypeconfiguresubmissionpagespreview(req,
                                           doctype="",
                                           action="",
                                           pagenum="",
                                           ln=CFG_SITE_LANG):
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        (title, body, errors, warnings) = perform_request_configure_doctype_submissionpage_preview(doctype=doctype,
                                                                                                   action=action,
                                                                                                   pagenum=pagenum)
        return page(title       = title,
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln,
                    errors      = errors,
                    warnings    = warnings)

    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))
Example #25
0
def actionedit(req, actid, actname=None, working_dir=None, status_text=None, actcommit="", ln=CFG_SITE_LANG):
    """Display the details of a WebSubmit action in a Web form so that it can be viewed and/or edited.
       @param actid: The unique action identifier code.
       @param actname: name of action (if present, action will be updated, else action details will be displayed)
       @param working_dir: action working directory for websubmit
       @param status_text: status text displayed at end of websubmit action
       @param ln: language
       @return: page
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        # Generate content
        (title, body, errors, warnings) = perform_request_edit_action(actid, actname, working_dir, status_text, actcommit)
        return page(title       = title,
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln,
                    errors      = errors,
                    warnings    = warnings)
    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))
def edit(req, ln=CFG_SITE_LANG, fname=""):
    """ creates an editor for the file. This is called also when the user wants to
        create a new file. In the case fname is empty"""
    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    # sanity check for fname:
    fname = os.path.basename(fname)

    #check auth
    (admin_ok, uid) = is_admin(req)
    navtrail = """<a class="navtrail" href="%s/help/admin">%s</a>""" % \
               (CFG_SITE_URL, _("Admin Area"))
    navtrail += """&gt; <a class="navtrail" href="%s/admin/bibcheck/bibcheckadmin.py/">BibCheck Admin</a> """ % CFG_SITE_URL
    myout = _("File")+" " + cgi.escape(fname) + "<br/>"
    if admin_ok:
        #add a javascript checker so that the user cannot save a form with empty
        #fname
        myout += """<script language="JavaScript" type="text/javascript">
                    <!--
                     function checkform ( form ) { if (form.fname.value == "") {
                              alert( "Missing filename." ); form.fname.focus(); return false ;
                            }
                            return true ;
                      }
                     -->
                     </script>"""


        #read the file if there is one
        filelines = []
        if fname:
            myfile = CFG_ETCDIR+"/bibcheck/"+fname
            infile = file(myfile, 'r')
            filelines = infile.readlines()
            infile.close()
        myout += '<form method="post" action="save" onsubmit="return checkform(this);">'
        #create a filename dialog box if there is no fname, otherwise it's hidden
        if fname:
            myout += '<input type="hidden" name="fname" value="'+fname+'">'
        else:
            myout += '<input name="fname" value="'+fname+'"><br/>'
            myout += '<input type="hidden" name="wasnew" value="1">'
        myout += '<input type="hidden" name="ln" value="'+ln+'">'
        myout += '<textarea name="code" id="code" rows="25" style="width:100%">'
        for line in filelines:
            myout += line
        #create a save button
        myout += '</textarea><br/><input type="submit" name="save" value="'+_("Save Changes")+'"></form>'
        #create page
        return page(title=_("Edit BibCheck config file"),
                body= myout,
                language= ln,
                uid=uid,
                navtrail = navtrail,
                lastupdated=__lastupdated__,
                req=req,
                warnings=[])
    else: #not admin
        return page_not_authorized(req=req, text=_("Not authorized"), navtrail=navtrail)
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(
        """ &gt; <a class="navtrail" href="%s/admin/bibformat/bibformatadmin.py/format_templates_manage?ln=%s">%s</a>"""
        % (CFG_SITE_URL, ln, _("Manage Format Templates"))
    )

    try:
        uid = getUid(req)
    except MySQLdb.Error, e:
        return error_page(req)
Example #28
0
def jscheckadd(req, chname=None, chdesc=None, chcommit="", ln=CFG_SITE_LANG):
    """Add a new JavaScript CHECK to the WebSubmit database.
       Web form for action details will be displayed if "actid" and "actname" are empty; else
       new action will be committed to WebSubmit.
       @param chname: unique name/ID for new check (if empty, Web form will be displayed)
       @param chdesc: description of new JS check (the JavaScript code that is the check.) (If empty,
                      Web form will be displayed)
       @param ln: language
       @return: page
    """

    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        # Generate content
        (title, body, errors, warnings) = perform_request_add_jscheck(chname, chdesc, chcommit)
        return page(title       = title,
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln,
                    errors      = errors,
                    warnings    = warnings)
    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))
Example #29
0
def format_template_add(req, ln=CFG_SITE_LANG):
    """
    Adds a new format template

    @param req: the request object
    @param ln: language
    @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:

        bft = bibformatadminlib.add_format_template()
        redirect_to_url(
            req,
            "format_template_show_attributes?ln=%(ln)s&bft=%(bft)s&new=1" % {
                'ln': ln,
                'bft': bft
            })
    else:
        return page_not_authorized(req=req, text=auth_msg)
Example #30
0
def jscheckedit(req, chname, chdesc=None, chcommit="", ln=CFG_SITE_LANG):
    """Display the details of a WebSubmit checking function in a Web form so that it can be viewed
       and/or edited.
       @param chname: The unique Check name/identifier code.
       @param chdesc: The description of the Check (if present, Check will be updated, else Check
                      details will be displayed)
       @param ln: language
       @return: page
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        # Generate content
        (title, body, errors, warnings) = perform_request_edit_jscheck(chname, chdesc, chcommit)
        return page(title       = title,
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln,
                    errors      = errors,
                    warnings    = warnings)
    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))
Example #31
0
def format_template_show_short_doc(req,
                                   ln=CFG_SITE_LANG,
                                   search_doc_pattern=""):
    """
    Prints the format elements documentation in a brief way. To be included inside Format template
    editor.

    @param req: the request object
    @param ln: language
    @param search_doc_pattern: a search pattern that specified which elements to display
    @return: 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:
        search_doc_pattern = wash_url_argument(search_doc_pattern, 'str')
        return bibformatadminlib.perform_request_format_template_show_short_doc(
            ln=ln, search_doc_pattern=search_doc_pattern)
    else:
        return page_not_authorized(req=req, text=auth_msg)
Example #32
0
def functionedit(req, funcname=None, funcdescr=None, funceditaddparam=None, funceditaddparamfree=None, \
                 funceditdelparam=None, funcdescreditcommit="", funcparamdelcommit="", funcparamaddcommit="", ln=CFG_SITE_LANG):
    """Edit a WebSubmit function"""
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        # Generate content
        (title, body, errors, warnings) = perform_request_edit_function(funcname=funcname,
                                                                        funcdescr=funcdescr,
                                                                        funceditdelparam=funceditdelparam,
                                                                        funceditaddparam=funceditaddparam,
                                                                        funceditaddparamfree=funceditaddparamfree,
                                                                        funcdescreditcommit=funcdescreditcommit,
                                                                        funcparamdelcommit=funcparamdelcommit,
                                                                        funcparamaddcommit=funcparamaddcommit
                                                                       )

        return page(title       = title,
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln,
                    errors      = errors,
                    warnings    = warnings)
    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))
Example #33
0
def alert(req, journal_name="", ln=CFG_SITE_LANG, sent="False", plainText=u"",
          htmlMail="", recipients="", subject="", issue="", force="False"):
    """
    Sends an email alert, in HTML/PlainText or only PlainText to a mailing
    list to alert for new journal releases.
    """
    navtrail_previous_links = wjn.getnavtrail(' &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a> &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py/administrate?journal_name=%s">%s</a>' % (CFG_SITE_URL, CFG_SITE_URL, journal_name, journal_name))

    ln = wash_language(ln)
    _ = gettext_set_language(ln)

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

    try:
        journal_name = wash_journal_name(ln, journal_name)
        issue = wash_issue_number(ln,
                                         journal_name,
                                         issue)
        plain_text = wash_url_argument(plainText, 'str')
        html_mail = wash_url_argument(htmlMail, 'str')
        recipients = wash_url_argument(recipients, 'str')
        subject = wash_url_argument(subject, 'str')
        sent = wash_url_argument(sent, 'str')
        force = wash_url_argument(force, 'str')
    except InvenioWebJournalNoJournalOnServerError, e:
        register_exception(req=req)
        return e.user_box()
Example #34
0
def functionusage(req, funcname, ln=CFG_SITE_LANG):
    """View the usage cases (document-type and actions) in which a function is used.
       @param function: the function name
       @param ln: the language
       @return: a web page
    """

    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        (body, errors, warnings) = perform_request_function_usage(funcname)
        return page(title       = "WebSubmit Function Usage",
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln,
                    errors      = errors,
                    warnings    = warnings)
    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))
Example #35
0
def issue_control(req, journal_name="", issue=[],
                  ln=CFG_SITE_LANG, action="cfg"):
    """
    Page that allows full control over creating, backtracing, adding to,
    removing from issues.
    """
    navtrail_previous_links = wjn.getnavtrail(' &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a> &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py/administrate?journal_name=%s">%s</a>' % (CFG_SITE_URL, CFG_SITE_URL, journal_name, journal_name))

    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    try:
        uid = getUid(req)
    except:
        return error_page('Error', req)
    try:
        journal_name = wash_journal_name(ln, journal_name)
        action = wash_url_argument(action, 'str')
        issue = wash_url_argument(issue, 'list')
        issues = [wash_issue_number(ln,journal_name, _issue) \
                  for _issue in issue \
                  if _issue != "ww/YYYY"]
    except InvenioWebJournalNoJournalOnServerError, e:
        register_exception(req=req)
        return e.user_box()
Example #36
0
def doctyperemove(req, doctype="", doctypedelete="", doctypedeleteconfirm="", ln=CFG_SITE_LANG):
    """Delete a WebSubmit document-type.
    @param doctype: the unique id of the document type to be deleted
    @param ln: the interface language
    @return: HTML page.
    """

    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        (title, body, errors, warnings) = perform_request_remove_doctype(doctype=doctype,
                                                                         doctypedelete=doctypedelete,
                                                                         doctypedeleteconfirm=doctypedeleteconfirm)
        return page(title       = title,
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln,
                    errors      = errors,
                    warnings    = warnings)
    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))
Example #37
0
def hot(req, ln=CFG_SITE_LANG, comments=1, top=10, collection=""):
    """
    View most active comments/reviews
    @param req: request object to obtain user information
    @param ln: language
    @param comments: boolean enabled for comments, disabled for reviews
    @param top: number of results to be shown
    @param collection: filter results by collection
    """
    ln = wash_language(ln)
    collection = wash_url_argument(collection, 'str')
    _ = gettext_set_language(ln)
    navtrail_previous_links = getnavtrail()
    navtrail_previous_links += ' &gt; <a class="navtrail" href="%s/admin/webcomment/webcommentadmin.py/">' % CFG_SITE_URL
    navtrail_previous_links += _("WebComment Admin") + '</a>'

    user_info = collect_user_info(req)
    (auth_code, auth_msg) = acc_authorize_action(user_info, 'cfgwebcomment')
    if auth_code:
        return page_not_authorized(req=req, text=auth_msg, navtrail=navtrail_previous_links)
    return page(title=(comments=='0' and _("View most reviewed records") or
                           _("View most commented records")),
                    body=perform_request_hot(req, ln=ln, comments=comments, top=top, collection=collection),
                    uid=user_info['uid'],
                    language=ln,
                    navtrail = navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)
Example #38
0
def doctypeadd(req, doctype=None, doctypename=None, doctypedescr=None, clonefrom=None, doctypedetailscommit="", ln=CFG_SITE_LANG):
    """Add a new document type to WebSubmit"""
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        (title, body, errors, warnings) = perform_request_add_doctype(doctype=doctype,
                                                                      doctypename=doctypename,
                                                                      doctypedescr=doctypedescr,
                                                                      clonefrom=clonefrom,
                                                                      doctypedetailscommit=doctypedetailscommit
                                                                      )

        return page(title       = title,
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln,
                    errors      = errors,
                    warnings    = warnings)
    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))
Example #39
0
def index(req, ln=CFG_SITE_LANG):
    """
    Menu of admin options
    @param ln: language
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = getnavtrail()
    navtrail_previous_links +=' &gt; <a class="navtrail" href="%s/admin/webcomment/webcommentadmin.py/">' % CFG_SITE_URL
    navtrail_previous_links += _("WebComment Admin") + '</a>'

    try:
        uid = getUid(req)
    except Error:
        return page(title=_("Internal Error"),
                    body = create_error_box(req, verbose=0, ln=ln),
                    description="%s - Internal Error" % CFG_SITE_NAME,
                    keywords="%s, Internal Error" % CFG_SITE_NAME,
                    language=ln,
                    req=req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebcomment')
    if (auth_code != 'false'):
        return page(title=_("WebComment Admin"),
                body=perform_request_index(ln=ln),
                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)
Example #40
0
def doctypeconfiguresubmissionpagespreview(req,
                                           doctype="",
                                           action="",
                                           pagenum="",
                                           ln=CFG_SITE_LANG):
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        (title, body, errors, warnings) = perform_request_configure_doctype_submissionpage_preview(doctype=doctype,
                                                                                                   action=action,
                                                                                                   pagenum=pagenum)
        return page(title       = title,
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln,
                    errors      = errors,
                    warnings    = warnings)

    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))
Example #41
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 MySQLdb.Error, e:
        return error_page(req)
Example #42
0
def index(req,
          c=CFG_SITE_NAME,
          ln=CFG_SITE_LANG,
          order="",
          doctype="",
          deletedId="",
          deletedAction="",
          deletedDoctype=""):
    global uid
    ln = wash_language(ln)

    # load the right message language
    _ = gettext_set_language(ln)

    t = ""
    # get user ID:
    try:
        uid = getUid(req)
        if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
            return page_not_authorized(req,
                                       "../yoursubmissions.py/index",
                                       navmenuid='yoursubmissions')
        u_email = get_email(uid)
    except Error, e:
        return errorMsg(str(e), req, ln=ln)
Example #43
0
def kb_add(req, ln=CFG_SITE_LANG, sortby="to", kbtype=""):
    """
    Adds a new kb
    @param req the request
    @param ln language
    @param sortby to or from
    @param kbtype type of knowledge base. one of: "", taxonomy, dynamic
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    navtrail_previous_links = ''' &gt; <a class="navtrail" href="%s/kb?ln=%s">%s</a>''' % (CFG_SITE_SECURE_URL, ln, _("Manage Knowledge Bases"))

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

    (auth_code, auth_msg) = check_user(req, 'cfgbibknowledge')
    if not auth_code:
        name = "Untitled"
        if kbtype == "taxonomy":
            name = "Untitled Taxonomy"
        if kbtype == "dynamic":
            name = "Untitled dynamic"
        kb_id = bibknowledge.add_kb(kb_name=name, kb_type=kbtype)
        redirect_to_url(req, "kb?ln=%(ln)s&amp;action=attributes&amp;kb=%(kb)s" % {'ln':ln, 'kb':kb_id, 'sortby':sortby})
    else:
        navtrail_previous_links = ''' &gt; <a class="navtrail" href="%s/kb?ln=%s">%s</a>''' % (CFG_SITE_SECURE_URL, ln, _("Manage Knowledge Bases"))

        return page_not_authorized(req=req,
                                   text=auth_msg,
                                   navtrail=navtrail_previous_links)
Example #44
0
def hot(req, ln=CFG_SITE_LANG, comments=1, top=10, collection=""):
    """
    View most active comments/reviews
    @param req: request object to obtain user information
    @param ln: language
    @param comments: boolean enabled for comments, disabled for reviews
    @param top: number of results to be shown
    @param collection: filter results by collection
    """
    ln = wash_language(ln)
    collection = wash_url_argument(collection, 'str')
    _ = gettext_set_language(ln)
    navtrail_previous_links = getnavtrail()
    navtrail_previous_links += ' &gt; <a class="navtrail" href="%s/admin/webcomment/webcommentadmin.py/">' % CFG_SITE_URL
    navtrail_previous_links += _("WebComment Admin") + '</a>'

    user_info = collect_user_info(req)
    (auth_code, auth_msg) = acc_authorize_action(user_info, 'cfgwebcomment')
    if auth_code:
        return page_not_authorized(req=req, text=auth_msg, navtrail=navtrail_previous_links)
    return page(title=(comments=='0' and _("View most reviewed records") or
                           _("View most commented records")),
                    body=perform_request_hot(req, ln=ln, comments=comments, top=top, collection=collection),
                    uid=user_info['uid'],
                    language=ln,
                    navtrail = navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)
Example #45
0
def format_templates_manage(req, ln=CFG_SITE_LANG, checking='0'):
    """
    Main page for formats templates management. Check for authentication and print formats list.

    @param req: the request object
    @param ln: language
    @param checking: if 0, basic checking. Else perform extensive checking (time-consuming)
    @return: a web page
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = bibformatadminlib.getnavtrail()

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

    (auth_code, auth_msg) = check_user(req, 'cfgbibformat')
    if not auth_code:
        checking_level = wash_url_argument(checking, 'int')
        return page(title=_("Manage Format Templates"),
                body=bibformatadminlib.perform_request_format_templates_management(ln=ln, checking=checking_level),
                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)
Example #46
0
def users(req, ln=CFG_SITE_LANG):
    """
    View a list of all the users that have been reported, sorted by most reported
    @param req: request object to obtain user information
    @param ln: language
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = getnavtrail()
    navtrail_previous_links += ' &gt; <a class="navtrail" href="%s/admin/webcomment/webcommentadmin.py/">' % CFG_SITE_URL
    navtrail_previous_links += _("WebComment Admin") + '</a>'

    try:
        uid = getUid(req)
    except Error:
        return page(title=_("Internal Error"),
                    body = create_error_box(req, verbose=0, ln=ln),
                    description="%s - Internal Error" % CFG_SITE_NAME,
                    keywords="%s, Internal Error" % CFG_SITE_NAME,
                    language=ln,
                    req=req)

    (auth_code, auth_msg) = check_user(req,'cfgwebcomment')
    if (auth_code != 'false'):
        return page(title=_("View all reported users"),
                    body=perform_request_users(ln=ln),
                    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)
Example #47
0
def output_formats_manage(req, ln=CFG_SITE_LANG, sortby="code"):
    """
    Main page for output formats management. Check for authentication and print output formats list.

    @param req: the request object
    @param ln: language
    @param sortby: the sorting crieteria (can be 'code' or 'name')
    @return: a web page
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = bibformatadminlib.getnavtrail()

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

    (auth_code, auth_msg) = check_user(req, 'cfgbibformat')
    if not auth_code:
        sortby = wash_url_argument(sortby, 'str')
        return page(title=_("Manage Output Formats"),
                body=bibformatadminlib.perform_request_output_formats_management(ln=ln, sortby=sortby),
                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)
Example #48
0
def index(req, ln=CFG_SITE_LANG):
    """
    Menu of admin options
    @param ln: language
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = getnavtrail()
    navtrail_previous_links +=' &gt; <a class="navtrail" href="%s/admin/webcomment/webcommentadmin.py/">' % CFG_SITE_URL
    navtrail_previous_links += _("WebComment Admin") + '</a>'

    try:
        uid = getUid(req)
    except Error:
        return page(title=_("Internal Error"),
                    body = create_error_box(req, verbose=0, ln=ln),
                    description="%s - Internal Error" % CFG_SITE_NAME,
                    keywords="%s, Internal Error" % CFG_SITE_NAME,
                    language=ln,
                    req=req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebcomment')
    if (auth_code != 'false'):
        return page(title=_("WebComment Admin"),
                body=perform_request_index(ln=ln),
                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)
Example #49
0
def format_element_show_dependencies(req, bfe, ln=CFG_SITE_LANG):
    """
    Shows format element dependencies

    @param req: the request object
    @param req: the request object
    @param bfe: the name of the bfe to show
    @param ln: language
    @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/format_elements_doc?ln=%s">%s</a>''' % (CFG_SITE_SECURE_URL, ln , _("Format Elements Documentation")))
    try:
        uid = getUid(req)
    except:
        return error_page('Error', req)

    (auth_code, auth_msg) = check_user(req, 'cfgbibformat')
    if not auth_code:
        bfe = wash_url_argument(bfe, 'str')
        return page(title=_("Format Element %s Dependencies" % bfe),
                body=bibformatadminlib.perform_request_format_element_show_dependencies(bfe=bfe, ln=ln),
                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)
Example #50
0
def edit(req, ln=CFG_SITE_LANG, fname=""):
    """ creates an editor for the file. This is called also when the user wants to
        create a new file. In the case fname is empty"""
    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    # sanity check for fname:
    fname = os.path.basename(fname)

    #check auth
    (admin_ok, uid) = is_admin(req)
    navtrail = """<a class="navtrail" href="%s/help/admin">%s</a>""" % \
               (CFG_SITE_URL, _("Admin Area"))
    navtrail += """&gt; <a class="navtrail" href="%s/admin/bibcheck/bibcheckadmin.py/">BibCheck Admin</a> """ % CFG_SITE_URL
    myout = _("File")+" " + cgi.escape(fname) + "<br/>"
    if admin_ok:
        #add a javascript checker so that the user cannot save a form with empty
        #fname
        myout += """<script language="JavaScript" type="text/javascript">
                    <!--
                     function checkform ( form ) { if (form.fname.value == "") {
                              alert( "Missing filename." ); form.fname.focus(); return false ;
                            }
                            return true ;
                      }
                     -->
                     </script>"""


        #read the file if there is one
        filelines = []
        if fname:
            myfile = CFG_ETCDIR+"/bibcheck/"+fname
            infile = file(myfile, 'r')
            filelines = infile.readlines()
            infile.close()
        myout += '<form method="post" action="save" onsubmit="return checkform(this);">'
        #create a filename dialog box if there is no fname, otherwise it's hidden
        if fname:
            myout += '<input type="hidden" name="fname" value="'+fname+'">'
        else:
            myout += '<input name="fname" value="'+fname+'"><br/>'
            myout += '<input type="hidden" name="wasnew" value="1">'
        myout += '<input type="hidden" name="ln" value="'+ln+'">'
        myout += '<textarea name="code" id="code" rows="25" style="width:100%">'
        for line in filelines:
            myout += line
        #create a save button
        myout += '</textarea><br/><input type="submit" name="save" value="'+_("Save Changes")+'"></form>'
        #create page
        return page(title=_("Edit BibCheck config file"),
                body= myout,
                language= ln,
                uid=uid,
                navtrail = navtrail,
                lastupdated=__lastupdated__,
                req=req,
                warnings=[])
    else: #not admin
        return page_not_authorized(req=req, text=_("Not authorized"), navtrail=navtrail)
def perform_request_users(ln=CFG_SITE_LANG):
    """
    """
    ln = wash_language(ln)

    users_data = query_get_users_reported()
    return webcomment_templates.tmpl_admin_users(ln=ln, users_data=users_data)
Example #52
0
def output_format_add(req, ln=CFG_SITE_LANG):
    """
    Adds a new output format

    @param req: the request object
    @param ln: language
    @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:

        bfo = bibformatadminlib.add_output_format()
        if bfo == None:
            return page(title=_("Cannot create output format"),
                        body="""BibFormat cannot add an output format.
                        Check output formats directory permissions.""",
                        language=ln,
                        lastupdated=__lastupdated__,
                        req=req)
        redirect_to_url(
            req, "output_format_show_attributes?ln=%(ln)s&bfo=%(bfo)s" % {
                'ln': ln,
                'bfo': bfo
            })
    else:
        return page_not_authorized(req=req, text=auth_msg)
def index(req, ln=CFG_SITE_LANG):
    """
    Main BibFormat administration page.

    Displays a warning if we find out that etc/biformat dir is not writable by us
    (as most opeation of BibFormat must write in this directory).

    @param req: the request object
    @param ln: language
    @return: a web page
    """
    warnings = []

    if not bibformatadminlib.can_write_etc_bibformat_dir():
        warnings.append(("WRN_BIBFORMAT_CANNOT_WRITE_IN_ETC_BIBFORMAT"))

    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    # Check if user is authorized to administer
    # If not, still display page but offer to log in
    try:
        uid = getUid(req)
    except MySQLdb.Error, e:
        return error_page(req)
Example #54
0
def format_templates_manage(req, ln=CFG_SITE_LANG, checking='0'):
    """
    Main page for formats templates management. Check for authentication and print formats list.

    @param req: the request object
    @param ln: language
    @param checking: if 0, basic checking. Else perform extensive checking (time-consuming)
    @return: a web page
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = bibformatadminlib.getnavtrail()

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

    (auth_code, auth_msg) = check_user(req, 'cfgbibformat')
    if not auth_code:
        checking_level = wash_url_argument(checking, 'int')
        return page(
            title=_("Manage Format Templates"),
            body=bibformatadminlib.perform_request_format_templates_management(
                ln=ln, checking=checking_level),
            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)
Example #55
0
def kb_add(req, ln=CFG_SITE_LANG, sortby="to", kbtype=""):
    """
    Adds a new kb
    @param req the request
    @param ln language
    @param sortby to or from
    @param kbtype type of knowledge base. one of: "", taxonomy, dynamic
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    navtrail_previous_links = ''' &gt; <a class="navtrail" href="%s/kb?ln=%s">%s</a>''' % (CFG_SITE_SECURE_URL, ln, _("Manage Knowledge Bases"))

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

    (auth_code, auth_msg) = check_user(req, 'cfgbibknowledge')
    if not auth_code:
        name = "Untitled"
        if kbtype == "taxonomy":
            name = "Untitled Taxonomy"
        if kbtype == "dynamic":
            name = "Untitled dynamic"
        kb_id = bibknowledge.add_kb(kb_name=name, kb_type=kbtype)
        redirect_to_url(req, "kb?ln=%(ln)s&amp;action=attributes&amp;kb=%(kb)s" % {'ln':ln, 'kb':kb_id, 'sortby':sortby})
    else:
        navtrail_previous_links = ''' &gt; <a class="navtrail" href="%s/kb?ln=%s">%s</a>''' % (CFG_SITE_SECURE_URL, ln, _("Manage Knowledge Bases"))

        return page_not_authorized(req=req,
                                   text=auth_msg,
                                   navtrail=navtrail_previous_links)
def doctypeadd(req, doctype=None, doctypename=None, doctypedescr=None, clonefrom=None, doctypedetailscommit="", ln=CFG_SITE_LANG):
    """Add a new document type to WebSubmit"""
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        (title, body, errors, warnings) = perform_request_add_doctype(doctype=doctype,
                                                                      doctypename=doctypename,
                                                                      doctypedescr=doctypedescr,
                                                                      clonefrom=clonefrom,
                                                                      doctypedetailscommit=doctypedetailscommit
                                                                      )

        return page(title       = title,
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln,
                    errors      = errors,
                    warnings    = warnings)
    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))