Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
categories exist as sub-collections of 'cc'). The second option is
preferred.
@param categories: comma-separated list of journal categories that will be linked from this RSS. If 'all', use all. If empty, try to use current category.
@param label: label of the RSS link
@param rss_icon_url: if provided, display the RSS icon in front of the label
@param rss_icon_width: if provided, declared width for the RSS icon
@param rss_icon_height: if provided, declared height for the RSS icon
@param cc: if provided, use as root collection for the journal, and ignore 'categories' parameter.
@param css_class: CSS class of the RSS link.
"""
args = parse_url_string(bfo.user_info['uri'])
category_name = args["category"]
journal_name = args["journal_name"]
ln = bfo.lang
_ = gettext_set_language(ln)
if cc:
categories = []
elif categories.lower() == 'all':
categories = get_journal_categories(journal_name)
elif not categories and category_name:
categories = [category_name]
else:
categories = categories.split(',')
# Build the query definition for selected categories. If a
# category name can a match collection name, we can simply search
# in this collection. Otherwise we have to search using the query
# definition of the category.
# Note that if there is one category that does not match a
def tmpl_show_examples(self, collection_name, ln):
"returns html with js controls for example searches"
# load the right message language
_ = gettext_set_language(ln)
def get_example_search_queries(name):
"""Returns list of sample search queries for this collection.
"""
res = run_sql("""SELECT example.body FROM example LEFT JOIN collection_example ON example.id=collection_example.id_example LEFT JOIN collection ON collection_example.id_collection=collection.id WHERE collection.name=%s ORDER BY collection_example.score""", (name,))
return [query[0] for query in res]
# Build example of queries for this collection
example_search_queries = get_example_search_queries(collection_name)
example_search_queries_links = [create_html_link(self.build_search_url(p=example_query,
ln=ln,
aas= 0,
cc=collection_name),
{},
cgi.escape(example_query),
def tmpl_admin_configure_journal(self, ln, journal_name='', xml_config=None,
action='edit', msg=None):
"""
Display a page to change the settings of a journal. Also used to
add a new journal.
"""
out = ''
_ = gettext_set_language(ln)
journal_name_readonly = 'readonly="readonly" disabled="disabled"'
journal_name_note = ''
submit_button_label = _('Apply')
if action == 'add':
journal_name = ''
journal_name_readonly = ''
journal_name_note = 'Used in URLs. Choose it short and meaningful. This cannot be changed later'
submit_button_label = _('Add')
elif action in ['edit', 'editDone']:
# Display navigation menu
out += '''<table class="admin_wvar">
<tbody><tr><th cellspacing="0" class="adminheaderleft" colspan="5">%(menu)s</th></tr>
<tr>
<td>0. <small><a href="administrate?journal_name=%(journal_name)s">Administrate</a></small> </td>
<td>1. <small><a href="feature_record?journal_name=%(journal_name)s">Feature a Record</a></small> </td>
<td>2. <small>Edit Configuration</small> </td></tr></tbody></table>
def perform_remove_alert(alert_name, id_query, id_basket, uid, ln=CFG_SITE_LANG):
"""perform_remove_alert: remove an alert from the database
input: alert name
identifier of the query;
identifier of the basket
uid
output: confirmation message + the list of alerts Web page"""
# load the right language
_ = gettext_set_language(ln)
# security check:
if not check_user_can_add_alert(uid, id_query):
raise AlertError(_("You do not have rights for this operation."))
# set variables
out = ""
if (None in (alert_name, id_query, id_basket, uid)):
return out
# remove a row from the alerts table: user_query_basket
query = """DELETE FROM user_query_basket
WHERE id_user=%s AND id_query=%s AND id_basket=%s"""
params = (uid, id_query, id_basket)
res = run_sql(query, params)
if res:
out += "The alert <b>%s</b> has been removed from your profile.<br><br>\n" % cgi.escape(alert_name)
else:
out += "Unable to remove alert <b>%s</b>.<br><br>\n" % cgi.escape(alert_name)
def get_format_template_attrs(filename):
"""
Returns the attributes of the format template with given filename
The attributes are {'name', 'description'}
Caution: the function does not check that path exists or
that the format element is valid.
@param filename: the name of a format template
@return: a structure with detailed information about given format template
"""
_ = gettext_set_language(CFG_SITE_LANG)
attrs = {}
attrs['name'] = ""
attrs['description'] = ""
try:
template_file = open("%s%s%s" % (CFG_BIBFORMAT_TEMPLATES_PATH,
os.sep,
filename))
code = template_file.read()
template_file.close()
match = None
if filename.endswith(".xsl"):
# .xsl
attrs['name'] = filename[:-4]
else:
# .bft
def tmpl_account_list_alerts(self, ln, alerts):
"""
Displays all the alerts in the main "Your account" page
Parameters:
- 'ln' *string* - The language to display the interface in
- 'alerts' *array* - The existing alerts IDs ('id' + 'name' pairs)
"""
# load the right message language
_ = gettext_set_language(ln)
out = """<form method="post" action="../youralerts/list" name="displayalert">
%(you_own)s:
<select name="id_alert">
<option value="0">- %(alert_name)s -</option>""" % {
'you_own' : _("You own the following alerts:"),
'alert_name' : _("alert name"),
}
for alert in alerts :
out += """<option value="%(id)s">%(name)s</option>""" % \
{'id': alert['id'], 'name': cgi.escape(alert['name'])}
out += """</select>
<input value="%(show)s" type="submit" class="formbutton">
</form>""" % {
'show' : _("SHOW"),
}
def get_waiting_requests(req, request_id, print_data, ln=CFG_SITE_LANG):
"""
Get all loans requests who are waiting.
@type request_id: integer.
@param request_id: identify the hold request. It is also the primary key
of the table crcLOANREQUEST.
@type print_data: string.
@param print_data: print requests information.
@return: list of waiting requests (on loan with hold).
"""
_ = gettext_set_language(ln)
if print_data == 'true':
return print_pending_hold_requests_information(req, ln)
elif request_id:
db.update_loan_request_status(request_id,'cancelled')
update_request_data(request_id)
result = db.get_loan_request_by_status('waiting')
else:
result = db.get_loan_request_by_status('waiting')
navtrail_previous_links = '<a class="navtrail">Admin Area' \
'</a>' % (CFG_SITE_URL,)
def format_element(bfo, detail='no'):
""" Prints the data of a journal authority record in HTML. By default prints
brief version.
@param detail: whether the 'detailed' rather than the 'brief' format
@type detail: 'yes' or 'no'
"""
from invenio.messages import gettext_set_language
_ = gettext_set_language(bfo.lang) # load the right message language
# return value
out = ""
# local function
def stringify_dict(d):
""" return string composed values in d """
_str = ""
if 'a' in d:
_str += d['a']
return _str or ''
# brief
main_dicts = bfo.fields('130%%')
if len(main_dicts):
main_dict = main_dicts[0]
main = stringify_dict(main_dict)
##out += "<p>" + "<strong>" + _("Main %s name") % _("journal") + "</strong>" + ": " + main + "</p>"
out += "<a href="" +"/record/"+ str(bfo.recID) +"?ln=" + bfo.lang + "" style="margin-top:0px;margin-bottom:0px">" + main + "</a>"
@param buttons_verbiage_dict: language for the buttons
@type buttons_verbiage_dict: dict
'''
session = get_session(req)
personinfo = {}
try:
personinfo = session["personinfo"]
except KeyError:
return ""
if 'ln' in personinfo:
ln = personinfo["ln"]
else:
ln = CFG_SITE_LANG
_ = gettext_set_language(ln)
if not verbiage_dict:
verbiage_dict = self._get_default_verbiage_dicts_for_admin(req)
if not buttons_verbiage_dict:
buttons_verbiage_dict = self._get_default_buttons_verbiage_dicts_for_admin(req)
all_papers = webapi.get_papers_by_person_id(self.person_id,
ext_out=True)
records = [{'recid': paper[0],
'bibref': paper[1],
'flag': paper[2],
'authorname': paper[3],
'authoraffiliation': paper[4],
'paperdate': paper[5],
'rt_status': paper[6],
def doctypelist(req, ln=CFG_SITE_LANG):
"""List all WebSubmit document types."""
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 = perform_request_list_doctypes()
return page(title = "Available WebSubmit Document Types",
body = body,
navtrail = get_navtrail(ln),
uid = uid,
lastupdated = __lastupdated__,
req = req,
language = ln)
else:
## user is not authorised to use WebSubmit Admin:
return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))