<commit_before>"""
Custom dashboard for ECMS.

To activate the index dashboard add the following to your settings.py::
    ADMIN_TOOLS_INDEX_DASHBOARD = 'ecms_dashboard.dashboard.CustomIndexDashboard'

And to activate the app index dashboard::
    ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'ecms_dashboard.dashboard.CustomAppIndexDashboard'
"""

from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse

from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard
from admin_tools.utils import get_admin_site_name  # needs 0.4.0

from ecms_dashboard.modules import EcmsAppIconList


ADMINISTRATION_APPS = ('django.contrib.*', 'registration.*',)


class EcmsIndexDashboard(Dashboard):
    """
    Custom index dashboard for ECMS
    """
    class Media:
        css = ("ecms_dashboard/dashboard.css",)

    def init_with_context(self, context):
        site_name = get_admin_site_name(context)

        quick_links = modules.LinkList(
            _('Quick links'),
            layout='inline',
            draggable=False,
            deletable=False,
            collapsible=False,
            children=[
                [_('Return to site'), '/'],
                [_('Change password'),
                 reverse('%s:password_change' % site_name)],
                [_('Log out'), reverse('%s:logout' % site_name)],
            ]
        )

        apps = EcmsAppIconList(
            _('CMS'),
            exclude=ADMINISTRATION_APPS,
            collapsible=False
        )

        administration = EcmsAppIconList(
            _('Administration'),
            models=ADMINISTRATION_APPS,
            collapsible=False
        )

        recent_actions = modules.RecentActions(_('Recent Actions'), 5, enabled=False, collapsible=False)

        self.children.append(quick_links)
        self.children.append(apps)
        self.children.append(administration)
        self.children.append(recent_actions)


class EcmsAppIndexDashboard(AppIndexDashboard):
    """
    Custom app index dashboard for ECMS
    """

    # disable title because its redundant with the model list module<commit_msg>Reserve a category for developer tools<commit_after>"""
Custom dashboard for ECMS.

To activate the index dashboard add the following to your settings.py::
    ADMIN_TOOLS_INDEX_DASHBOARD = 'ecms_dashboard.dashboard.CustomIndexDashboard'

And to activate the app index dashboard::
    ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'ecms_dashboard.dashboard.CustomAppIndexDashboard'
"""

from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse

from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard
from admin_tools.utils import get_admin_site_name  # needs 0.4.0

from ecms_dashboard.modules import EcmsAppIconList


ADMINISTRATION_APPS = ('django.contrib.*', 'registration.*',)
DEVELOPER_APPS = ()
ALL_KNOWN_APPS = ADMINISTRATION_APPS + DEVELOPER_APPS


class EcmsIndexDashboard(Dashboard):
    """
    Custom index dashboard for ECMS
    """
    class Media:
        css = ("ecms_dashboard/dashboard.css",)

    def init_with_context(self, context):
        site_name = get_admin_site_name(context)

        quick_links = modules.LinkList(
            _('Quick links'),
            layout='inline',
            draggable=False,
            deletable=False,
            collapsible=False,
            children=[
                [_('Return to site'), '/'],
                [_('Change password'),
                 reverse('%s:password_change' % site_name)],
                [_('Log out'), reverse('%s:logout' % site_name)],
            ]
        )

        apps = EcmsAppIconList(
            _('CMS'),
            exclude=ALL_KNOWN_APPS,
            collapsible=False
        )

        administration = EcmsAppIconList(
            _('Administration'),
            models=ADMINISTRATION_APPS,
            collapsible=False
        )

        if DEVELOPER_APPS:
            development = EcmsAppIconList(
                _('Developer tools'),
                models=DEVELOPER_APPS,
                collapsible=True
            )

        recent_actions = modules.RecentActions(_('Recent Actions'), 5, enabled=False, collapsible=False)

        self.children.append(quick_links)
        self.children.append(apps)
        self.children.append(administration)
        if DEVELOPER_APPS:
            self.children.append(development)

        self.children.append(recent_actions)


class EcmsAppIndexDashboard(AppIndexDashboard):
    """
    Custom app index dashboard for ECMS
    """

    # disable title because its redundant with the model list module
{'fraction_non_alphanumeric': 0.0908895110919664, 'fraction_numerical': 0.0017230239069567091, 'mean_word_length': 2.648075412411626, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3799709', 'n_tokens_mistral': 1375, 'n_tokens_neox': 1312, 'n_words': 277}