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

from admin_tools.dashboard import modules, Dashboard
from admin_tools.utils import get_admin_site_name


class CrateIndexDashboard(Dashboard):

    def init_with_context(self, context):
        site_name = get_admin_site_name(context)
        # append a link list module for "quick links"
        self.children.append(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)],
            ]
        ))

        # append an app list module for "Applications"
        self.children.append(modules.AppList(
            _("Applications"),
            exclude=('django.contrib.*',),
        ))

        # append an app list module for "Administration"
        self.children.append(modules.AppList(
            _("Administration"),
            models=('django.contrib.*',),
        ))

        # append a recent actions module
        self.children.append(modules.RecentActions(_("Recent Actions"), 5))

        # append a feed module
        self.children.append(modules.Feed(
            _("Latest Django News"),
            feed_url='http://www.djangoproject.com/rss/weblog/',
            limit=5
        ))

        # append another link list module for "support".
        self.children.append(modules.LinkList(
            _("Support"),
            children=[
                {
                    "title": _("Django documentation"),
                    "url": "http://docs.djangoproject.com/",
                    "external": True,
                },
                {
                    "title": _("Django \"django-users\" mailing list"),
                    "url": "http://groups.google.com/group/django-users",
                    "external": True,
                },
                {
                    "title": _("Django irc channel"),
                    "url": "irc://irc.freenode.net/django",
                    "external": True,
                },
            ]
        ))

@@ -880,27 +880,29 @@
 e for %22A
-pplic
+dministr
 ation
-s
 %22%0A      
@@ -961,19 +961,21 @@
 _(%22A
-pplic
+dministr
 ation
-s
 %22),%0A
@@ -990,15 +990,14 @@
     
-exclude
+models
 =('d
@@ -1066,37 +1066,35 @@
 odule for %22A
-dministr
+pplic
 ation
+s
 %22%0A        se
@@ -1141,37 +1141,35 @@
         _(%22A
-dministr
+pplic
 ation
+s
 %22),%0A        
@@ -1176,36 +1176,198 @@
     
-models=('django.contrib.*',)
+exclude=%5B%0A                %22django.contrib.*%22,%0A                %22pinax.apps.*%22,%0A                %22djcelery.*%22,%0A                %22emailconfirmation.*%22,%0A                %22profiles.*%22,%0A            %5D
 ,%0A  

move the administration module up and exclude some less used apps from the dashboard