Skip to content

Commit

Permalink
documents: removes permssions from the search list
Browse files Browse the repository at this point in the history
* Removes the useless files permissions from the search list to speed up the server responses.

Co-Authored-by: Johnny Mariéthoz <Johnny.Mariethoz@rero.ch>
  • Loading branch information
jma committed Jan 30, 2024
1 parent 221d31d commit 51e9fd2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
10 changes: 5 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ invenio-theme = ">=2.5.7,<3.0.0"

# Invenio auth bundle
invenio-access = ">=2.0.0,<3.0.0"
invenio-accounts = ">=3.0.0,<4.0.0"
invenio-accounts = ">=3.5.2,<4.0.0"
invenio-oauth2server = ">=2.0.0,<3.0.0"
invenio-oauthclient = ">=3.0.0,<4.0.0"
invenio-userprofiles = "^2.3.1"
Expand Down
2 changes: 1 addition & 1 deletion sonar/modules/documents/marshmallow/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class DocumentListMetadataSchemaV1(StrictKeysMixin):
customField3 = fields.List(fields.String(validate=validate.Length(min=1)))
masked = SanitizedUnicode()
_bucket = SanitizedUnicode()
_files = Nested(FileSchemaV1, many=True)
_files = Nested(ThumbnailSchemaV1, many=True)
_oai = fields.Dict()
# When loading, if $schema is not provided, it's retrieved by
# Record.schema property.
Expand Down
15 changes: 15 additions & 0 deletions tests/api/documents/test_documents_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@
from invenio_accounts.testutils import login_user_via_session


def test_get(client, document_with_file):
"""Get REST methods."""
res = client.get(url_for('invenio_records_rest.doc_list', view='global'))
assert res.status_code == 200
assert res.json['hits']['total']['value'] == 1
# the search results does not contains permissions
assert not res.json['hits']['hits'][0]['metadata']['_files'][0].get("permissions")

# the item result should contains permissions
res = client.get(url_for('invenio_records_rest.doc_item', pid_value=document_with_file['pid']))
assert res.status_code == 200
assert res.json['metadata']['_files'][0]['permissions'] == {
'delete': False, 'read': False,'update': False}


def test_put(app, client, document_with_file):
"""Test putting metadata on existing file."""
# Disable configuration
Expand Down

0 comments on commit 51e9fd2

Please sign in to comment.