-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upgrades Invenio to version 3.2 (alpha 9). * Configures Invenio files REST. * Creates default location for storing files. * Removes unnecessary entries (setup_requires and tests_require) in setup.py. * Closes #81 Co-Authored-by: Sébastien Délèze <sebastien.deleze@rero.ch>
- Loading branch information
Sébastien Délèze
committed
Dec 15, 2019
1 parent
34c3793
commit 77af5e2
Showing
10 changed files
with
509 additions
and
150 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,21 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Swiss Open Access Repository | ||
# Copyright (C) 2019 RERO | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, version 3 of the License. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
|
||
"""Deposit module.""" | ||
|
||
from __future__ import absolute_import, print_function |
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,64 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Swiss Open Access Repository | ||
# Copyright (C) 2019 RERO | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, version 3 of the License. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""Deposit CLI commands.""" | ||
|
||
import shutil | ||
from os import makedirs | ||
from os.path import exists, join | ||
|
||
import click | ||
from flask import current_app | ||
from flask.cli import with_appcontext | ||
from invenio_db import db | ||
from invenio_files_rest.models import Bucket, FileInstance, Location, \ | ||
ObjectVersion | ||
|
||
|
||
@click.group() | ||
def deposits(): | ||
"""Deposits CLI commands.""" | ||
|
||
|
||
@deposits.command('create') | ||
@with_appcontext | ||
def create(): | ||
"""Create a location and a bucket for uploading files.""" | ||
click.secho('Creating default location for importing files', bold=True) | ||
|
||
# Directory where files are stored | ||
directory = join(current_app.instance_path, 'files') | ||
|
||
if exists(directory): | ||
shutil.rmtree(directory) | ||
|
||
makedirs(directory) | ||
|
||
# Remove stored data | ||
ObjectVersion.query.delete() | ||
Bucket.query.delete() | ||
FileInstance.query.delete() | ||
Location.query.delete() | ||
db.session.commit() | ||
|
||
# Create location | ||
loc = Location(name='local', uri=directory, default=True) | ||
db.session.add(loc) | ||
db.session.commit() | ||
|
||
click.secho('Location #{id} created successfully'.format(id=loc.id), | ||
fg='green') |
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