From 87585964f563215a26097ef994aba4274f96b5f9 Mon Sep 17 00:00:00 2001 From: Emmanuel Cazenave Date: Thu, 10 Sep 2020 17:23:29 +0200 Subject: [PATCH] do not rely on pkg_resources (#46549) --- README | 6 +++++- check-migrations.sh | 2 ++ setup.py | 5 ----- src/authentic2_cut/__init__.py | 19 ------------------- src/authentic2_cut/apps.py | 10 ++++++++++ tests/settings.py | 6 ++++++ 6 files changed, 23 insertions(+), 25 deletions(-) diff --git a/README b/README index bebc35f..865b2dd 100644 --- a/README +++ b/README @@ -33,7 +33,11 @@ the git hook.) Settings ======== -Nothing to say here. +Register the plugin in your settings file. + + INSTALLED_APPS += ('sorl.thumbnail', 'authentic2_cut',) + TENANT_APPS += ('sorl.thumbnail', 'authentic2_cut',) + MIDDLEWARE += ('authentic2_cut.middlewares.CUTMiddleware',) License ------- diff --git a/check-migrations.sh b/check-migrations.sh index ea0e143..1179390 100755 --- a/check-migrations.sh +++ b/check-migrations.sh @@ -12,6 +12,8 @@ DATABASES = { 'ENGINE': 'django.db.backends.dummy', } } +INSTALLED_APPS += ('authentic2_cut',) +MIDDLEWARE += ('authentic2_cut.middlewares.CUTMiddleware',) EOF TEMPFILE=`mktemp` trap "rm -f ${TEMPFILE} ${CHECK_MIGRATIONS_SETTINGS}" EXIT diff --git a/setup.py b/setup.py index 9ba96b2..9e874ca 100755 --- a/setup.py +++ b/setup.py @@ -110,11 +110,6 @@ setup( 'Pillow', 'sorl-thumbnail', ], - entry_points={ - 'authentic2.plugin': [ - 'authentic2-cut = authentic2_cut:Plugin', - ], - }, cmdclass={ 'build': build, 'install_lib': install_lib, diff --git a/src/authentic2_cut/__init__.py b/src/authentic2_cut/__init__.py index 899702a..d807690 100644 --- a/src/authentic2_cut/__init__.py +++ b/src/authentic2_cut/__init__.py @@ -16,22 +16,3 @@ # along with this program. If not, see . default_app_config = 'authentic2_cut.apps.AppConfig' - - -class Plugin: - def get_before_urls(self): - from . import urls - - return urls.urlpatterns - - def get_apps(self): - return ['sorl.thumbnail', __name__] - - def get_authentication_backends(self): - return [] - - def get_auth_frontends(self): - return [] - - def get_after_middleware(self): - return ['authentic2_cut.middlewares.CUTMiddleware'] diff --git a/src/authentic2_cut/apps.py b/src/authentic2_cut/apps.py index d88d34a..aa9c6bf 100644 --- a/src/authentic2_cut/apps.py +++ b/src/authentic2_cut/apps.py @@ -790,3 +790,13 @@ class AppConfig(django.apps.AppConfig): 'href': reverse_lazy('cut-manager-user-validation'), 'class': 'icon-management', } + + def get_a2_plugin(self): + return Plugin() + + +class Plugin: + def get_before_urls(self): + from . import urls + + return urls.urlpatterns diff --git a/tests/settings.py b/tests/settings.py index 3ffb3e4..a50712d 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -20,3 +20,9 @@ A2_FC_CLIENT_SECRET = '' # test hook handlers A2_HOOKS_PROPAGATE_EXCEPTIONS = True + +INSTALLED_APPS += ( + 'sorl.thumbnail', + 'authentic2_cut', +) +MIDDLEWARE += ('authentic2_cut.middlewares.CUTMiddleware',)