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