Completed
Pull Request — master (#300)
by
unknown
01:12
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
3
from actstream import settings
4
from actstream.compat_apps import AppConfig
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.fields import JSONField
19
            except ImportError:
20
                raise ImproperlyConfigured('You must have django-jsonfield installed '
21
                                           'if you wish to use a JSONField on your actions')
22
            JSONField(blank=True, null=True).contribute_to_class(action_class, 'data')
23