1 # -*- encoding: utf-8 -*
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.
8 To activate your index dashboard add the following to your settings.py::
9 ADMIN_TOOLS_INDEX_DASHBOARD = 'SIGMA.dashboard.CustomIndexDashboard'
11 And to activate the app index dashboard::
12 ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'SIGMA.dashboard.CustomAppIndexDashboard'
15 from django
.core
.urlresolvers
import reverse
16 from django
.utils
.translation
import ugettext_lazy
as _
17 from admin_tools
.dashboard
import modules
, Dashboard
, AppIndexDashboard
18 from project
.decorators
import in_drh_or_admin
19 from project
.rh
.historique
import get_active_revisions
21 class CustomIndexDashboard(Dashboard
):
23 Custom index dashboard for SGRH.
25 def init_with_context(self
, context
):
26 request
= context
['request']
28 # append an app list module for "Applications"
29 self
.children
.append(modules
.Group(
34 title
='Demande d\'autorisation d\'engagement',
36 'project.dae.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.OffreEmploiEvaluateur',
50 'project.recrutement.models.CourrielTemplate',
54 title
='Gestion des personnels',
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',
67 'project.rh.models.ChangementPersonnel',
74 if in_drh_or_admin(request
.user
):
75 revisions
= get_active_revisions()[:10]
78 date
= rev
['short_date_created']
79 user
= u
"<span style='font-weight: bold;'>%s</span>" % rev
['user']
80 if rev
['type'] is None or rev
['objet'] is None:
81 titre
= u
"""<span style='color:black;'>[%s] %s</span>
82 commentaire : %s """ % (date
, user
, rev
['comment'])
85 'url': reverse('rhr_historique_des_modifications'),
89 type = u
"<span style='font-decoration: underligne;'>%s</span>" % rev
['type']
90 titre
= u
"""<span style='color:black;'>[%s] %s a modifié
91 un(e) %s :</span> %s""" % (date
, user
, type, rev
['objet'], )
94 'url': rev
['history_url'],
97 self
.children
.append(modules
.LinkList(
98 title
='10 dernières modifications',
104 # append an app list module for "Configuration"
105 self
.children
.append(modules
.AppList(
108 'project.rh.models.Classement',
109 'project.rh.models.Devise',
110 'project.rh.models.CategorieEmploi',
111 'project.rh.models.FamilleProfessionnelle',
112 'project.rh.models.OrganismeBstg',
113 'project.rh.models.Responsable',
114 'project.rh.models.Service',
115 'project.rh.models.Statut',
116 'project.rh.models.TauxChange',
117 'project.rh.models.TypeContrat',
118 'project.rh.models.TypePoste',
119 'project.rh.models.TypeRevalorisation',
120 'project.rh.models.TypeRemuneration',
121 'project.rh.models.ValeurPoint',
122 'project.rh.models.ChangementPersonnelNotifications',
124 exclude
=('django.contrib.*',),
127 # append an app list module for "Inter-systèmes"
128 self
.children
.append(modules
.AppList(
129 _(u
'Inter-systèmes'),
131 'project.rh.models.ResponsableImplantationProxy',
135 # append an app list module for "Administration"
136 self
.children
.append(modules
.AppList(
143 class CustomAppIndexDashboard(AppIndexDashboard
):
145 Custom app index dashboard for project.
148 # we disable title because its redundant with the model list module
151 def __init__(self
, *args
, **kwargs
):
152 AppIndexDashboard
.__init__(self
, *args
, **kwargs
)
154 def init_with_context(self
, context
):
156 Use this method if you need to access the request context.
158 if self
.app_title
!= 'Rh':
159 # append a model list module and a recent actions module
161 modules
.ModelList(self
.app_title
, self
.models
),
166 # append an app list module for "Application"
167 self
.children
.append(modules
.AppList(
170 'project.rh.models.AyantDroit',
171 'project.rh.models.Dossier',
172 'project.rh.models.DossierInactif',
173 'project.rh.models.Employe',
174 'project.rh.models.EmployeInactif',
175 'project.rh.models.Poste',
179 # append an app list module for "Configuration"
180 self
.children
.append(modules
.AppList(
183 'project.rh.models.Classement',
184 'project.rh.models.Devise',
185 'project.rh.models.CategorieEmploi',
186 'project.rh.models.FamilleProfessionnelle',
187 'project.rh.models.OrganismeBstg',
188 'project.rh.models.Responsable',
189 'project.rh.models.Service',
190 'project.rh.models.Statut',
191 'project.rh.models.TauxChange',
192 'project.rh.models.TypeContrat',
193 'project.rh.models.TypePoste',
194 'project.rh.models.TypeRevalorisation',
195 'project.rh.models.TypeRemuneration',
196 'project.rh.models.ValeurPoint',
200 # append an app list module for "Inter-systèmes"
201 self
.children
.append(modules
.AppList(
202 _(u
'Inter-systèmes'),
204 'project.rh.models.ResponsableImplantation',