upgrade saml
[auf_rh_dae.git] / project / dashboard.py
CommitLineData
8846b99e
OL
1# -*- encoding: utf-8 -*
2
3"""
4This file was generated with the customdashboard management command, it
5contains the two classes for the main dashboard and app index dashboard.
6You can customize these classes as you want.
7
8To activate your index dashboard add the following to your settings.py::
9 ADMIN_TOOLS_INDEX_DASHBOARD = 'SIGMA.dashboard.CustomIndexDashboard'
10
11And to activate the app index dashboard::
12 ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'SIGMA.dashboard.CustomAppIndexDashboard'
13"""
14
ca108b40 15from django.core.urlresolvers import reverse
fc4bf968 16from django.utils.translation import ugettext_lazy as _
ca108b40 17from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard
8e26a99b 18from project.decorators import in_drh_or_admin
edbc9e37 19from project.rh.historique import get_active_revisions
8846b99e 20
8846b99e
OL
21class CustomIndexDashboard(Dashboard):
22 """
23 Custom index dashboard for SIGMA.
24 """
25 def init_with_context(self, context):
8e26a99b 26 request = context['request']
8846b99e
OL
27
28 # append an app list module for "Applications"
62201d27 29 self.children.append(modules.Group(
8846b99e 30 _('Applications'),
62201d27
OL
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
62201d27 66
8e26a99b 67 if in_drh_or_admin(request.user):
edbc9e37 68 revisions = get_active_revisions()[:10]
8e26a99b
OL
69 children = []
70 for rev in revisions:
45c66f19
OL
71 date = rev['short_date_created']
72 user = u"<span style='font-weight: bold;'>%s</span>" % rev['user']
ca108b40
OL
73 if rev['type'] is None or rev['objet'] is None:
74 titre = u"""<span style='color:black;'>[%s] %s</span>
75 commentaire : %s """ % (date, user, rev['comment'])
76 children.append({
77 'title': titre,
78 'url': reverse('rhr_historique_des_modifications'),
79 'external': False,
80 })
81 else:
82 type = u"<span style='font-decoration: underligne;'>%s</span>" % rev['type']
83 titre = u"""<span style='color:black;'>[%s] %s a modifié
84 un(e) %s :</span> %s""" % (date, user, type, rev['objet'], )
85 children.append({
86 'title': titre,
87 'url': rev['history_url'],
88 'external': False,
89 })
8e26a99b
OL
90 self.children.append(modules.LinkList(
91 title='10 dernières modifications',
92 children=children,)
93 )
94
95
96
d69f7f42
DB
97 # append an app list module for "Configuration"
98 self.children.append(modules.AppList(
99 _('Configuration'),
100 models=(
fc4bf968
EMS
101 'project.rh.models.Classement',
102 'project.rh.models.Devise',
103 'project.rh.models.CategorieEmploi',
321fe481 104 'project.rh.models.FamilleProfessionnelle',
fc4bf968
EMS
105 'project.rh.models.OrganismeBstg',
106 'project.rh.models.Responsable',
107 'project.rh.models.Service',
108 'project.rh.models.Statut',
109 'project.rh.models.TauxChange',
110 'project.rh.models.TypeContrat',
111 'project.rh.models.TypePoste',
112 'project.rh.models.TypeRevalorisation',
113 'project.rh.models.TypeRemuneration',
114 'project.rh.models.ValeurPoint',
56fdab08 115 ),
8846b99e
OL
116 exclude=('django.contrib.*',),
117 ))
118
d69f7f42
DB
119 # append an app list module for "Inter-systèmes"
120 self.children.append(modules.AppList(
121 _(u'Inter-systèmes'),
122 models=(
6fb68b2f 123 'project.rh.models.ResponsableImplantationProxy',
d69f7f42
DB
124 ),
125 ))
126
8846b99e
OL
127 # append an app list module for "Administration"
128 self.children.append(modules.AppList(
129 _('Administration'),
d69f7f42 130 models=(
fc4bf968 131 'django.contrib.*',
d69f7f42 132 ),
8846b99e
OL
133 ))
134
7f43054e
PP
135class CustomAppIndexDashboard(AppIndexDashboard):
136 """
137 Custom app index dashboard for project.
138 """
139
140 # we disable title because its redundant with the model list module
141 title = ''
142
143 def __init__(self, *args, **kwargs):
144 AppIndexDashboard.__init__(self, *args, **kwargs)
145
146 def init_with_context(self, context):
147 """
148 Use this method if you need to access the request context.
149 """
150 if self.app_title != 'Rh':
151 # append a model list module and a recent actions module
152 self.children += [
fc4bf968 153 modules.ModelList(self.app_title, self.models),
7f43054e
PP
154 ]
155
156 return
157
158 # append an app list module for "Application"
159 self.children.append(modules.AppList(
160 _('Application'),
161 models=(
fc4bf968
EMS
162 'project.rh.models.AyantDroit',
163 'project.rh.models.Dossier',
164 'project.rh.models.DossierInactif',
165 'project.rh.models.Employe',
166 'project.rh.models.EmployeInactif',
167 'project.rh.models.Poste',
7f43054e
PP
168 ),
169 ))
170
171 # append an app list module for "Configuration"
172 self.children.append(modules.AppList(
173 _('Configuration'),
174 models=(
fc4bf968
EMS
175 'project.rh.models.Classement',
176 'project.rh.models.Devise',
177 'project.rh.models.CategorieEmploi',
321fe481 178 'project.rh.models.FamilleProfessionnelle',
fc4bf968
EMS
179 'project.rh.models.OrganismeBstg',
180 'project.rh.models.Responsable',
181 'project.rh.models.Service',
182 'project.rh.models.Statut',
183 'project.rh.models.TauxChange',
184 'project.rh.models.TypeContrat',
185 'project.rh.models.TypePoste',
186 'project.rh.models.TypeRevalorisation',
187 'project.rh.models.TypeRemuneration',
188 'project.rh.models.ValeurPoint',
7f43054e
PP
189 ),
190 ))
191
192 # append an app list module for "Inter-systèmes"
193 self.children.append(modules.AppList(
194 _(u'Inter-systèmes'),
195 models=(
fc4bf968 196 'project.rh.models.ResponsableImplantation',
7f43054e
PP
197 ),
198 ))