File: apps.py

package info (click to toggle)
django-webpack-loader 0.6.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 196 kB
  • sloc: python: 256; makefile: 3
file content (29 lines) | stat: -rw-r--r-- 744 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from django.apps import AppConfig

from .errors import BAD_CONFIG_ERROR


def webpack_cfg_check(*args, **kwargs):
    '''Test if config is compatible or not'''
    from django.conf import settings

    check_failed = False
    user_config = getattr(settings, 'WEBPACK_LOADER', {})
    try:
        user_config = [dict({}, **cfg) for cfg in user_config.values()]
    except TypeError:
        check_failed = True

    errors = []
    if check_failed:
        errors.append(BAD_CONFIG_ERROR)
    return errors


class WebpackLoaderConfig(AppConfig):
    name = 'webpack_loader'
    verbose_name = "Webpack Loader"

    def ready(self):
        from django.core.checks import register, Tags
        register(Tags.compatibility)(webpack_cfg_check)