Commit | Line | Data |
---|---|---|
8846b99e OL |
1 | # -*- encoding: utf-8 -* |
2 | ||
3 | """ | |
4 | This file was generated with the customdashboard management command, it | |
5 | contains the two classes for the main dashboard and app index dashboard. | |
6 | You can customize these classes as you want. | |
7 | ||
8 | To activate your index dashboard add the following to your settings.py:: | |
9 | ADMIN_TOOLS_INDEX_DASHBOARD = 'SIGMA.dashboard.CustomIndexDashboard' | |
10 | ||
11 | And to activate the app index dashboard:: | |
12 | ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'SIGMA.dashboard.CustomAppIndexDashboard' | |
13 | """ | |
14 | ||
15 | from django.utils.translation import ugettext_lazy as _ | |
16 | from django.core.urlresolvers import reverse | |
17 | ||
18 | from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard | |
19 | from admin_tools.utils import get_admin_site_name | |
20 | ||
21 | ||
22 | class CustomIndexDashboard(Dashboard): | |
23 | """ | |
24 | Custom index dashboard for SIGMA. | |
25 | """ | |
26 | def init_with_context(self, context): | |
27 | site_name = get_admin_site_name(context) | |
28 | ||
29 | # append an app list module for "Applications" | |
30 | self.children.append(modules.AppList( | |
31 | _('Applications'), | |
d69f7f42 DB |
32 | models=( |
33 | 'project.dae.models.*', | |
34 | 'project.recrutement.models.*', | |
56fdab08 | 35 | 'project.rh.models.AyantDroit', |
d69f7f42 | 36 | 'project.rh.models.Dossier', |
64721a83 | 37 | 'project.rh.models.DossierInactif', |
d69f7f42 | 38 | 'project.rh.models.Employe', |
64721a83 | 39 | 'project.rh.models.EmployeInactif', |
d69f7f42 DB |
40 | 'project.rh.models.Poste', |
41 | ), | |
42 | )) | |
43 | ||
44 | # append an app list module for "Configuration" | |
45 | self.children.append(modules.AppList( | |
46 | _('Configuration'), | |
47 | models=( | |
56fdab08 OL |
48 | 'project.rh.models.Classement', |
49 | 'project.rh.models.Devise', | |
50 | 'project.rh.models.FamilleEmploi', | |
51 | 'project.rh.models.OrganismeBstg', | |
52 | 'project.rh.models.Responsable', | |
53 | 'project.rh.models.Service', | |
54 | 'project.rh.models.Statut', | |
55 | 'project.rh.models.TauxChange', | |
56 | 'project.rh.models.TypeContrat', | |
57 | 'project.rh.models.TypePoste', | |
58 | 'project.rh.models.TypeRevalorisation', | |
59 | 'project.rh.models.TypeRemuneration', | |
60 | 'project.rh.models.ValeurPoint', | |
61 | ), | |
8846b99e OL |
62 | exclude=('django.contrib.*',), |
63 | )) | |
64 | ||
d69f7f42 DB |
65 | # append an app list module for "Inter-systèmes" |
66 | self.children.append(modules.AppList( | |
67 | _(u'Inter-systèmes'), | |
68 | models=( | |
69 | 'project.rh.models.ResponsableImplantation', | |
70 | ), | |
71 | )) | |
72 | ||
8846b99e OL |
73 | # append an app list module for "Administration" |
74 | self.children.append(modules.AppList( | |
75 | _('Administration'), | |
d69f7f42 DB |
76 | models=( |
77 | 'django.contrib.*', | |
78 | ), | |
8846b99e OL |
79 | )) |
80 | ||
81 | # append a recent actions module | |
4a6a9e85 | 82 | #self.children.append(modules.RecentActions(_('Recent Actions'), 5)) |
7f43054e PP |
83 | |
84 | ||
85 | class CustomAppIndexDashboard(AppIndexDashboard): | |
86 | """ | |
87 | Custom app index dashboard for project. | |
88 | """ | |
89 | ||
90 | # we disable title because its redundant with the model list module | |
91 | title = '' | |
92 | ||
93 | def __init__(self, *args, **kwargs): | |
94 | AppIndexDashboard.__init__(self, *args, **kwargs) | |
95 | ||
96 | def init_with_context(self, context): | |
97 | """ | |
98 | Use this method if you need to access the request context. | |
99 | """ | |
100 | if self.app_title != 'Rh': | |
101 | # append a model list module and a recent actions module | |
102 | self.children += [ | |
103 | modules.ModelList(self.app_title,self.models), | |
4a6a9e85 OL |
104 | #modules.RecentActions( |
105 | # _('Recent Actions'), | |
106 | # include_list=self.get_app_content_types(), | |
107 | # limit=5 | |
108 | #) | |
7f43054e PP |
109 | ] |
110 | ||
111 | return | |
112 | ||
113 | # append an app list module for "Application" | |
114 | self.children.append(modules.AppList( | |
115 | _('Application'), | |
116 | models=( | |
117 | 'project.rh.models.AyantDroit', | |
118 | 'project.rh.models.Dossier', | |
64721a83 | 119 | 'project.rh.models.DossierInactif', |
7f43054e | 120 | 'project.rh.models.Employe', |
64721a83 | 121 | 'project.rh.models.EmployeInactif', |
7f43054e PP |
122 | 'project.rh.models.Poste', |
123 | ), | |
124 | )) | |
125 | ||
126 | # append an app list module for "Configuration" | |
127 | self.children.append(modules.AppList( | |
128 | _('Configuration'), | |
129 | models=( | |
130 | 'project.rh.models.Classement', | |
131 | 'project.rh.models.Devise', | |
132 | 'project.rh.models.FamilleEmploi', | |
133 | 'project.rh.models.OrganismeBstg', | |
134 | 'project.rh.models.Responsable', | |
135 | 'project.rh.models.Service', | |
136 | 'project.rh.models.Statut', | |
137 | 'project.rh.models.TauxChange', | |
138 | 'project.rh.models.TypeContrat', | |
139 | 'project.rh.models.TypePoste', | |
140 | 'project.rh.models.TypeRevalorisation', | |
141 | 'project.rh.models.TypeRemuneration', | |
142 | 'project.rh.models.ValeurPoint', | |
143 | ), | |
144 | )) | |
145 | ||
146 | # append an app list module for "Inter-systèmes" | |
147 | self.children.append(modules.AppList( | |
148 | _(u'Inter-systèmes'), | |
149 | models=( | |
150 | 'project.rh.models.ResponsableImplantation', | |
151 | ), | |
152 | )) | |
153 | ||
154 | # append a recent actions module | |
4a6a9e85 OL |
155 | #self.children.append(modules.RecentActions( |
156 | # _('Recent Actions'), | |
157 | # include_list=self.get_app_content_types(), | |
158 | # limit=5 | |
159 | #)) |