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 | ||
ca108b40 | 15 | from django.core.urlresolvers import reverse |
fc4bf968 | 16 | from django.utils.translation import ugettext_lazy as _ |
ca108b40 | 17 | from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard |
8e26a99b | 18 | from project.decorators import in_drh_or_admin |
edbc9e37 | 19 | from project.rh.historique import get_active_revisions |
8846b99e | 20 | |
8846b99e OL |
21 | class CustomIndexDashboard(Dashboard): |
22 | """ | |
e1a81904 | 23 | Custom index dashboard for SGRH. |
8846b99e OL |
24 | """ |
25 | def init_with_context(self, context): | |
8e26a99b | 26 | request = context['request'] |
8846b99e OL |
27 | |
28 | # append an app list module for "Applications" | |
e1a81904 | 29 | self.children.append(modules.Group( |
8846b99e | 30 | _('Applications'), |
e1a81904 PP |
31 | display='stacked', |
32 | children=[ | |
33 | modules.ModelList( | |
34 | title='Demande d\'autorisation d\'engagement', | |
35 | models=( | |
36 | 'project.dae.models.*', | |
37 | ) | |
38 | ), | |
39 | modules.ModelList( | |
40 | title='Gestion des candidatures', | |
41 | models=( | |
42 | 'auf.django.emploi.models.OffreEmploi', | |
43 | 'project.recrutement.models.ProxyOffreEmploi', | |
44 | 'auf.django.emploi.models.Candidat', | |
45 | 'project.recrutement.models.ProxyCandidat', | |
46 | 'project.recrutement.models.CandidatEvaluation', | |
47 | 'project.recrutement.models.MesCandidatEvaluation', | |
48 | 'project.recrutement.models.Evaluateur', | |
49 | 'project.recrutement.models.CourrielTemplate', | |
50 | ) | |
51 | ), | |
52 | modules.ModelList( | |
53 | title='Gestion des personnels', | |
54 | models=( | |
55 | 'project.rh.models.AyantDroit', | |
56 | 'project.rh.models.Dossier', | |
57 | 'project.rh.models.DossierInactif', | |
58 | 'project.rh.models.Employe', | |
59 | 'project.rh.models.EmployeInactif', | |
60 | 'project.rh.models.Poste', | |
61 | ) | |
62 | ), | |
63 | ] | |
d69f7f42 DB |
64 | )) |
65 | ||
8e26a99b | 66 | if in_drh_or_admin(request.user): |
edbc9e37 | 67 | revisions = get_active_revisions()[:10] |
8e26a99b OL |
68 | children = [] |
69 | for rev in revisions: | |
45c66f19 OL |
70 | date = rev['short_date_created'] |
71 | user = u"<span style='font-weight: bold;'>%s</span>" % rev['user'] | |
ca108b40 OL |
72 | if rev['type'] is None or rev['objet'] is None: |
73 | titre = u"""<span style='color:black;'>[%s] %s</span> | |
74 | commentaire : %s """ % (date, user, rev['comment']) | |
75 | children.append({ | |
76 | 'title': titre, | |
77 | 'url': reverse('rhr_historique_des_modifications'), | |
78 | 'external': False, | |
79 | }) | |
80 | else: | |
81 | type = u"<span style='font-decoration: underligne;'>%s</span>" % rev['type'] | |
82 | titre = u"""<span style='color:black;'>[%s] %s a modifié | |
83 | un(e) %s :</span> %s""" % (date, user, type, rev['objet'], ) | |
84 | children.append({ | |
85 | 'title': titre, | |
86 | 'url': rev['history_url'], | |
87 | 'external': False, | |
88 | }) | |
8e26a99b OL |
89 | self.children.append(modules.LinkList( |
90 | title='10 dernières modifications', | |
91 | children=children,) | |
92 | ) | |
93 | ||
94 | ||
95 | ||
d69f7f42 DB |
96 | # append an app list module for "Configuration" |
97 | self.children.append(modules.AppList( | |
98 | _('Configuration'), | |
99 | models=( | |
fc4bf968 EMS |
100 | 'project.rh.models.Classement', |
101 | 'project.rh.models.Devise', | |
102 | 'project.rh.models.CategorieEmploi', | |
321fe481 | 103 | 'project.rh.models.FamilleProfessionnelle', |
fc4bf968 EMS |
104 | 'project.rh.models.OrganismeBstg', |
105 | 'project.rh.models.Responsable', | |
106 | 'project.rh.models.Service', | |
107 | 'project.rh.models.Statut', | |
108 | 'project.rh.models.TauxChange', | |
109 | 'project.rh.models.TypeContrat', | |
110 | 'project.rh.models.TypePoste', | |
111 | 'project.rh.models.TypeRevalorisation', | |
112 | 'project.rh.models.TypeRemuneration', | |
113 | 'project.rh.models.ValeurPoint', | |
56fdab08 | 114 | ), |
8846b99e OL |
115 | exclude=('django.contrib.*',), |
116 | )) | |
117 | ||
d69f7f42 DB |
118 | # append an app list module for "Inter-systèmes" |
119 | self.children.append(modules.AppList( | |
120 | _(u'Inter-systèmes'), | |
121 | models=( | |
6fb68b2f | 122 | 'project.rh.models.ResponsableImplantationProxy', |
d69f7f42 DB |
123 | ), |
124 | )) | |
125 | ||
8846b99e OL |
126 | # append an app list module for "Administration" |
127 | self.children.append(modules.AppList( | |
128 | _('Administration'), | |
d69f7f42 | 129 | models=( |
fc4bf968 | 130 | 'django.contrib.*', |
d69f7f42 | 131 | ), |
8846b99e OL |
132 | )) |
133 | ||
7f43054e PP |
134 | class CustomAppIndexDashboard(AppIndexDashboard): |
135 | """ | |
136 | Custom app index dashboard for project. | |
137 | """ | |
138 | ||
139 | # we disable title because its redundant with the model list module | |
140 | title = '' | |
141 | ||
142 | def __init__(self, *args, **kwargs): | |
143 | AppIndexDashboard.__init__(self, *args, **kwargs) | |
144 | ||
145 | def init_with_context(self, context): | |
146 | """ | |
147 | Use this method if you need to access the request context. | |
148 | """ | |
149 | if self.app_title != 'Rh': | |
150 | # append a model list module and a recent actions module | |
151 | self.children += [ | |
fc4bf968 | 152 | modules.ModelList(self.app_title, self.models), |
7f43054e PP |
153 | ] |
154 | ||
155 | return | |
156 | ||
157 | # append an app list module for "Application" | |
158 | self.children.append(modules.AppList( | |
159 | _('Application'), | |
160 | models=( | |
fc4bf968 EMS |
161 | 'project.rh.models.AyantDroit', |
162 | 'project.rh.models.Dossier', | |
163 | 'project.rh.models.DossierInactif', | |
164 | 'project.rh.models.Employe', | |
165 | 'project.rh.models.EmployeInactif', | |
166 | 'project.rh.models.Poste', | |
7f43054e PP |
167 | ), |
168 | )) | |
169 | ||
170 | # append an app list module for "Configuration" | |
171 | self.children.append(modules.AppList( | |
172 | _('Configuration'), | |
173 | models=( | |
fc4bf968 EMS |
174 | 'project.rh.models.Classement', |
175 | 'project.rh.models.Devise', | |
176 | 'project.rh.models.CategorieEmploi', | |
321fe481 | 177 | 'project.rh.models.FamilleProfessionnelle', |
fc4bf968 EMS |
178 | 'project.rh.models.OrganismeBstg', |
179 | 'project.rh.models.Responsable', | |
180 | 'project.rh.models.Service', | |
181 | 'project.rh.models.Statut', | |
182 | 'project.rh.models.TauxChange', | |
183 | 'project.rh.models.TypeContrat', | |
184 | 'project.rh.models.TypePoste', | |
185 | 'project.rh.models.TypeRevalorisation', | |
186 | 'project.rh.models.TypeRemuneration', | |
187 | 'project.rh.models.ValeurPoint', | |
7f43054e PP |
188 | ), |
189 | )) | |
190 | ||
191 | # append an app list module for "Inter-systèmes" | |
192 | self.children.append(modules.AppList( | |
193 | _(u'Inter-systèmes'), | |
194 | models=( | |
fc4bf968 | 195 | 'project.rh.models.ResponsableImplantation', |
7f43054e PP |
196 | ), |
197 | )) |