Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ docs/_build/

# PyBuilder
target/

# examples
examples/*.db
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ env:
- REQUIREMENTS=release
- REQUIREMENTS=devel

services:
- redis
- rabbitmq

python:
- "2.7"
- "3.3"
Expand Down
4 changes: 3 additions & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ Authors

Zenodo module for providing access request feature.

- CERN <info@zenodo.org>
- Adrian Baran Pawel <adrian.baran.pawel@cern.ch>
- Lars Holm Nielsen <lars.holm.nielsen@cern.ch>
- Leonardo Rossi <leonardo.r@cern.ch>
25 changes: 15 additions & 10 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Zenodo.
# Copyright (C) 2015 CERN.
# Copyright (C) 2015, 2016 CERN.
#
# Zenodo is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
Expand All @@ -22,15 +22,20 @@
# waive the privileges and immunities granted to it by virtue of its status
# as an Intergovernmental Organization or submit itself to any jurisdiction.


# TODO: Generate this manifest file by running the following commands:
#
# git init
# git add -A
# pip install -e .[all]
# check-manifest -u

# Check manifest will not automatically add these two files:
include *.rst
include *.sh
include *.txt
include .dockerignore
include .editorconfig
include .tx/config
include babel.ini
include LICENSE
include pytest.ini
recursive-include docs *.bat
recursive-include docs *.py
recursive-include docs *.rst
recursive-include docs Makefile
recursive-include examples *.py
recursive-include tests *.py
recursive-include zenodo_accessrequests *.html
recursive-include zenodo_accessrequests *.tpl
11 changes: 6 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Zenodo.
# Copyright (C) 2015 CERN.
# Copyright (C) 2015, 2016 CERN.
#
# Zenodo is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
Expand All @@ -27,13 +27,14 @@
import os

import sphinx.environment
from docutils.utils import get_source_line

_warn_node_old = sphinx.environment.BuildEnvironment.warn_node

def _warn_node(self, msg, node):

def _warn_node(self, msg, *args, **kwargs):
"""Do not warn on external images."""
if not msg.startswith('nonlocal image URI found:'):
self._warnfunc(msg, '%s:%s' % get_source_line(node))
_warn_node_old(self, msg, *args, **kwargs)

sphinx.environment.BuildEnvironment.warn_node = _warn_node

Expand Down Expand Up @@ -70,7 +71,7 @@ def _warn_node(self, msg, node):

# General information about the project.
project = u'Zenodo-AccessRequests'
copyright = u'2015, CERN'
copyright = u'2015, 2016 CERN'
author = u'CERN'

# The version info for the project you're documenting, acts as replacement for
Expand Down
109 changes: 104 additions & 5 deletions examples/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Zenodo.
# Copyright (C) 2015 CERN.
# Copyright (C) 2015, 2016 CERN.
#
# Zenodo is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -35,22 +35,121 @@

from __future__ import absolute_import, print_function

import os
from time import sleep

from flask import Flask
from flask_babelex import Babel
from flask_mail import Mail
from flask_menu import Menu as FlaskMenu
from invenio_access import InvenioAccess
from invenio_accounts import InvenioAccounts
from invenio_db import InvenioDB
from invenio_accounts.testutils import create_test_user
from invenio_accounts.views import blueprint as blueprint_user
from invenio_admin import InvenioAdmin
from invenio_db import InvenioDB, db
from invenio_indexer import InvenioIndexer
from invenio_indexer.api import RecordIndexer
from invenio_mail import InvenioMail as Mail
from invenio_pidstore import InvenioPIDStore
from invenio_records import InvenioRecords
from invenio_records_ui import InvenioRecordsUI
from invenio_search import InvenioSearch

from zenodo_accessrequests import ZenodoAccessRequests
from zenodo_accessrequests.views.requests import blueprint as request_blueprint
from zenodo_accessrequests.views.settings import \
blueprint as settings_blueprint

# Create Flask application
app = Flask(__name__)

app.config.update(
# DEBUG=True,
CELERY_ALWAYS_EAGER=True,
CELERY_CACHE_BACKEND="memory",
CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
CELERY_RESULT_BACKEND="cache",
MAIL_SUPPRESS_SEND=True,
TESTING=True,
SECRET_KEY='TEST',
SQLALCHEMY_DATABASE_URI=os.environ.get(
'SQLALCHEMY_DATABASE_URI', 'sqlite:///app.db'
),
SECURITY_PASSWORD_SALT='security-password-salt',
RECORDS_UI_ENDPOINTS=dict(
recid=dict(
pid_type='recid',
route='/records/<pid_value>',
template='invenio_records_ui/detail.html',
),
recid_access_request=dict(
pid_type='recid',
route='/records/<pid_value>/accessrequest',
template='zenodo_accessrequests/access_request.html',
view_imp='zenodo_accessrequests.views.requests.access_request',
methods=['GET', 'POST'],
),
recid_access_request_email_confirm=dict(
pid_type='recid',
route='/records/<pid_value>/accessrequest/<token>/confirm',
# template='invenio_records_ui/detail.html',
view_imp='zenodo_accessrequests.views.requests.confirm',
),
)
)

Babel(app)
InvenioDB(app)
InvenioAccounts(app)
InvenioRecords(app)
FlaskMenu(app)
Mail(app)
InvenioRecordsUI(app)
ZenodoAccessRequests(app)
InvenioPIDStore(app)
InvenioIndexer(app)
InvenioSearch(app)
InvenioAccess(app)
InvenioAdmin(app, permission_factory=lambda x: x,
view_class_factory=lambda x: x)

app.register_blueprint(request_blueprint)
app.register_blueprint(settings_blueprint)
app.register_blueprint(blueprint_user)


@app.cli.group()
def fixtures():
"""Command for working with test data."""


@fixtures.command()
def records():
"""Load test data fixture."""
import uuid
from invenio_records.api import Record
from invenio_pidstore.models import PersistentIdentifier, PIDStatus

create_test_user()

indexer = RecordIndexer()

# Record 1 - Live record
with db.session.begin_nested():
rec_uuid = uuid.uuid4()
pid1 = PersistentIdentifier.create(
'recid', '1', object_type='rec', object_uuid=rec_uuid,
status=PIDStatus.REGISTERED)
Record.create({
'title': 'Registered',
'description': 'This is an awesome description',
'control_number': '1',
'access_right': 'restricted',
'access_conditions': 'fuu',
'owners': [1, 2],
}, id_=rec_uuid)
indexer.index_by_id(pid1.object_uuid)

db.session.commit()

if __name__ == "__main__":
app.run()
sleep(3)
14 changes: 8 additions & 6 deletions requirements-devel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
# In applying this license, CERN does not
# waive the privileges and immunities granted to it by virtue of its status
# as an Intergovernmental Organization or submit itself to any jurisdiction.
#
# TODO: Add development versions of some important dependencies here to get a
# warning when there are breaking upstream changes, e.g.:
#
# -e git+git://github.com/mitsuhiko/werkzeug.git#egg=Werkzeug
# -e git+git://github.com/mitsuhiko/jinja2.git#egg=Jinja2

-e git+git://github.com/inveniosoftware/invenio-access.git#egg=invenio-access
-e git+git://github.com/inveniosoftware/invenio-accounts.git#egg=invenio-accounts
-e git+git://github.com/inveniosoftware/invenio-db.git#egg=invenio-db
-e git+git://github.com/inveniosoftware/invenio-files-rest.git#egg=invenio-files-rest
-e git+git://github.com/inveniosoftware/invenio-mail.git#egg=invenio-mail
-e git+git://github.com/inveniosoftware/invenio-pidstore.git#egg=invenio-pidstore
-e git+git://github.com/inveniosoftware/invenio-records.git#egg=invenio-records
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Zenodo.
# Copyright (C) 2015 CERN.
# Copyright (C) 2015, 2016 CERN.
#
# Zenodo is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
Expand All @@ -22,6 +22,8 @@
# waive the privileges and immunities granted to it by virtue of its status
# as an Intergovernmental Organization or submit itself to any jurisdiction.

[aliases]
test=pytest

[build_sphinx]
source-dir = docs/
Expand Down
Loading