From ab72870cf7081b4f884f4b4834344365848d6744 Mon Sep 17 00:00:00 2001 From: Leonardo Rossi Date: Mon, 31 Aug 2015 11:35:35 +0000 Subject: [PATCH] global: bibdocfile dependency removal * INCOMPATIBLE Removes dependency on legacy bibdocfile module. (addresses inveniosoftware/invenio#3233) Signed-off-by: Leonardo Rossi --- invenio_records/views.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/invenio_records/views.py b/invenio_records/views.py index 504101cb..f67dea27 100644 --- a/invenio_records/views.py +++ b/invenio_records/views.py @@ -22,17 +22,20 @@ from __future__ import unicode_literals import cStringIO + +import warnings + from functools import wraps from flask import (Blueprint, abort, current_app, flash, g, redirect, - render_template, request, send_file, url_for) + render_template, request, send_file) + from flask_breadcrumbs import default_breadcrumb_root + from flask_login import current_user + from flask_menu import register_menu -from invenio_collections.decorators import check_collection -from invenio_formatter import (get_output_format_content_type, - response_formated_records) from invenio.base.decorators import wash_arguments from invenio.base.globals import cfg from invenio.base.i18n import _ @@ -41,6 +44,11 @@ register_template_context_processor from invenio.utils import apache +from invenio_collections.decorators import check_collection + +from invenio_formatter import (get_output_format_content_type, + response_formated_records) + from .signals import record_viewed from .utils import visible_collection_tabs @@ -165,11 +173,9 @@ def metadata(recid, of='hd', ot=None): def files(recid): """Return overview of attached files.""" def get_files(): - from invenio.legacy.bibdocfile.api import BibRecDocs - for bibdoc in BibRecDocs(recid).list_bibdocs(): - for file in bibdoc.list_all_files(): - yield file.get_url() - + warnings.warn("Use of bibdocfile has been deprecated.", + DeprecationWarning) + return [] return render_template('records/files.html', files=list(get_files())) @@ -207,13 +213,6 @@ def file(recid, filename): attachment_filename=filename) return send_file(document['uri']) - from invenio_documents.utils import _get_legacy_bibdocs - for fullpath, permission in _get_legacy_bibdocs(recid, filename=filename): - if not permission: - error = 401 - continue - return send_file(fullpath) - abort(error)