diff --git a/admin_interface/settings.py b/admin_interface/settings.py index 91bc12a..d4ac7f1 100644 --- a/admin_interface/settings.py +++ b/admin_interface/settings.py @@ -5,33 +5,27 @@ from django.conf import settings from django.core.exceptions import ImproperlyConfigured +def check_installed_app(app, app_dj_version_limit): + dj_version = django.VERSION + installed_apps = settings.INSTALLED_APPS + if dj_version < app_dj_version_limit: + if app not in installed_apps: + raise ImproperlyConfigured( + '\'{}\' needed before django {}.{}, ' + 'add it to settings.INSTALLED_APPS.'.format( + app, *app_dj_version_limit)) + else: + if app in installed_apps: + raise ImproperlyConfigured( + '\'{}\' not needed since django {}.{}, ' + 'remove it from settings.INSTALLED_APPS.'.format( + app, *app_dj_version_limit)) + + def check_installed_apps(): dj_version = django.VERSION installed_apps = settings.INSTALLED_APPS - if 'colorfield' not in installed_apps: - raise ImproperlyConfigured( - '\'colorfield\' needed, ' - 'add it to settings.INSTALLED_APPS.') - - if dj_version < (1, 9): - if 'flat' not in installed_apps: - raise ImproperlyConfigured( - '\'flat\' needed before django 1.9, ' - 'add it to settings.INSTALLED_APPS.') - else: - if 'flat' in installed_apps: - raise ImproperlyConfigured( - '\'flat\' not needed since django 1.9, ' - 'remove it from settings.INSTALLED_APPS.') - - if dj_version < (2, 0): - if 'flat_responsive' not in installed_apps: - raise ImproperlyConfigured( - '\'flat_responsive\' needed before django 2.0, ' - 'add it to settings.INSTALLED_APPS.') - else: - if 'flat_responsive' in installed_apps: - raise ImproperlyConfigured( - '\'flat_responsive\' not needed since django 2.0, ' - 'remove it from settings.INSTALLED_APPS.') + check_installed_app('colorfield', (4, 0)) + check_installed_app('flat', (1, 9)) + check_installed_app('flat_responsive', (2, 0))