Skip to content

Commit

Permalink
global: removal of Invenio-Records-UI
Browse files Browse the repository at this point in the history
* Removes `record_file_factory` extenstion property. (addresses inveniosoftware#134)

* Moves `file_download_ui` utility function to Invenio-Records-Files.

Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
  • Loading branch information
jirikuncar committed Nov 9, 2016
1 parent bd3f879 commit d13d096
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 160 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ indent_size = 4
# isort plugin configuration
known_standard_library = mimetypes
known_first_party = invenio_files_rest
known_third_party = invenio_access, invenio_admin, invenio_accounts, invenio_db, invenio_records, invenio_rest, invenio_records_files, invenio_records_ui
known_third_party = invenio_access, invenio_admin, invenio_accounts, invenio_db, invenio_rest
multi_line_output = 2
default_section = THIRDPARTY

Expand Down
15 changes: 0 additions & 15 deletions invenio_files_rest/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,6 @@ def __init__(self, app):
"""Initialize state."""
self.app = app

@cached_property
def record_file_factory(self):
"""Load default storage factory."""
r = load_or_import_from_config(
'FILES_REST_RECORD_FILE_FACTORY', app=self.app)
if r is not None:
return r
else:
try:
get_distribution('invenio-records-files')
from invenio_records_files.utils import record_file_factory
return record_file_factory
except DistributionNotFound:
return lambda pid, record, filename: None

@cached_property
def storage_factory(self):
"""Load default storage factory."""
Expand Down
46 changes: 0 additions & 46 deletions invenio_files_rest/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,52 +302,6 @@ def decorate(*args, **kwargs):
)


#
# Records-UI integration
#
def file_download_ui(pid, record, **kwargs):
"""File download view for a given record.
Plug this method into your ``RECORDS_UI_ENDPOINTS`` configuration:
.. code-block:: python
RECORDS_UI_ENDPOINTS = dict(
recid=dict(
# ...
route='/records/<pid_value/files/<filename>',
view_imp='invenio_files_rest.views.file_download_ui',
record_class='invenio_records_files.api:Record',
)
)
:param pid: The :class:`invenio_pidstore.models.PersistentIdentifier`
instance.
:param record: The record metadata.
"""
# Extract file from record.
fileobj = current_files_rest.record_file_factory(
pid, record, request.view_args.get('filename'))

if not fileobj:
abort(404)

obj = fileobj.obj

# Check permissions
ObjectResource.check_object_permission(obj)

# Send file.
return ObjectResource.send_object(
obj.bucket, obj,
expected_chksum=fileobj.get('checksum'),
logger_data=dict(
bucket_id=obj.bucket_id,
pid_type=pid.pid_type,
pid_value=pid.pid_value,
))


#
# REST resources
#
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
'invenio-accounts>=1.0.0a15',
'invenio-admin>=1.0.0a3',
'invenio-celery>=1.0.0a4',
'invenio-records-files>=1.0.0a4',
'invenio-records-ui>=1.0.0a5',
'isort>=4.2.2',
'mock>=1.3.0',
'pydocstyle>=1.0.0',
Expand Down
96 changes: 0 additions & 96 deletions tests/test_views_records_ui.py

This file was deleted.

0 comments on commit d13d096

Please sign in to comment.