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