M src/wiki/plugins/images/apps.py => src/wiki/plugins/images/apps.py +6 -0
@@ 1,8 1,14 @@
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
+from django.core.checks import register
+
+from . import checks
class ImagesConfig(AppConfig):
name = 'wiki.plugins.images'
verbose_name = _("Wiki images")
label = 'wiki_images'
+
+ def ready(self):
+ register(checks.check_for_required_installed_apps, checks.Tags.required_installed_apps)
A src/wiki/plugins/images/checks.py => src/wiki/plugins/images/checks.py +13 -0
@@ 0,0 1,13 @@
+from django.apps import apps
+from django.core.checks import Error
+
+
+class Tags:
+ required_installed_apps = "required_installed_apps"
+
+
+def check_for_required_installed_apps(app_configs, **kwargs):
+ errors = []
+ if not apps.is_installed("sorl.thumbnail"):
+ errors.append(Error('needs sorl.thumbnail in INSTALLED_APPS', id='wiki_images.E001'))
+ return errors
M src/wiki/plugins/images/models.py => src/wiki/plugins/images/models.py +0 -6
@@ 1,8 1,6 @@
import os.path
-from django.apps import apps
from django.conf import settings as django_settings
-from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.db.models import signals
from django.utils.translation import gettext, gettext_lazy as _
@@ 10,10 8,6 @@ from wiki.models.pluginbase import RevisionPlugin, RevisionPluginRevision
from . import settings
-if not apps.is_installed("sorl.thumbnail"):
- raise ImproperlyConfigured(
- 'wiki.plugins.images: needs sorl.thumbnail in INSTALLED_APPS')
-
def upload_path(instance, filename):
# Has to match original extension filename