diff --git a/invenio_oaiserver/admin.py b/invenio_oaiserver/admin.py deleted file mode 100644 index 25b7378..0000000 --- a/invenio_oaiserver/admin.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of Invenio. -# Copyright (C) 2015-2018 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. - -"""Admin model views for OAI sets.""" - -from flask_admin.contrib.sqla import ModelView - -from .models import OAISet - - -def _(x): - """Identity.""" - return x - - -class OAISetModelView(ModelView): - """OAISets model view.""" - - can_create = True - can_edit = True - can_delete = False - can_view_details = True - column_list = ( - "id", - "spec", - "name", - "updated", - "created", - ) - column_details_list = ( - "id", - "spec", - "name", - "description", - "search_pattern", - "updated", - "created", - ) - column_filters = ("name", "created", "updated") - column_default_sort = ("updated", True) - column_searchable_list = ["spec", "name", "description"] - page_size = 25 - - def edit_form(self, obj): - """Customize edit form.""" - form = super(OAISetModelView, self).edit_form(obj) - del form.spec - return form - - -set_adminview = dict( - modelview=OAISetModelView, - model=OAISet, - category=_("OAI-PMH"), - name=_("Sets"), -) diff --git a/setup.cfg b/setup.cfg index 534bdc6..fca88d9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -43,7 +43,6 @@ tests = invenio-jsonschemas>=1.1.3,<2.0.0 mock>=1.3.0 pytest-invenio>=2.1.0,<3.0.0 - invenio-admin>=1.3.0,<2.0.0 invenio-celery>=1.2.5,<2.0.0 Sphinx>=4.5.0 invenio-db[mysql,postgresql,versioning]>=1.0.9,<2.0.0 @@ -65,8 +64,6 @@ invenio_db.alembic = invenio_oaiserver = invenio_oaiserver:alembic invenio_db.models = invenio_oaiserver = invenio_oaiserver.models -invenio_admin.views = - invenio_oaiserver = invenio_oaiserver.admin:set_adminview invenio_jsonschemas.schemas = oaiserver = invenio_oaiserver.schemas invenio_pidstore.minters = diff --git a/tests/test_admin.py b/tests/test_admin.py deleted file mode 100644 index ba783fb..0000000 --- a/tests/test_admin.py +++ /dev/null @@ -1,72 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of Invenio. -# Copyright (C) 2016-2018 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. - -"""Test admin interface.""" - -from flask import url_for -from flask_admin import Admin, menu -from invenio_db import db - -from invenio_oaiserver.admin import set_adminview -from invenio_oaiserver.models import OAISet - - -def test_admin(app): - """Test Flask-Admin interace.""" - admin = Admin(app, name="Test") - - assert "model" in set_adminview - assert "modelview" in set_adminview - - # Register both models in admin - model = set_adminview.pop("model") - view = set_adminview.pop("modelview") - admin.add_view(view(model, db.session, **set_adminview)) - - # Check if generated admin menu contains the correct items - menu_items = {str(item.name): item for item in admin.menu()} - assert "OAI-PMH" in menu_items - assert menu_items["OAI-PMH"].is_category() - - submenu_items = { - str(item.name): item for item in menu_items["OAI-PMH"].get_children() - } - assert "Sets" in submenu_items - assert isinstance(submenu_items["Sets"], menu.MenuView) - - # Create a test set. - with app.app_context(): - test_set = OAISet( - id=1, - spec="test", - name="test_name", - description="some test description", - search_pattern="title_statement.title:Test0", - system_created=False, - ) - db.session.add(test_set) - db.session.commit() - - with app.test_request_context(): - index_view_url = url_for("oaiset.index_view") - delete_view_url = url_for("oaiset.delete_view") - detail_view_url = url_for("oaiset.details_view", id=1) - - with app.test_client() as client: - # List index view and check record is there. - res = client.get(index_view_url) - assert res.status_code == 200 - - # Deletion is forbiden. - res = client.post(delete_view_url, data={"id": 1}, follow_redirects=True) - assert res.status_code == 200 - - # View the deleted record. - res = client.get(detail_view_url) - assert res.status_code == 200 - assert 1 == OAISet.query.count()