Skip to content

Commit

Permalink
examples: fix access to admin page
Browse files Browse the repository at this point in the history
* Fixes access to admin page. (closes #81)

Signed-off-by: Leonardo Rossi <leonardo.r@cern.ch>
  • Loading branch information
Leonardo Rossi committed Aug 1, 2017
1 parent 7fba823 commit 192c02f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
6 changes: 6 additions & 0 deletions examples/app-fixtures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ export FLASK_APP=app.py
# Create the users
flask users create -a info@inveniosoftware.org --password 123456
flask users create -a another@inveniosoftware.org --password 123456

# give to 'info' user the access to the admin page
flask roles create admin
flask roles add info@inveniosoftware.org admin
flask access allow admin-access role admin

22 changes: 19 additions & 3 deletions examples/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@
$ open http://127.0.0.1:5000/
Choose a user to login:
- user info@inveniosoftware.org password 123456
- user another@inveniosoftware.org password 123456
You can check the administration page opening the page:
$ open http://127.0.0.1:5000/admin
Note that, as defined in our fixtures, only `info@inveniosoftware.org` user
can enter.
To uninstall and purge the example app, run:
.. code-block:: console
Expand All @@ -69,9 +81,11 @@
import pkg_resources
from flask import Flask, redirect, url_for
from flask_babelex import Babel
from invenio_access import InvenioAccess
from invenio_accounts import InvenioAccounts
from invenio_accounts.views import blueprint
from invenio_admin import InvenioAdmin
from invenio_admin.views import blueprint as blueprint_admin_ui
from invenio_db import InvenioDB
from invenio_i18n import InvenioI18N
from invenio_mail import InvenioMail
Expand Down Expand Up @@ -100,7 +114,7 @@
app = Flask(__name__)
app.config.update(
ACCOUNTS_USE_CELERY=False,
BABEL_DEFAULT_LOCALE='da',
BABEL_DEFAULT_LOCALE='en',
I18N_TRASNLATION_PATHS=[messages_path()],
MAIL_SUPPRESS_SEND=True,
SECRET_KEY='CHANGE_ME',
Expand All @@ -118,14 +132,16 @@
InvenioAssets(app)
if INVENIO_THEME_AVAILABLE:
InvenioTheme(app)
InvenioAccess(app)
InvenioAccounts(app)
app.register_blueprint(blueprint)
InvenioUserProfiles(app)
app.register_blueprint(blueprint2)
app.register_blueprint(blueprint_api_init)
app.register_blueprint(blueprint_ui_init)
InvenioAdmin(app, permission_factory=lambda x: x,
view_class_factory=lambda x: x)

InvenioAdmin(app)
app.register_blueprint(blueprint_admin_ui)


@app.route('/')
Expand Down
7 changes: 4 additions & 3 deletions examples/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# waive the privileges and immunities granted to it by virtue of its status
# as an Intergovernmental Organization or submit itself to any jurisdiction.

invenio-assets
invenio-theme
invenio-mail
invenio-access>=1.0.0a12
invenio-assets>=1.0.0b6
invenio-theme>=1.0.0b2
invenio-mail>=1.0.0b1

0 comments on commit 192c02f

Please sign in to comment.