ActstreamConfig.ready()   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 1 Features 0
Metric Value
cc 3
c 5
b 1
f 0
dl 0
loc 15
rs 9.65
1
from django.apps import AppConfig
2
from django.core.exceptions import ImproperlyConfigured
3
4
from actstream import settings
5
from actstream.signals import action
6
7
8
class ActstreamConfig(AppConfig):
9
    name = 'actstream'
10
11
    def ready(self):
12
        from actstream.actions import action_handler
13
        action.connect(action_handler, dispatch_uid='actstream.models')
14
        action_class = self.get_model('action')
15
16
        if settings.USE_JSONFIELD:
17
            try:
18
                from jsonfield_compat import JSONField, register_app
19
            except ImportError:
20
                raise ImproperlyConfigured(
21
                    'You must have django-jsonfield and django-jsonfield-compat '
22
                    'installed if you wish to use a JSONField on your actions'
23
                )
24
            JSONField(blank=True, null=True).contribute_to_class(action_class, 'data')
25
            register_app(self)
26