-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
views: implementation of records_files views
* Closes #71 Co-authored-by: Diego Rodriguez <diego.rodriguez@cern.ch>
- Loading branch information
Showing
11 changed files
with
542 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.. | ||
This file is part of Invenio. | ||
Copyright (C) 2019 CERN. | ||
Invenio is free software; you can redistribute it and/or modify it | ||
under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
|
||
|
||
Configuration | ||
============= | ||
|
||
.. automodule:: invenio_records_files.config | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ Invenio-Records-Files. | |
:maxdepth: 2 | ||
|
||
installation | ||
configuration | ||
usage | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of Invenio. | ||
# Copyright (C) 2019 CERN. | ||
# | ||
# Invenio is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
"""Invenio-Records-Files configuration.""" | ||
|
||
RECORDS_FILES_REST_ENDPOINTS = {} | ||
"""REST endpoints configuration. | ||
You can configure the REST API endpoint to access the record's | ||
files as follows: | ||
.. code-block:: python | ||
RECORDS_FILES_REST_ENDPOINTS = { | ||
'<*_REST_ENDPOINTS>': { | ||
'<record_pid_type>': '<endpoint_suffix>', | ||
} | ||
} | ||
* ``<*_REST_ENDPOINTS>`` corresponds to `Invenio-Records-REST endpoint | ||
configurations names <https://invenio-records-rest.readthedocs.io/en/ | ||
latest/configuration.html#invenio_records_rest.config | ||
.RECORDS_REST_ENDPOINTS>`_ you have defined in your application. | ||
* ``<record_pid_type>`` is the PID type associated to the record defined in | ||
your `Invenio-Records-REST <https://invenio-records-rest.readthedocs.io/en/ | ||
latest/configuration.html#invenio_records_rest. | ||
config.RECORDS_REST_ENDPOINTS>`_ like configuration. | ||
* ``<endpoint_suffix>`` is the endpoint name to access the record's files. | ||
.. code-block:: console | ||
{'recid': '/myawesomefiles'} -> /records/1/myawesomefiles | ||
An example of this configuration is provided in the | ||
`Integration with Invenio REST API | ||
<usage.html#integration-with-invenio-rest-api>`_ section of the documentation. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of Invenio. | ||
# Copyright (C) 2019 CERN. | ||
# | ||
# Invenio is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
"""Flask extension for the Invenio-Records-Files.""" | ||
|
||
|
||
from __future__ import absolute_import, print_function | ||
|
||
from invenio_records_files import config | ||
|
||
|
||
class InvenioRecordsFiles(object): | ||
"""Invenio-Records-Files extension.""" | ||
|
||
def __init__(self, app=None, **kwargs): | ||
"""Extension initialization.""" | ||
if app: | ||
self.init_app(app, **kwargs) | ||
|
||
def init_app(self, app): | ||
"""Flask application initialization.""" | ||
self.init_config(app) | ||
app.extensions['invenio-records-files'] = self | ||
|
||
def init_config(self, app): | ||
"""Initialize configuration.""" | ||
for k in dir(config): | ||
if k.startswith('RECORDS_FILES_'): | ||
app.config.setdefault(k, getattr(config, k)) |
Oops, something went wrong.