core.py 1.1 KB
Newer Older
David Baumgold committed
1 2 3 4
"""
Core logic for Comprehensive Theming.
"""
from django.conf import settings
5
from path import Path as path
David Baumgold committed
6

7
from .helpers import get_themes
David Baumgold committed
8

9 10
from logging import getLogger
logger = getLogger(__name__)  # pylint: disable=invalid-name
David Baumgold committed
11 12


13
def enable_theming():
David Baumgold committed
14
    """
15
    Add directories and relevant paths to settings for comprehensive theming.
David Baumgold committed
16
    """
17 18 19 20 21 22 23 24 25 26
    # Deprecated Warnings
    if hasattr(settings, "COMPREHENSIVE_THEME_DIR"):
        logger.warning(
            "\033[93m \nDeprecated: "
            "\n\tCOMPREHENSIVE_THEME_DIR setting has been deprecated in favor of COMPREHENSIVE_THEME_DIRS.\033[00m"
        )

    for theme in get_themes():
        if theme.themes_base_dir not in settings.MAKO_TEMPLATES['main']:
            settings.MAKO_TEMPLATES['main'].insert(0, theme.themes_base_dir)
27 28 29 30 31 32 33 34 35 36 37

    _add_theming_locales()


def _add_theming_locales():
    """
    Add locale paths to settings for comprehensive theming.
    """
    theme_locale_paths = settings.COMPREHENSIVE_THEME_LOCALE_PATHS
    for locale_path in theme_locale_paths:
        settings.LOCALE_PATHS += (path(locale_path), )  # pylint: disable=no-member