Improved code quality.

pull/78/head
Fabio Caccamo 2020-02-07 15:16:36 +01:00
parent dc43ff1b0a
commit d689ba43af
1 changed files with 20 additions and 26 deletions

View File

@ -5,33 +5,27 @@ from django.conf import settings
from django.core.exceptions import ImproperlyConfigured 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(): def check_installed_apps():
dj_version = django.VERSION dj_version = django.VERSION
installed_apps = settings.INSTALLED_APPS installed_apps = settings.INSTALLED_APPS
if 'colorfield' not in installed_apps: check_installed_app('colorfield', (4, 0))
raise ImproperlyConfigured( check_installed_app('flat', (1, 9))
'\'colorfield\' needed, ' check_installed_app('flat_responsive', (2, 0))
'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.')