From 31944ac3461e6c57499bc075fee1b86760cd7d21 Mon Sep 17 00:00:00 2001 From: Elias Showk Date: Fri, 25 May 2018 15:14:10 +0200 Subject: [PATCH] removed django-admin-tools (#22626) --- debian-jessie/control | 1 - debian-wheezy/control | 1 - doc/installation_modes.rst | 1 - .../authentic2_plugin_template/__init__.py | 8 +- .../authentic2_plugin_template/dashboard.py | 11 -- setup.py | 1 - .../migrations/0002_auto_20150410_1823.py | 9 -- src/authentic2/dashboard.py | 130 ------------------ .../dashboard_migrations/0001_initial.py | 33 ----- src/authentic2/idp/saml/__init__.py | 11 -- src/authentic2/menu.py | 30 ---- .../menu_migrations/0001_initial.py | 29 ---- src/authentic2/settings.py | 4 - src/authentic2/urls.py | 1 - src/authentic2_auth_oidc/__init__.py | 9 -- src/authentic2_idp_cas/__init__.py | 11 +- src/authentic2_idp_oidc/__init__.py | 11 +- 17 files changed, 4 insertions(+), 297 deletions(-) delete mode 100644 samples/authentic2-plugin-template/src/authentic2_plugin_template/dashboard.py delete mode 100644 src/authentic2/dashboard.py delete mode 100644 src/authentic2/dashboard_migrations/0001_initial.py delete mode 100644 src/authentic2/menu.py delete mode 100644 src/authentic2/menu_migrations/0001_initial.py diff --git a/debian-jessie/control b/debian-jessie/control index 8586de69..1a419007 100644 --- a/debian-jessie/control +++ b/debian-jessie/control @@ -14,7 +14,6 @@ Pre-Depends: python-django (>= 1.8), python-django (<< 1.9), openssl Depends: ${misc:Depends}, ${python:Depends}, python-requests (>=2.3), python-django-model-utils (>= 2.4), - python-django-admin-tools (>= 0.5.2), python-lasso (>= 2.4.1.100), python-dnspython (>= 1.10), python-django-select2 (>= 5), diff --git a/debian-wheezy/control b/debian-wheezy/control index 4a09b757..b8039228 100644 --- a/debian-wheezy/control +++ b/debian-wheezy/control @@ -14,7 +14,6 @@ Pre-Depends: python-django (>= 1.8), python-django (<< 1.8), openssl Depends: ${misc:Depends}, ${python:Depends}, python-requests (>=2.3), python-django-model-utils (>= 2.4), - python-django-admin-tools (>= 0.5.2), python-lasso (>= 2.4.1.100), python-dnspython (>= 1.10), python-django-select2 (>= 5), diff --git a/doc/installation_modes.rst b/doc/installation_modes.rst index 9db4a2e3..759cb0af 100644 --- a/doc/installation_modes.rst +++ b/doc/installation_modes.rst @@ -17,7 +17,6 @@ The other Authentic 2 dependencies are: - Django>=1.7.6,<1.9 - requests>=2. - django-model-utils>=2 -- django-admin-tools>=0.5.2 - dnspython>=1.12 - django-select2>=4.3.0 - django-tables2>=1.0 diff --git a/samples/authentic2-plugin-template/src/authentic2_plugin_template/__init__.py b/samples/authentic2-plugin-template/src/authentic2_plugin_template/__init__.py index 3de27b71..42da0917 100644 --- a/samples/authentic2-plugin-template/src/authentic2_plugin_template/__init__.py +++ b/samples/authentic2-plugin-template/src/authentic2_plugin_template/__init__.py @@ -26,13 +26,9 @@ class Plugin(object): def get_idp_backends(self): return [] - def get_admin_modules(self): - from . import dashboard - return dashboard.get_admin_modules() - def service_list(self, request): '''For IdP plugins this method add links to the user homepage. - + It must return a list of authentic2.utils.Service objects, each object has a name and can have an url and some actions. @@ -49,7 +45,7 @@ class Plugin(object): def logout_list(self, request): '''For IdP or SP plugins this method add actions to logout from remote IdP or SP. - + It must returns a list of HTML fragments, each fragment is responsible for calling the view doing the logout. Views are usually called using or tags and finally redirect to an diff --git a/samples/authentic2-plugin-template/src/authentic2_plugin_template/dashboard.py b/samples/authentic2-plugin-template/src/authentic2_plugin_template/dashboard.py deleted file mode 100644 index 48882ba9..00000000 --- a/samples/authentic2-plugin-template/src/authentic2_plugin_template/dashboard.py +++ /dev/null @@ -1,11 +0,0 @@ -from django.utils.translation import ugettext_lazy as _ - -from admin_tools.dashboard import modules - - -def get_admin_modules(): - '''Show Client model in authentic2 admin''' - model_list = modules.ModelList(_('Authentic2 Plugin Template'), - models=('authentic2_plugin_template.models.*',)) - return (model_list,) - diff --git a/setup.py b/setup.py index 3d882584..8af4679f 100755 --- a/setup.py +++ b/setup.py @@ -112,7 +112,6 @@ setup(name="authentic2", 'django>=1.8,<1.9', 'requests>=2.3', 'django-model-utils>=2.4', - 'django-admin-tools>=0.6,<0.7', 'dnspython>=1.10', 'Django-Select2>5,<6', 'django-tables2>=1.0,<1.1', diff --git a/src/authentic2/custom_user/migrations/0002_auto_20150410_1823.py b/src/authentic2/custom_user/migrations/0002_auto_20150410_1823.py index 1f88f9ab..14337df8 100644 --- a/src/authentic2/custom_user/migrations/0002_auto_20150410_1823.py +++ b/src/authentic2/custom_user/migrations/0002_auto_20150410_1823.py @@ -38,7 +38,6 @@ class ThirdPartyAlterField(migrations.AlterField): class Migration(migrations.Migration): dependencies = [ ('custom_user', '0001_initial'), - ('menu', '__first__'), ('admin', '__first__'), ] @@ -55,12 +54,4 @@ class Migration(migrations.Migration): field=models.ForeignKey(to=settings.AUTH_USER_MODEL), preserve_default=True ), - # Django admin-tools menu bookmark - ThirdPartyAlterField( - app_label='menu', - model_name='bookmark', - name='user', - field=models.ForeignKey(to=settings.AUTH_USER_MODEL), - preserve_default=True - ), ] diff --git a/src/authentic2/dashboard.py b/src/authentic2/dashboard.py deleted file mode 100644 index 947e2079..00000000 --- a/src/authentic2/dashboard.py +++ /dev/null @@ -1,130 +0,0 @@ -""" -This file was generated with the customdashboard management command, it -contains the two classes for the main dashboard and app index dashboard. -You can customize these classes as you want. - -To activate your index dashboard add the following to your settings.py:: - ADMIN_TOOLS_INDEX_DASHBOARD = 'authentic2.dashboard.CustomIndexDashboard' - -And to activate the app index dashboard:: - ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'authentic2.dashboard.CustomAppIndexDashboard' -""" - -from django.conf import settings -from django.utils.translation import ugettext_lazy as _ -from django.core.urlresolvers import reverse - -from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard -from admin_tools.utils import get_admin_site_name - -from . import plugins, compat - -class CustomIndexDashboard(Dashboard): - """ - Custom index dashboard for authentic2. - """ - def init_with_context(self, context): - site_name = get_admin_site_name(context) - # append a link list module for "quick links" - self.children.append(modules.LinkList( - _('Quick links'), - layout='inline', - draggable=False, - deletable=False, - collapsible=False, - children=[ - [_('Return to site'), '/'], - [_('Change password'), - reverse('%s:password_change' % site_name)], - [_('Log out'), reverse('%s:logout' % site_name)], - ] - )) - - # append an app list module for "Applications" - User = compat.get_user_model() - user_class = '{0}.{1}'.format(User.__module__, User.__name__) - self.children.append(modules.ModelList( - _('Users and groups'), - models=(user_class, - 'django.contrib.auth.models.*', - 'authentic2.models.Attribute', - 'authentic2.models.PasswordReset'), - )) - self.children.append(modules.ModelList( - _('Access control'), - models=('authentic2.a2_rbac.models.OrganizationalUnit', - 'authentic2.a2_rbac.models.Role', - 'authentic2.a2_rbac.models.Permission', - 'authentic2.models.ServiceRole', - ), - )) - self.children.append(modules.ModelList( - _('Debug'), - models=( - 'authentic2.models.AttributeValue', - 'authentic2.nonce.models.Nonce', - 'authentic2.models.LogoutUrl', - 'authentic2.models.AuthenticationEvent', - 'authentic2.models.UserExternalId', - 'authentic2.models.DeletedUser', - 'django.contrib.sessions.*', - ), - )) - for plugin in plugins.get_plugins(): - if hasattr(plugin, 'get_admin_modules') and callable(plugin.get_admin_modules): - plugin_modules = plugin.get_admin_modules() - for module in plugin_modules: - self.children.append(module) - - # append a recent actions module - self.children.append(modules.RecentActions(_('Recent Actions'), 5)) - - # append another link list module for "support". - self.children.append(modules.LinkList( - _('Support'), - children=[ - { - 'title': _('Authentic2 documentation'), - 'url': 'http://pythonhosted.org/authentic2/', - 'external': True, - }, - { - 'title': _('Authentic2 project'), - 'url': 'http://dev.entrouvert.org/projects/authentic/', - 'external': True, - }, - { - 'title': _('Authentic Mailing List'), - 'url': 'http://listes.entrouvert.com/info/authentic', - 'external': True, - }, - ] - )) - - -class CustomAppIndexDashboard(AppIndexDashboard): - """ - Custom app index dashboard for authentic2. - """ - - # we disable title because its redundant with the model list module - title = '' - - def __init__(self, *args, **kwargs): - AppIndexDashboard.__init__(self, *args, **kwargs) - - # append a model list module and a recent actions module - self.children += [ - modules.ModelList(self.app_title, self.models), - modules.RecentActions( - _('Recent Actions'), - include_list=self.get_app_content_types(), - limit=5 - ) - ] - - def init_with_context(self, context): - """ - Use this method if you need to access the request context. - """ - return super(CustomAppIndexDashboard, self).init_with_context(context) diff --git a/src/authentic2/dashboard_migrations/0001_initial.py b/src/authentic2/dashboard_migrations/0001_initial.py deleted file mode 100644 index 97fad07e..00000000 --- a/src/authentic2/dashboard_migrations/0001_initial.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import models, migrations -from django.conf import settings - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.CreateModel( - name='DashboardPreferences', - fields=[ - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), - ('data', models.TextField()), - ('dashboard_id', models.CharField(max_length=100)), - ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)), - ], - options={ - 'ordering': ('user',), - 'db_table': 'admin_tools_dashboard_preferences', - }, - bases=(models.Model,), - ), - migrations.AlterUniqueTogether( - name='dashboardpreferences', - unique_together=set([('user', 'dashboard_id')]), - ), - ] diff --git a/src/authentic2/idp/saml/__init__.py b/src/authentic2/idp/saml/__init__.py index e7f3c1a4..f921dc79 100644 --- a/src/authentic2/idp/saml/__init__.py +++ b/src/authentic2/idp/saml/__init__.py @@ -22,17 +22,6 @@ class Plugin(object): def get_apps(self): return ['authentic2.idp.saml'] - def get_admin_modules(self): - from admin_tools.dashboard import modules - return [modules.ModelList( - _('SAML2'), - models=( - 'authentic2.saml.models.LibertyProvider', - 'authentic2.saml.models.SPOptionsIdPPolicy', - 'authentic2.saml.models.IdPOptionsSPPolicy', - ), - )] - def get_idp_backends(self): return ['authentic2.idp.saml.backend.SamlBackend'] diff --git a/src/authentic2/menu.py b/src/authentic2/menu.py deleted file mode 100644 index 50293d25..00000000 --- a/src/authentic2/menu.py +++ /dev/null @@ -1,30 +0,0 @@ -""" -This file was generated with the custommenu management command, it contains -the classes for the admin menu, you can customize this class as you want. - -To activate your custom menu add the following to your settings.py:: - ADMIN_TOOLS_MENU = 'authentic2.menu.CustomMenu' -""" - -from django.core.urlresolvers import reverse -from django.utils.translation import ugettext_lazy as _ - -from admin_tools.menu import items, Menu - - -class CustomMenu(Menu): - """ - Custom Menu for authentic2 admin site. - """ - def __init__(self, **kwargs): - Menu.__init__(self, **kwargs) - self.children += [ - items.MenuItem(_('Dashboard'), reverse('admin:index')), - items.Bookmarks(), - ] - - def init_with_context(self, context): - """ - Use this method if you need to access the request context. - """ - return super(CustomMenu, self).init_with_context(context) diff --git a/src/authentic2/menu_migrations/0001_initial.py b/src/authentic2/menu_migrations/0001_initial.py deleted file mode 100644 index bf81750e..00000000 --- a/src/authentic2/menu_migrations/0001_initial.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import models, migrations -from django.conf import settings - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.CreateModel( - name='Bookmark', - fields=[ - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), - ('url', models.CharField(max_length=255)), - ('title', models.CharField(max_length=255)), - ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)), - ], - options={ - 'ordering': ('id',), - 'db_table': 'admin_tools_menu_bookmark', - }, - bases=(models.Model,), - ), - ] diff --git a/src/authentic2/settings.py b/src/authentic2/settings.py index e2ae5569..18e286b8 100644 --- a/src/authentic2/settings.py +++ b/src/authentic2/settings.py @@ -113,10 +113,6 @@ INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.sessions', 'django.contrib.messages', - 'admin_tools', - 'admin_tools.theming', - 'admin_tools.menu', - 'admin_tools.dashboard', 'django.contrib.admin', 'django_select2', 'django_tables2', diff --git a/src/authentic2/urls.py b/src/authentic2/urls.py index 7e041bfe..35b13139 100644 --- a/src/authentic2/urls.py +++ b/src/authentic2/urls.py @@ -24,7 +24,6 @@ not_homepage_patterns = [ not_homepage_patterns += [ url(r'^accounts/', include(app_settings.A2_REGISTRATION_URLCONF)), url(r'^admin/', include(admin.site.urls)), - url(r'^admin_tools/', include('admin_tools.urls')), url(r'^idp/', include('authentic2.idp.urls')), url(r'^manage/', include('authentic2.manager.urls')), url(r'^api/', include('authentic2.api_urls')) diff --git a/src/authentic2_auth_oidc/__init__.py b/src/authentic2_auth_oidc/__init__.py index 3cfd199e..cfafe280 100644 --- a/src/authentic2_auth_oidc/__init__.py +++ b/src/authentic2_auth_oidc/__init__.py @@ -66,12 +66,3 @@ class Plugin(object): return logger.info(u'revoked token from OIDC provider %s', provider.issuer) - def get_admin_modules(self): - from admin_tools.dashboard import modules - return [modules.ModelList( - _('OpenID Connect authentication'), - models=( - 'authentic2_auth_oidc.models.OIDCProvider', - 'authentic2_auth_oidc.models.OIDCAccount', - ), - )] diff --git a/src/authentic2_idp_cas/__init__.py b/src/authentic2_idp_cas/__init__.py index aa7896e7..0993f16f 100644 --- a/src/authentic2_idp_cas/__init__.py +++ b/src/authentic2_idp_cas/__init__.py @@ -30,13 +30,4 @@ class Plugin(object): } content = render_to_string('authentic2_idp_cas/logout_fragment.html', ctx) fragments.append(content) - return fragments - - def get_admin_modules(self): - from admin_tools.dashboard import modules - return [modules.ModelList( - _('CAS'), - models=( - '%s.*' % __name__, - ), - )] + return fragments \ No newline at end of file diff --git a/src/authentic2_idp_oidc/__init__.py b/src/authentic2_idp_oidc/__init__.py index 1f04c368..337b6f60 100644 --- a/src/authentic2_idp_oidc/__init__.py +++ b/src/authentic2_idp_oidc/__init__.py @@ -31,13 +31,4 @@ class Plugin(object): render_to_string( 'authentic2_idp_oidc/logout_fragment.html', ctx)) - return fragments - - def get_admin_modules(self): - from admin_tools.dashboard import modules - return [modules.ModelList( - _('OpenID Connect authentication'), - models=( - 'authentic2_idp_oidc.models.*', - ), - )] + return fragments \ No newline at end of file -- 2.18.0