Completed
Pull Request — master (#300)
by
unknown
01:12
created

ActstreamConfig   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
dl 0
loc 15
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A ready() 0 12 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