diff --git a/modules/websession/lib/websession_templates_epfl.py b/modules/websession/lib/websession_templates_epfl.py
index 8d6b71c65..a89cf0cc2 100644
--- a/modules/websession/lib/websession_templates_epfl.py
+++ b/modules/websession/lib/websession_templates_epfl.py
@@ -1,311 +1,383 @@
# -*- coding: utf-8 -*-
"""
EPFL templates.
Websession handles admin menu and login links
"""
import urllib
from invenio.config import CFG_SITE_LANG, CFG_SITE_SECURE_URL, CFG_SITE_URL
from invenio.messages import gettext_set_language
from invenio import websession_templates
+
class Template(websession_templates.Template):
"""
EPFL subclass of websession_template
"""
-
+
def tmpl_account_adminactivities(self, ln, uid, guest, roles, activities):
"""
Displays the admin activities block for this user
Parameters:
- 'ln' *string* - The language to display the interface in
- 'uid' *string* - The used id
- 'guest' *boolean* - If the user is guest
- 'roles' *array* - The current user roles
- 'activities' *array* - The user allowed activities
"""
# load the right message language
_ = gettext_set_language(ln)
out = ""
# guest condition
if guest:
- return _("You seem to be a guest user. You have to %(x_url_open)slogin%(x_url_close)s first.") % \
- {'x_url_open': '',
- 'x_url_close': ''}
+ return _(
+ "You seem to be a guest user. You have to %(x_url_open)slogin%(x_url_close)s first.") % \
+ {
+ 'x_url_open': '',
+ 'x_url_close': ''}
# no rights condition
if not roles:
- return "
" + _("You are not authorized to access administrative functions.") + "
"
+ return "" + _(
+ "You are not authorized to access administrative functions.") + "
"
# displaying form
- out += "" + _("You are enabled to the following roles: %(x_role)s.") % {'x_role': ('' + ", ".join(roles) + "")} + '
'
+ out += "" + _(
+ "You are enabled to the following roles: %(x_role)s.") % {
+ 'x_role': (
+ '' + ", ".join(roles) + "")} + '
'
if activities:
# print proposed links:
activities.sort(lambda x, y: cmp(x.lower(), y.lower()))
tmp_out = ''
for action in activities:
if action == "runbibedit":
- tmp_out += """
%s""" % (CFG_SITE_URL, _("Run Record Editor"))
+ tmp_out += """
%s""" % (
+ CFG_SITE_URL, _("Run Record Editor"))
if action == "runbibeditmulti":
- tmp_out += """
%s""" % (CFG_SITE_URL, _("Run Multi-Record Editor"))
+ tmp_out += """
%s""" % (
+ CFG_SITE_URL, _("Run Multi-Record Editor"))
if action == "runbibcirculation":
- tmp_out += """
%s""" % (CFG_SITE_URL, ln, _("Run BibCirculation"))
+ tmp_out += """
%s""" % (
+ CFG_SITE_URL, ln, _("Run BibCirculation"))
if action == "runbibmerge":
- tmp_out += """
%s""" % (CFG_SITE_URL, _("Run Record Merger"))
+ tmp_out += """
%s""" % (
+ CFG_SITE_URL, _("Run Record Merger"))
if action == "runbibswordclient":
- tmp_out += """
%s""" % (CFG_SITE_URL, _("Run BibSword Client"))
+ tmp_out += """
%s""" % (
+ CFG_SITE_URL, _("Run BibSword Client"))
if action == "runbatchuploader":
- tmp_out += """
%s""" % (CFG_SITE_URL, ln, _("Run Batch Uploader"))
+ tmp_out += """
%s""" % (
+ CFG_SITE_URL, ln, _("Run Batch Uploader"))
if action == "cfgbibformat":
- tmp_out += """
%s""" % (CFG_SITE_URL, ln, _("Configure BibFormat"))
- tmp_out += """
%s""" % (CFG_SITE_URL, ln, _("Configure BibKnowledge"))
+ tmp_out += """
%s""" % (
+ CFG_SITE_URL, ln, _("Configure BibFormat"))
+ tmp_out += """
%s""" % (
+ CFG_SITE_URL, ln, _("Configure BibKnowledge"))
if action == "cfgoaiharvest":
- tmp_out += """
%s""" % (CFG_SITE_URL, ln, _("Configure OAI Harvest"))
+ tmp_out += """
%s""" % (
+ CFG_SITE_URL, ln, _("Configure OAI Harvest"))
if action == "cfgoairepository":
- tmp_out += """
%s""" % (CFG_SITE_URL, ln, _("Configure OAI Repository"))
+ tmp_out += """
%s""" % (
+ CFG_SITE_URL, ln, _("Configure OAI Repository"))
if action == "cfgbibindex":
- tmp_out += """
%s""" % (CFG_SITE_URL, ln, _("Configure BibIndex"))
+ tmp_out += """
%s""" % (
+ CFG_SITE_URL, ln, _("Configure BibIndex"))
if action == "cfgbibrank":
- tmp_out += """
%s""" % (CFG_SITE_URL, ln, _("Configure BibRank"))
+ tmp_out += """
%s""" % (
+ CFG_SITE_URL, ln, _("Configure BibRank"))
if action == "cfgwebaccess":
- tmp_out += """
%s""" % (CFG_SITE_URL, ln, _("Configure WebAccess"))
+ tmp_out += """
%s""" % (
+ CFG_SITE_URL, ln, _("Configure WebAccess"))
if action == "cfgwebcomment":
- tmp_out += """
%s""" % (CFG_SITE_URL, ln, _("Configure WebComment"))
+ tmp_out += """
%s""" % (
+ CFG_SITE_URL, ln, _("Configure WebComment"))
if action == "cfgwebjournal":
- tmp_out += """
%s""" % (CFG_SITE_URL, ln, _("Configure WebJournal"))
+ tmp_out += """
%s""" % (
+ CFG_SITE_URL, ln, _("Configure WebJournal"))
if action == "cfgwebsearch":
- tmp_out += """
%s""" % (CFG_SITE_URL, ln, _("Configure WebSearch"))
+ tmp_out += """
%s""" % (
+ CFG_SITE_URL, ln, _("Configure WebSearch"))
if action == "cfgwebsubmit":
- tmp_out += """
%s""" % (CFG_SITE_URL, ln, _("Configure WebSubmit"))
+ tmp_out += """
%s""" % (
+ CFG_SITE_URL, ln, _("Configure WebSubmit"))
if tmp_out:
- out += _("Here are some interesting web admin links for you:") + tmp_out
+ out += _(
+ "Here are some interesting web admin links for you:") + tmp_out
- out += "
" + _("For more admin-level activities, see the complete %(x_url_open)sAdmin Area%(x_url_close)s.") %\
- {'x_url_open': '',
- 'x_url_close': ''}
+ out += "
" + _(
+ "For more admin-level activities, see the complete %(x_url_open)sAdmin Area%(x_url_close)s.") % \
+ {
+ 'x_url_open': '',
+ 'x_url_close': ''}
return out
-
- def tmpl_create_useractivities_menu(self, user_info, ln, selected, url_referer, guest, username, submitter, referee, admin, usebaskets, usemessages, usealerts, usegroups, useloans, usestats):
+ def tmpl_create_useractivities_menu(self, user_info, ln, selected,
+ url_referer, guest, username,
+ submitter, referee, admin, usebaskets,
+ usemessages, usealerts, usegroups,
+ useloans, usestats):
"""
Returns the main navigation menu with actions based on user's
priviledges
@param ln: The language to display the interface in
@type ln: string
@param selected: If the menu is currently selected
@type selected: boolean
@param url_referer: URL of the page being displayed
@type url_referer: string
@param guest: If the user is guest
@type guest: string
@param username: The username (nickname or email)
@type username: string
@param submitter: If the user is submitter
@type submitter: boolean
@param referee: If the user is referee
@type referee: boolean
@param admin: If the user is admin
@type admin: boolean
@param usebaskets: If baskets are enabled for the user
@type usebaskets: boolean
@param usemessages: If messages are enabled for the user
@type usemessages: boolean
@param usealerts: If alerts are enabled for the user
@type usealerts: boolean
@param usegroups: If groups are enabled for the user
@type usegroups: boolean
@param useloans: If loans are enabled for the user
@type useloans: boolean
@param usestats: If stats are enabled for the user
@type usestats: boolean
@return: html menu of the user activities
@rtype: string
"""
# load the right message language
_ = gettext_set_language(ln)
out = ''
if guest:
return out
+
+ manual_match_url = ''
+
+ # allow admins and TTO, but if TTO, the url is specific
+ if admin:
+ mm_url = '/curator/getter/manual_match/?ln=%s' % ln
+ manual_match_url = '%(' \
+ 'publications_manual_match_label)s' % {
+ 'secure_domain': CFG_SITE_SECURE_URL,
+ 'publications_manual_match_label': _(
+ "to be matched"),
+ 'manual_match_url': mm_url
+ }
+
+ # tto too
+ if admin or 'U10021 [EPFL]' in user_info.get('group', []):
+ mm_url = '/curator/getter/TTO/manual_match/?ln=%s' % ln
+ manual_match_tto_url = '%(' \
+ 'publications_manual_match_label)s' % {
+ 'secure_domain': CFG_SITE_SECURE_URL,
+ 'publications_manual_match_label': _(
+ "to be matched TTO"),
+ 'manual_match_url': mm_url
+ }
+ if manual_match_url:
+ manual_match_url += manual_match_tto_url
+ else:
+ manual_match_url = manual_match_tto_url
+
out = """
""" % {'secure_domain': CFG_SITE_SECURE_URL,
'ln': ln,
- 'sciper': user_info.get('external_uniqueidentifier', [None])[0] or user_info.get('external_cn', [None])[-1] or '',
+ 'sciper': user_info.get('external_uniqueidentifier',
+ [None])[0] or
+ user_info.get('external_cn', [None])[
+ -1] or '',
'my_infoscience_label': _("My profile"),
'collections_label': _("My collections"),
'alerts_label': _("My alerts"),
'publications_validation_label': _("to be validated"),
'publications_import_label': _("to be imported"),
- 'publications_manual_match_label': _("to be matched"),
- }
- junk = _("XX-Translate-test")
+ 'manual_match_url': manual_match_url,
+ }
+
+ junk = _("XX-Translate-test")
return out
- def tmpl_create_adminactivities_menu(self, ln, selected, url_referer, guest, username, submitter, referee, admin, usebaskets, usemessages, usealerts, usegroups, useloans, usestats, activities):
+ def tmpl_create_adminactivities_menu(self, ln, selected, url_referer,
+ guest, username, submitter, referee,
+ admin, usebaskets, usemessages,
+ usealerts, usegroups, useloans,
+ usestats, activities):
"""
Returns the main navigation menu with actions based on user's
priviledges
@param ln: The language to display the interface in
@type ln: string
@param selected: If the menu is currently selected
@type selected: boolean
@param url_referer: URL of the page being displayed
@type url_referer: string
@param guest: If the user is guest
@type guest: string
@param username: The username (nickname or email)
@type username: string
@param submitter: If the user is submitter
@type submitter: boolean
@param referee: If the user is referee
@type referee: boolean
@param admin: If the user is admin
@type admin: boolean
@param usebaskets: If baskets are enabled for the user
@type usebaskets: boolean
@param usemessages: If messages are enabled for the user
@type usemessages: boolean
@param usealerts: If alerts are enabled for the user
@type usealerts: boolean
@param usegroups: If groups are enabled for the user
@type usegroups: boolean
@param useloans: If loans are enabled for the user
@type useloans: boolean
@param usestats: If stats are enabled for the user
@type usestats: boolean
@param activities: dictionary of admin activities
@rtype activities: dict
@return: html menu of the user activities
@rtype: string
"""
# load the right message language
_ = gettext_set_language(ln)
-
+
if not activities:
return ''
-
+
admin_action_list = {}
-
+
tmpl = ' %s'
admin_action_list['curator_functions'] = '\n'.join([
- tmpl % ('/curator/dropbox', _("Dropbox")),
- tmpl % ('/curator/delete', _("Delete by reference")),
- tmpl % ('/curator/laboratories', _("Laboratories management")),
- tmpl % ('/curator/stats/query', _("Laboratories stats")),
- tmpl % ('/curator/authors', _("Authors management")),
- tmpl % ('/curator/users/create', _("Create user")),
- tmpl % ('/curator/metrics', _("Publication statistics / bibliometrics")),
- #tmpl % ('/stats/', _("Site statistics")),
- ])
+ tmpl % ('/curator/dropbox', _("Dropbox")),
+ tmpl % ('/curator/delete', _("Delete by reference")),
+ tmpl % ('/curator/laboratories', _("Laboratories management")),
+ tmpl % ('/curator/stats/query', _("Laboratories stats")),
+ tmpl % ('/curator/authors', _("Authors management")),
+ tmpl % ('/curator/users/create', _("Create user")),
+ tmpl % (
+ '/curator/metrics', _("Publication statistics / bibliometrics")),
+ # tmpl % ('/stats/', _("Site statistics")),
+ ])
admin_action_list['getter_functions'] = '\n'.join([
- tmpl % ('/curator/deduplicate/wos/list', _("Deduplicate")),
- tmpl % ('/curator/getter/manual_match', _("Manual match")),
- tmpl % ('/curator/getter/rejected_imports', _("Rejected imports")),
- ])
-
+ tmpl % ('/curator/deduplicate/wos/list', _("Deduplicate")),
+ tmpl % ('/curator/getter/manual_match', _("Manual match")),
+ tmpl % ('/curator/getter/rejected_imports', _("Rejected imports")),
+ ])
+
activities = activities.items()
activities.sort(lambda x, y: cmp(x[0], y[0]))
- admin_action_list['invenio_functions'] = '\n'.join([tmpl % (url, label) for (label, url) in activities])
+ admin_action_list['invenio_functions'] = '\n'.join(
+ [tmpl % (url, label) for (label, url) in activities])
out = """
""" % (admin_action_list)
-
return out
-
def tmpl_navtrail(self, ln=CFG_SITE_LANG, title=""):
"""
display the navtrail, e.g.:
Your account > Your group > title
@param title: the last part of the navtrail. Is not a link
@param ln: language
return html formatted navtrail
"""
_ = gettext_set_language(ln)
nav_h1 = '%s'
nav_h2 = ""
if (title != ""):
nav_h2 = ' > %s'
nav_h2 = nav_h2 % (CFG_SITE_URL, _("Your Groups"))
- return nav_h1 % (CFG_SITE_URL, _("Your Account")) + nav_h2
+ return nav_h1 % (CFG_SITE_URL, _("Your Account")) + nav_h2
-
- def tmpl_create_userinfobox(self, ln, url_referer, guest, username, submitter, referee, admin, usebaskets, usemessages, usealerts, usegroups, useloans, usestats):
+ def tmpl_create_userinfobox(self, ln, url_referer, guest, username,
+ submitter, referee, admin, usebaskets,
+ usemessages, usealerts, usegroups, useloans,
+ usestats):
"""
Displays the user block
Parameters:
- 'ln' *string* - The language to display the interface in
- 'url_referer' *string* - URL of the page being displayed
- 'guest' *boolean* - If the user is guest
- 'username' *string* - The username (nickname or email)
- 'submitter' *boolean* - If the user is submitter
- 'referee' *boolean* - If the user is referee
- 'admin' *boolean* - If the user is admin
- 'usebaskets' *boolean* - If baskets are enabled for the user
- 'usemessages' *boolean* - If messages are enabled for the user
- 'usealerts' *boolean* - If alerts are enabled for the user
- 'usegroups' *boolean* - If groups are enabled for the user
- 'useloans' *boolean* - If loans are enabled for the user
- 'usestats' *boolean* - If stats are enabled for the user
@note: with the update of CSS classes (cds.cds ->
invenio.css), the variables useloans etc are not used in
this function, since they are in the menus. But we keep
them in the function signature for backwards
compatibility.
"""
# load the right message language
_ = gettext_set_language(ln)
out = ''
if guest:
out += """%(login)s""" % {
- 'sitesecureurl': CFG_SITE_SECURE_URL,
- 'ln' : ln,
- 'referer' : url_referer and ('&referer=%s' % urllib.quote(url_referer)) or '',
- 'login' : _('login')
- }
+ 'sitesecureurl': CFG_SITE_SECURE_URL,
+ 'ln': ln,
+ 'referer': url_referer and (
+ '&referer=%s' % urllib.quote(url_referer)) or '',
+ 'login': _('login')
+ }
else:
out += """%(logout)s""" % {
- 'sitesecureurl' : CFG_SITE_SECURE_URL,
- 'ln' : ln,
- 'logout' : _("logout"),
- }
+ 'sitesecureurl': CFG_SITE_SECURE_URL,
+ 'ln': ln,
+ 'logout': _("logout"),
+ }
out += """ (%(username)s)""" % {
- 'sitesecureurl' : CFG_SITE_SECURE_URL,
- 'ln' : ln,
- 'username' : username
- }
+ 'sitesecureurl': CFG_SITE_SECURE_URL,
+ 'ln': ln,
+ 'username': username
+ }
return out