Completed
Pull Request — master (#309)
by Steve
01:16
created

get_action_model()   A

Complexity

Conditions 3

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 3
1
try:
2
    from actstream.settings import ACTSTREAM_ACTION_MODEL, ACTSTREAM_FOLLOW_MODEL
3
    from actstream.signals import action
4
    from django.apps import apps as django_apps
5
except:
6
    pass
7
8
9
__version__ = '0.6.3'
10
__author__ = 'Justin Quick <[email protected]>'
11
default_app_config = 'actstream.apps.ActstreamConfig'
12
13
14
def get_action_model():
15
    """
16
    Returns the Action model that is active in this project.
17
    """
18
    try:
19
        return django_apps.get_model(ACTSTREAM_ACTION_MODEL)
20
    except ValueError:
21
        raise ImproperlyConfigured("ACTSTREAM_ACTION_MODEL must be of the form 'app_label.model_name'")
22
    except LookupError:
23
        raise ImproperlyConfigured(
24
            "ACTSTREAM_ACTION_MODEL refers to model '%s' that has not been installed" % ACTSTREAM_ACTION_MODEL
25
        )
26
27
28
def get_follow_model():
29
    """
30
    Returns the Follow model that is active in this project.
31
    """
32
    try:
33
        return django_apps.get_model(ACTSTREAM_FOLLOW_MODEL)
34
    except ValueError:
35
        raise ImproperlyConfigured("ACTSTREAM_FOLLOW_MODEL must be of the form 'app_label.model_name'")
36
    except LookupError:
37
        raise ImproperlyConfigured(
38
            "ACTSTREAM_FOLLOW_MODEL refers to model '%s' that has not been installed" % ACTSTREAM_FOLLOW_MODEL
39
        )
40