def format_element(bfo):
    """
    Display administration links for this articles when user is an
    editor of the journal
    """
    out = ''
    if bfo.user_info['uri'].startswith('/journal'):
        # Print editing links
        args = parse_url_string(bfo.user_info['uri'])
        journal_name = args["journal_name"]
        editor = False
        if acc_authorize_action(bfo.user_info['uid'],
                                'cfgwebjournal',
                                name="%s" % journal_name)[0] == 0:
            editor = True
        issue_number = args["issue"]

        if editor:
            recid = bfo.control_field('001')
            (doctype, identifier_element, identifier_field) = \
                      get_journal_submission_params(journal_name)
            if identifier_field.startswith('00'):
                identifier = bfo.control_field(identifier_field)
            else:
                identifier = bfo.field(identifier_field)

            out += '''
<div style="float:right;margin-left:5px;font-weight:700;">
  <p>
    <a href="%(CFG_SITE_URL)s/submit/direct?%(identifier_element)s=%(identifier)s&amp;sub=MBI%(doctype)s" target="_blank"> >> edit article</a>
  </p>
  <p>
    <a href="%(CFG_SITE_URL)s/%(CFG_SITE_RECORD)s/%(recid)s" target="_blank"> >> record in %(CFG_SITE_NAME_INTL)s</a>
  </p>
  <p>
    <a href="%(CFG_SITE_URL)s/admin/webjournal/webjournaladmin.py/regenerate?journal_name=%(journal_name)s&amp;issue=%(issue_number)s"> >> publish changes</a>
  </p>
</div>''' % {
                'CFG_SITE_URL':
                CFG_SITE_URL,
                'CFG_SITE_RECORD':
                CFG_SITE_RECORD,
                'identifier':
                identifier,
                'recid':
                recid,
                'journal_name':
                journal_name,
                'issue_number':
                issue_number,
                'doctype':
                doctype,
                'identifier_element':
                identifier_element,
                'CFG_SITE_NAME_INTL':
                CFG_SITE_NAME_INTL.get(bfo.lang, CFG_SITE_NAME)
            }

    return out
def format_element(bfo):
    """
    Display administration links for this articles when user is an
    editor of the journal
    """
    out = ''
    if bfo.user_info['uri'].startswith('/journal'):
        # Print editing links
        args = parse_url_string(bfo.user_info['uri'])
        journal_name = args["journal_name"]
        editor = False
        if acc_authorize_action(bfo.user_info['uid'], 'cfgwebjournal',
                                name="%s" % journal_name)[0] == 0:
            editor = True
        issue_number = args["issue"]

        if editor:
            recid = bfo.control_field('001')
            (doctype, identifier_element, identifier_field) = \
                      get_journal_submission_params(journal_name)
            if identifier_field.startswith('00'):
                identifier = bfo.control_field(identifier_field)
            else:
                identifier = bfo.field(identifier_field)

            out += '''
<div style="float:right;margin-left:5px;font-weight:700;">
  <p>
    <a href="%(CFG_SITE_URL)s/submit/direct?%(identifier_element)s=%(identifier)s&amp;sub=MBI%(doctype)s" target="_blank"> >> edit article</a>
  </p>
  <p>
    <a href="%(CFG_SITE_URL)s/%(CFG_SITE_RECORD)s/%(recid)s" target="_blank"> >> record in %(CFG_SITE_NAME_INTL)s</a>
  </p>
  <p>
    <a href="%(CFG_SITE_URL)s/admin/webjournal/webjournaladmin.py/regenerate?journal_name=%(journal_name)s&amp;issue=%(issue_number)s"> >> publish changes</a>
  </p>
</div>''' % {'CFG_SITE_URL': CFG_SITE_URL,
             'CFG_SITE_RECORD': CFG_SITE_RECORD,
             'identifier': identifier,
             'recid': recid,
             'journal_name': journal_name,
             'issue_number': issue_number,
             'doctype': doctype,
             'identifier_element': identifier_element,
             'CFG_SITE_NAME_INTL': CFG_SITE_NAME_INTL.get(bfo.lang,
                                                          CFG_SITE_NAME)}

    return out
def format(bfo):
    """
    Display administration links for this articles when user is an
    editor of the journal
    """
    out = ""
    if bfo.user_info["uri"].startswith("/journal"):
        # Print editing links
        args = parse_url_string(bfo.user_info["uri"])
        journal_name = args["journal_name"]
        editor = False
        if acc_authorize_action(bfo.user_info["uid"], "cfgwebjournal", name="%s" % journal_name)[0] == 0:
            editor = True
        issue_number = args["issue"]

        if editor:
            recid = bfo.control_field("001")
            (doctype, identifier_element, identifier_field) = get_journal_submission_params(journal_name)
            if identifier_field.startswith("00"):
                identifier = bfo.control_field(identifier_field)
            else:
                identifier = bfo.field(identifier_field)

            out += """
<div style="float:right;margin-left:5px;font-weight:700;">
  <p>
    <a href="%(CFG_SITE_URL)s/submit/direct?%(identifier_element)s=%(identifier)s&amp;sub=MBI%(doctype)s" target="_blank"> >> edit article</a>
  </p>
  <p>
    <a href="%(CFG_SITE_URL)s/record/%(recid)s" target="_blank"> >> record in %(CFG_SITE_NAME_INTL)s</a>
  </p>
  <p>
    <a href="%(CFG_SITE_URL)s/admin/webjournal/webjournaladmin.py/regenerate?journal_name=%(journal_name)s&amp;issue=%(issue_number)s"> >> publish changes</a>
  </p>
</div>""" % {
                "CFG_SITE_URL": CFG_SITE_URL,
                "identifier": identifier,
                "recid": recid,
                "journal_name": journal_name,
                "issue_number": issue_number,
                "doctype": doctype,
                "identifier_element": identifier_element,
                "CFG_SITE_NAME_INTL": CFG_SITE_NAME_INTL.get(bfo.lang, CFG_SITE_NAME),
            }

    return out
 def test_get_journal_submission_params(self):
     """webjournal - returns params for the submission of articles """
     submissions = wju.get_journal_submission_params('AtlantisTimes')
     self.assertEqual(submissions[0], 'DEMOJRN')
     self.assertEqual(submissions[1], 'DEMOJRN_RN')
     self.assertEqual(submissions[2], '037__a')
 def test_get_journal_submission_params(self):
     """webjournal - returns params for the submission of articles """
     submissions = wju.get_journal_submission_params('AtlantisTimes')
     self.assertEqual(submissions[0], 'DEMOJRN')
     self.assertEqual(submissions[1], 'DEMOJRN_RN')
     self.assertEqual(submissions[2], '037__a')
def format_element(bfo):
    """
    Display administration links for this articles when user is an
    editor of the journal
    """
    out = ''
    stats_admin_link = ''
    if bfo.user_info['uri'].startswith('/journal'):
        # Print editing links
        args = parse_url_string(bfo.user_info['uri'])
        journal_name = args["journal_name"]
        editor = False
        if acc_authorize_action(bfo.user_info['uid'], 'cfgwebjournal',
                                name="%s" % journal_name)[0] == 0:
            editor = True
        issue_number = args["issue"]

        if editor:
            recid = bfo.control_field('001')
            (doctype, identifier_element, identifier_field) = \
                      get_journal_submission_params(journal_name)
            if identifier_field.startswith('00'):
                identifier = bfo.control_field(identifier_field)
            else:
                identifier = bfo.field(identifier_field)

            (auth_code, auth_msg) = acc_authorize_action(bfo.user_info, 'runwebstatadmin')
            if not auth_code:
                # User will be allowed to see stats
                stats_admin_link = '''
                <p>
                    <a href="%(CFG_SITE_URL)s/stats/customevent?ids=journals&amp;cols0=articleid&col_value0=%(recid)s&amp;timespan=last+month"> &raquo; statistics</a>
                </p>
                ''' % {'CFG_SITE_URL': CFG_SITE_URL,
                       'recid': recid}

            out += '''
<div style="float:right;margin-left:5px;font-weight:700;">
  <p>
    <a href="%(CFG_SITE_URL)s/submit/direct?%(identifier_element)s=%(identifier)s&amp;sub=MBI%(doctype)s" target="_blank"> &raquo; edit article</a>
  </p>
  <p>
    <a href="%(CFG_SITE_URL)s/%(CFG_SITE_RECORD)s/%(recid)s" target="_blank"> &raquo; record in %(CFG_SITE_NAME_INTL)s</a>
  </p>
  <p>
    <a href="%(CFG_SITE_URL)s/admin/webjournal/webjournaladmin.py/regenerate?journal_name=%(journal_name)s&amp;issue=%(issue_number)s"> &raquo; publish changes</a>
  </p>
  %(stats_admin_link)s
</div>''' % {'CFG_SITE_URL': CFG_SITE_URL,
             'CFG_SITE_RECORD': CFG_SITE_RECORD,
             'identifier': identifier,
             'recid': recid,
             'journal_name': journal_name,
             'issue_number': issue_number,
             'doctype': doctype,
             'identifier_element': identifier_element,
             'CFG_SITE_NAME_INTL': CFG_SITE_NAME_INTL.get(bfo.lang,
                                                          CFG_SITE_NAME),
             'stats_admin_link': stats_admin_link}

    return out
def format_element(bfo):
    """
    Display administration links for this articles when user is an
    editor of the journal
    """
    out = ''
    stats_admin_link = ''
    if bfo.user_info['uri'].startswith('/journal'):
        # Print editing links
        args = parse_url_string(bfo.user_info['uri'])
        journal_name = args["journal_name"]
        editor = False
        if acc_authorize_action(bfo.user_info['uid'],
                                'cfgwebjournal',
                                name="%s" % journal_name)[0] == 0:
            editor = True
        issue_number = args["issue"]

        if editor:
            recid = bfo.control_field('001')
            (doctype, identifier_element, identifier_field) = \
                      get_journal_submission_params(journal_name)
            if identifier_field.startswith('00'):
                identifier = bfo.control_field(identifier_field)
            else:
                identifier = bfo.field(identifier_field)

            (auth_code,
             auth_msg) = acc_authorize_action(bfo.user_info, 'runwebstatadmin')
            if not auth_code:
                # User will be allowed to see stats
                stats_admin_link = '''
                <p>
                    <a href="%(CFG_SITE_URL)s/stats/customevent?ids=journals&amp;cols0=articleid&col_value0=%(recid)s&amp;timespan=last+month"> &raquo; statistics</a>
                </p>
                ''' % {
                    'CFG_SITE_URL': CFG_SITE_URL,
                    'recid': recid
                }

            out += '''
<div style="float:right;margin-left:5px;font-weight:700;">
  <p>
    <a href="%(CFG_SITE_URL)s/submit/direct?%(identifier_element)s=%(identifier)s&amp;sub=MBI%(doctype)s" target="_blank"> &raquo; edit article</a>
  </p>
  <p>
    <a href="%(CFG_SITE_URL)s/%(CFG_SITE_RECORD)s/%(recid)s" target="_blank"> &raquo; record in %(CFG_SITE_NAME_INTL)s</a>
  </p>
  <p>
    <a href="%(CFG_SITE_URL)s/admin/webjournal/webjournaladmin.py/regenerate?journal_name=%(journal_name)s&amp;issue=%(issue_number)s"> &raquo; publish changes</a>
  </p>
  %(stats_admin_link)s
</div>''' % {
                'CFG_SITE_URL':
                CFG_SITE_URL,
                'CFG_SITE_RECORD':
                CFG_SITE_RECORD,
                'identifier':
                identifier,
                'recid':
                recid,
                'journal_name':
                journal_name,
                'issue_number':
                issue_number,
                'doctype':
                doctype,
                'identifier_element':
                identifier_element,
                'CFG_SITE_NAME_INTL':
                CFG_SITE_NAME_INTL.get(bfo.lang, CFG_SITE_NAME),
                'stats_admin_link':
                stats_admin_link
            }

    return out