Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def make_url(path, **kargs):
""" Helper to generate an absolute invenio URL with query
arguments"""
url = CFG_SITE_URL + path
if kargs:
url += '?' + urlencode(kargs, doseq=True)
return url
def test_get_all_linkbacks1(self):
"""weblinkback - get all linkbacks for lnkENTRY and with a certain status"""
self.assertEqual(0, len(get_all_linkbacks(recid=5, status=CFG_WEBLINKBACK_STATUS['PENDING'])))
self.assertEqual(4, len(get_all_linkbacks(recid=41, status=CFG_WEBLINKBACK_STATUS['PENDING'])))
self.assertEqual(0, len(get_all_linkbacks(recid=41, status=CFG_WEBLINKBACK_STATUS['INSERTED'])))
self.assertEqual(5, len(get_all_linkbacks(recid=42, status=CFG_WEBLINKBACK_STATUS['PENDING'])))
self.assertEqual(0, len(get_all_linkbacks(recid=42, status=CFG_WEBLINKBACK_STATUS['APPROVED'])))
url = CFG_SITE_URL + '/%s/41/linkbacks/' % CFG_SITE_RECORD
expected_texts = ('Linkbacks to review: 4', 'Linkbacks: 0', 'URL1', 'URL2', 'URL3', 'URL4')
for text in expected_texts:
self.assertEqual([], test_web_page_content(url,
username='admin',
expected_text=text))
url = CFG_SITE_URL + '/%s/42/linkbacks/' % CFG_SITE_RECORD
expected_texts = ('Linkbacks to review: 5', 'Linkbacks: 0', 'URL5', 'URL6', 'URL7', 'URL8', 'URL1')
for text in expected_texts:
self.assertEqual([], test_web_page_content(url,
username='admin',
expected_text=text))
def test_websearch_admin_interface_pages_availability(self):
"""websearchadmin - availability of WebSearch Admin interface pages"""
baseurl = CFG_SITE_URL + '/admin/websearch/websearchadmin.py'
_exports = ['',
'?mtype=perform_showall',
'?mtype=perform_addcollection',
'?mtype=perform_addcollectiontotree',
'?mtype=perform_modifycollectiontree',
'?mtype=perform_checkwebcollstatus',
'?mtype=perform_checkcollectionstatus',]
error_messages = []
for url in [baseurl + page for page in _exports]:
# first try as guest:
error_messages.extend(test_web_page_content(url,
username='guest',
expected_text=
'Authorization failure'))
def build_url(sysno, name, file_type, extension, is_icon=False):
"""
Build the local URL to the file with given parameters
@param sysno: record ID
@name name: base name of the file
@param file_type: as chosen by CKEditor: 'File', 'Image', 'Flash', 'Media'
@param extension: file extension, including '.'
"""
return CFG_SITE_URL + '/'+ CFG_SITE_RECORD +'/' + str(sysno) + \
'/files/' + urllib.quote(build_docname(name, file_type, extension)) + \
(is_icon and '?subformat=icon' or '')
You can approve this document by visiting this page:
<%s>
You can also check the status of the document from:
<%s>
""" % (str(RN),
str(categ),
str(item_details['title']),
authors,
CFG_SITE_URL,
CFG_SITE_RECORD,
str(item_details['recid']),
actor,
recommendation,
str(CFG_SITE_URL + "/publiline.py?flow=cplx&doctype="+doctype+"&ln=en&apptype=RRP&categ="+categ+"&RN="+RN+"&action=ProjectLeaderDecision"),
str(CFG_SITE_URL + "/publiline.py?flow=cplx&doctype="+doctype+"&ln=en&apptype=RRP&categ="+categ+"&RN="+RN))
# send mails to all members of the ATLAS group
send_email(FROMADDR, email,"Request for approval/rejection of document %s" % (RN), message)
return ""
def get_admin_guide_link(ln):
"""
Returns the link to the admin guide.
"""
_ = gettext_set_language(ln)
return '<a href="%s/help/admin/bibsort-admin-guide">%s</a>' % (CFG_SITE_URL, _('BibSort Guide'))
if recid:
fields = (request_type, recid, budget_code, cash,
period_of_interest_from, period_of_interest_to,
additional_comments)
else:
fields = (request_type, title, authors, place, publisher, year, edition,
this_edition_only, isbn, standard_number, budget_code,
cash, period_of_interest_from, period_of_interest_to,
additional_comments)
# Check if user is logged
uid = getUid(req)
if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
return page_not_authorized(req, "%s/ill/purchase_request_step1" % \
(CFG_SITE_URL,),
navmenuid="ill")
elif uid == -1 or isGuestUser(uid):
return redirect_to_url(req, "%s/youraccount/login%s" % (
CFG_SITE_SECURE_URL,
make_canonical_urlargd({
'referer' : "%s/ill/purchase_request_step2%s" % (
CFG_SITE_SECURE_URL,
make_canonical_urlargd(argd, {})),
"ln" : ln}, {})), norobot=True)
_ = gettext_set_language(ln)
user_info = collect_user_info(req)
if not user_info['precached_useloans']:
return page_not_authorized(req, "../", \
text = _("You are not authorized to use ill."))
'sql': (int, 0),
'ln': (str, CFG_SITE_LANG)})
ln = argd['ln']
user_info = collect_user_info(req)
(auth_code, auth_msg) = acc_authorize_action(user_info, 'runwebstatadmin')
if auth_code:
return page_not_authorized(req,
navtrail=self.navtrail % {'ln_link': (ln != CFG_SITE_LANG and '?ln=' + ln) or ''},
text=auth_msg,
navmenuid='circulation users lists',
ln=ln)
return page(title="Circulation users lists",
body=perform_display_keyevent('user lists', argd, req, ln=ln),
navtrail="""<a href="%s/stats/%s" class="navtrail">Statistics</a>""" % \
(CFG_SITE_URL, (ln != CFG_SITE_LANG and '?ln=' + ln) or ''),
description="CDS, Statistics, Circulation users lists",
keywords="CDS, statistics, Circulation users lists",
req=req,
lastupdated=__lastupdated__,
navmenuid='circulation users lists',
language=ln)
/**/
[<a href="">%(delete)s</a>]
''' % {'bibdocname': escape_javascript_string(abstract_bibdoc['get_docname'], escape_for_html=False),
'delete': _("delete"),
'form_url_params': form_url_params or '',
'id': params_id}
out += ''''''
# Format row
out += '''
<img alt="" src="%s/img/tree_branch.gif">
''' % (even and ' class="even"' or '', hidden_p and ' style="color:#999"' or '', CFG_SITE_URL)
for bibdocfile in abstract_bibdoc['list_latest_files']:
if not updated and show_links and not hidden_p:
out += '<a href="' + bibdocfile.get_url() + '">'
out += bibdocfile.get_format().strip('.')
if not updated and show_links and not hidden_p:
out += '</a>'
out += ' '
# Add format link
out += ''
if main_bibdocfile.get_type() in can_add_format_to_doctypes or \
'*' in can_add_format_to_doctypes and not (hidden_p and protect_hidden_files):
(revise_panel, javascript_prefix) = javascript_display_revise_panel(
action='addFormat',
target=abstract_bibdoc['get_docname'],
show_doctypes=False,
'upload': (str, ''),
'dropbox': (str, '')})
_ = gettext_set_language(argd['ln'])
# Check if user is authorized to deposit publications
user_info = collect_user_info(req)
auth_code, auth_message = acc_authorize_action(
user_info, 'submit', doctype='OpenAIRE')
if auth_code:
if user_info['guest'] == '1':
return redirect_to_url(req, "%s/youraccount/login%s" % (
CFG_SITE_SECURE_URL,
make_canonical_urlargd({
'referer': "%s%s" % (
CFG_SITE_URL,
req.unparsed_uri),
"ln": argd['ln']}, {})))
else:
return page(req=req, body=_("You are not authorized to use OpenAIRE deposition."), title=_("Authorization failure"), navmenuid="submit")
# Get parameters
projectid = argd['projectid']
plus = argd['plus']
style = get_openaire_style(req)
if plus == -1:
try:
plus = bool(session_param_get(req, 'plus'))
except KeyError:
plus = False
session_param_set(req, 'plus', plus)