Skip to content

Commit

Permalink
organisation: improve specific URL
Browse files Browse the repository at this point in the history
* Renames default organisation from `sonar` to `global`.
* Removes `/organisation` from URL.
* Closes #215.

Co-Authored-by: Sébastien Délèze <sebastien.deleze@rero.ch>
  • Loading branch information
Sébastien Délèze committed Aug 17, 2020
1 parent c734f95 commit d204282
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion sonar/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _(x):
#: Frontpage template.
THEME_FRONTPAGE_TEMPLATE = 'sonar/frontpage.html'
#: Theme logo
THEME_LOGO = 'images/sonar-logo.svg'
THEME_LOGO = 'images/global-logo.svg'

THEME_ERROR_TEMPLATE = 'sonar/page_error.html'

Expand Down
2 changes: 1 addition & 1 deletion sonar/modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
SONAR_APP_INTERNAL_IPS = ['127.0.0.1']
"""Internal IPs for accessing files."""

SONAR_APP_DEFAULT_ORGANISATION = 'sonar'
SONAR_APP_DEFAULT_ORGANISATION = 'global'
"""Default organisation key."""

SONAR_APP_BABEL_TRANSLATE_JSON_KEYS = [
Expand Down
2 changes: 1 addition & 1 deletion sonar/modules/documents/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
__name__,
template_folder='templates',
static_folder='static',
url_prefix='/organisation/<view>')
url_prefix='/<view>')
"""Blueprint used for loading templates and static assets
The sole purpose of this blueprint is to ensure that Invenio can find the
Expand Down
File renamed without changes
2 changes: 1 addition & 1 deletion tests/api/documents/test_documents_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_list(app, client, make_document, superuser, admin, moderator,
assert res.json['aggregations'].get('organisation')

# Public search
res = client.get(url_for('invenio_records_rest.doc_list', view='sonar'))
res = client.get(url_for('invenio_records_rest.doc_list', view='global'))
assert res.status_code == 200
assert res.json['hits']['total'] == 2
assert res.json['aggregations'].get('organisation')
Expand Down
18 changes: 9 additions & 9 deletions tests/ui/documents/test_documents_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@

def test_default_view_code(app):
"""Test set default view code."""
views.default_view_code(None, {'view': 'sonar'})
views.default_view_code(None, {'view': 'global'})


def test_store_organisation(db, organisation):
"""Test store organisation in globals."""
# Default view, no organisation stored.
views.store_organisation(None, {'view': 'sonar'})
views.store_organisation(None, {'view': 'global'})
assert not g.get('organisation')

# Existing organisation stored
Expand Down Expand Up @@ -326,7 +326,7 @@ def test_part_of_format():
def test_is_file_restricted(app, organisation):
"""Test if a file is restricted by embargo date and/or organisation."""
g.pop('organisation', None)
views.store_organisation(None, {'view': 'sonar'})
views.store_organisation(None, {'view': 'global'})

record = {'organisation': {'pid': 'org'}}

Expand Down Expand Up @@ -397,7 +397,7 @@ def test_is_file_restricted(app, organisation):

# Restricted by embargo date and organisation
g.pop('organisation', None)
views.store_organisation(None, {'view': 'sonar'})
views.store_organisation(None, {'view': 'global'})
with app.test_request_context(environ_base={'REMOTE_ADDR': '10.1.2.3'}):
assert views.is_file_restricted(
{
Expand All @@ -423,20 +423,20 @@ def test_is_file_restricted(app, organisation):
def test_get_current_organisation_code(app, organisation):
"""Test get current organisation."""
# No globals and no args
assert views.get_current_organisation_code() == 'sonar'
assert views.get_current_organisation_code() == 'global'

# Default globals and no args
views.store_organisation(None, {'view': 'sonar'})
assert views.get_current_organisation_code() == 'sonar'
views.store_organisation(None, {'view': 'global'})
assert views.get_current_organisation_code() == 'global'

# Organisation globals and no args
views.store_organisation(None, {'view': 'org'})
assert views.get_current_organisation_code() == 'org'

# Args is global
with app.test_request_context() as req:
req.request.args = {'view': 'sonar'}
assert views.get_current_organisation_code() == 'sonar'
req.request.args = {'view': 'global'}
assert views.get_current_organisation_code() == 'global'

# Args has organisation view
with app.test_request_context() as req:
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ def test_get_view_code(organisation):
assert get_view_code() == 'org'

g.pop('organisation', None)
assert get_view_code() == 'sonar'
assert get_view_code() == 'global'

0 comments on commit d204282

Please # to comment.