Completed
Pull Request — master (#388)
by
unknown
35s
created

get_verb_transformer()   A

Complexity

Conditions 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
c 0
b 0
f 0
dl 0
loc 13
rs 9.4285
1
from django.conf import settings
2
3
SETTINGS = getattr(settings, 'ACTSTREAM_SETTINGS', {})
4
5
6
def get_action_manager():
7
    """
8
    Returns the class of the action manager to use from ACTSTREAM_SETTINGS['MANAGER']
9
    """
10
    mod = SETTINGS.get('MANAGER', 'actstream.managers.ActionManager')
11
    mod_path = mod.split('.')
12
    try:
13
        return getattr(__import__('.'.join(mod_path[:-1]), {}, {},
14
                                  [mod_path[-1]]), mod_path[-1])()
15
    except ImportError:
16
        raise ImportError(
17
            'Cannot import %s try fixing ACTSTREAM_SETTINGS[MANAGER]'
18
            'setting.' % mod
19
        )
20
21
22
def get_verb_transformer():
23
    """
24
    Returns the class of the verb transformer to use from ACTSTREAM_SETTINGS['VERB_TRANSFORMER']
25
    """
26
    mod = SETTINGS.get('VERB_TRANSFORMER', 'actstream.transformers.DefaultVerbTransformer')
27
    mod_path = mod.split('.')
28
    try:
29
        return getattr(__import__('.'.join(mod_path[:-1]), {}, {},
30
                                  [mod_path[-1]]), mod_path[-1])()
31
    except ImportError:
32
        raise ImportError(
33
            'Cannot import %s try fixing ACTSTREAM_SETTINGS[VERB_TRANSFORMER]'
34
            'setting.' % mod
35
        )
36
37
38
FETCH_RELATIONS = SETTINGS.get('FETCH_RELATIONS', True)
39
40
USE_JSONFIELD = SETTINGS.get('USE_JSONFIELD', False)
41