apps.py 895 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
"""
Initialization app for the LMS

This app consists solely of a ready method in its AppConfig, and should be
included early in the INSTALLED_APPS list.
"""

import analytics
from django.apps import AppConfig
from django.conf import settings


class LMSInitializationConfig(AppConfig):
    """
    Application Configuration for lms_initialization.
    """
    name = 'lms_initialization'
    verbose_name = 'LMS Initialization'

    def ready(self):
        """
        Global LMS initialization methods are called here.  This runs after
        settings have loaded, but before most other djangoapp initializations.
        """
25 26 27 28 29 30 31 32
        self._initialize_analytics()

    def _initialize_analytics(self):
        """
        Initialize Segment analytics module by setting the write_key.
        """
        if settings.LMS_SEGMENT_KEY:
            analytics.write_key = settings.LMS_SEGMENT_KEY