Completed
Push — master ( b0fcd0...22a21c )
by Justin
01:35
created

ActstreamConfig.ready()   A

Complexity

Conditions 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

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