188f249a |
1 | from django.utils.translation import ugettext_lazy as _ |
2 | from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard |
3 | from savoirs.models import Record |
4 | from savoirs.admin_views import RecordDashboard |
5 | |
6 | # to activate your index dashboard add the following to your settings.py: |
7 | # |
8 | # ADMIN_TOOLS_INDEX_DASHBOARD = 'auf_savoirs_en_partage.dashboard.CustomIndexDashboard' |
9 | |
10 | class CustomIndexDashboard(Dashboard): |
11 | """ |
12 | Custom index dashboard for auf_savoirs_en_partage. |
13 | """ |
14 | def __init__(self, **kwargs): |
15 | Dashboard.__init__(self, **kwargs) |
16 | |
17 | def init_with_context(self, context): |
18 | """ |
19 | Use this method if you need to access the request context. |
20 | """ |
21 | # append another link list module for "support". |
22 | #self.children.append(modules.LinkList( |
23 | # title=_('Support'), |
24 | # children=[ |
25 | # { |
26 | # 'title': _(u'Reporter un probleme JUTDA'), |
27 | # 'url': 'http://jutda.auf.org/', |
28 | # 'external': True, |
29 | # }, |
30 | # ] |
31 | #)) |
32 | |
33 | # append an app list module for "Applications" |
34 | self.children.append(modules.AppList( |
35 | title=_('Applications'), |
36 | exclude_list=('django.contrib',), |
37 | )) |
38 | |
39 | # append an app list module for "Administration" |
40 | #self.children.append(modules.AppList( |
41 | # title=_('Administration'), |
42 | # include_list=('django.contrib',), |
43 | #)) |
44 | |
45 | # append a recent actions module |
46 | #self.children.append(modules.RecentActions( |
47 | # title=_('Recent Actions'), |
48 | # limit=5 |
49 | #)) |
50 | |
51 | # append another link list module for "RecordDashboard". |
52 | ref_dash = RecordDashboard(context) |
53 | self.children.append(modules.LinkList( |
54 | title=_('Reference a completer') + " (%d restantes)" % ref_dash.total_a_faire(), |
55 | children=ref_dash.a_traiter() |
56 | )) |
57 | |
58 | |
59 | # to activate your app index dashboard add the following to your settings.py: |
60 | # |
61 | # ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'auf_savoirs_en_partage.dashboard.CustomAppIndexDashboard' |
62 | |
63 | class CustomAppIndexDashboard(AppIndexDashboard): |
64 | """ |
65 | Custom app index dashboard for auf_savoirs_en_partage. |
66 | """ |
67 | def __init__(self, *args, **kwargs): |
68 | AppIndexDashboard.__init__(self, *args, **kwargs) |
69 | |
70 | # we disable title because its redundant with the model list module |
71 | self.title = '' |
72 | |
73 | # append a model list module |
74 | self.children.append(modules.ModelList( |
75 | title=self.app_title, |
76 | include_list=self.models, |
77 | )) |
78 | |
79 | # append a recent actions module |
80 | self.children.append(modules.RecentActions( |
81 | title=_('Recent Actions'), |
82 | include_list=self.get_app_content_types(), |
83 | )) |
84 | |
85 | def init_with_context(self, context): |
86 | """ |
87 | Use this method if you need to access the request context. |
88 | """ |
89 | pass |