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 SIGMA.
25 def init_with_context(self
, context
):
26 request
= context
['request']
28 # append an app list module for "Applications"
29 self
.children
.append(modules
.AppList(
32 'project.dae.models.*',
33 'project.recrutement.models.*',
34 'project.rh.models.AyantDroit',
35 'project.rh.models.Dossier',
36 'project.rh.models.DossierInactif',
37 'project.rh.models.Employe',
38 'project.rh.models.EmployeInactif',
39 'project.rh.models.Poste',
43 if in_drh_or_admin(request
.user
):
44 revisions
= get_active_revisions()[:10]
47 date
= rev
['short_date_created']
48 user
= u
"<span style='font-weight: bold;'>%s</span>" % rev
['user']
49 if rev
['type'] is None or rev
['objet'] is None:
50 titre
= u
"""<span style='color:black;'>[%s] %s</span>
51 commentaire : %s """ % (date
, user
, rev
['comment'])
54 'url': reverse('rhr_historique_des_modifications'),
58 type = u
"<span style='font-decoration: underligne;'>%s</span>" % rev
['type']
59 titre
= u
"""<span style='color:black;'>[%s] %s a modifié
60 un(e) %s :</span> %s""" % (date
, user
, type, rev
['objet'], )
63 'url': rev
['history_url'],
66 self
.children
.append(modules
.LinkList(
67 title
='10 dernières modifications',
73 # append an app list module for "Configuration"
74 self
.children
.append(modules
.AppList(
77 'project.rh.models.Classement',
78 'project.rh.models.Devise',
79 'project.rh.models.CategorieEmploi',
80 'project.rh.models.FamilleProfessionnelle',
81 'project.rh.models.OrganismeBstg',
82 'project.rh.models.Responsable',
83 'project.rh.models.Service',
84 'project.rh.models.Statut',
85 'project.rh.models.TauxChange',
86 'project.rh.models.TypeContrat',
87 'project.rh.models.TypePoste',
88 'project.rh.models.TypeRevalorisation',
89 'project.rh.models.TypeRemuneration',
90 'project.rh.models.ValeurPoint',
92 exclude
=('django.contrib.*',),
95 # append an app list module for "Inter-systèmes"
96 self
.children
.append(modules
.AppList(
99 'project.rh.models.ResponsableImplantationProxy',
103 # append an app list module for "Administration"
104 self
.children
.append(modules
.AppList(
111 class CustomAppIndexDashboard(AppIndexDashboard
):
113 Custom app index dashboard for project.
116 # we disable title because its redundant with the model list module
119 def __init__(self
, *args
, **kwargs
):
120 AppIndexDashboard
.__init__(self
, *args
, **kwargs
)
122 def init_with_context(self
, context
):
124 Use this method if you need to access the request context.
126 if self
.app_title
!= 'Rh':
127 # append a model list module and a recent actions module
129 modules
.ModelList(self
.app_title
, self
.models
),
134 # append an app list module for "Application"
135 self
.children
.append(modules
.AppList(
138 'project.rh.models.AyantDroit',
139 'project.rh.models.Dossier',
140 'project.rh.models.DossierInactif',
141 'project.rh.models.Employe',
142 'project.rh.models.EmployeInactif',
143 'project.rh.models.Poste',
147 # append an app list module for "Configuration"
148 self
.children
.append(modules
.AppList(
151 'project.rh.models.Classement',
152 'project.rh.models.Devise',
153 'project.rh.models.CategorieEmploi',
154 'project.rh.models.FamilleProfessionnelle',
155 'project.rh.models.OrganismeBstg',
156 'project.rh.models.Responsable',
157 'project.rh.models.Service',
158 'project.rh.models.Statut',
159 'project.rh.models.TauxChange',
160 'project.rh.models.TypeContrat',
161 'project.rh.models.TypePoste',
162 'project.rh.models.TypeRevalorisation',
163 'project.rh.models.TypeRemuneration',
164 'project.rh.models.ValeurPoint',
168 # append an app list module for "Inter-systèmes"
169 self
.children
.append(modules
.AppList(
170 _(u
'Inter-systèmes'),
172 'project.rh.models.ResponsableImplantation',