rapport modif + widget
[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
OL
17from reversion.models import Revision
18from project.decorators import in_drh_or_admin
19from project.rh.historique import format_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"
29 self.children.append(modules.AppList(
30 _('Applications'),
d69f7f42 31 models=(
fc4bf968
EMS
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',
d69f7f42
DB
40 ),
41 ))
42
8e26a99b
OL
43 if in_drh_or_admin(request.user):
44 revisions = format_revisions(Revision.objects.order_by('-date_created')[:10])
45 children = []
46 for rev in revisions:
47 children.append({
48 'title': u"%s: %s %s (%s)" % (rev['date_created'],
49 rev['type'], rev['objet'], rev['comment']),
50 'url': rev['url'],
51 'external': False,
52 })
53 self.children.append(modules.LinkList(
54 title='10 dernières modifications',
55 children=children,)
56 )
57
58
59
d69f7f42
DB
60 # append an app list module for "Configuration"
61 self.children.append(modules.AppList(
62 _('Configuration'),
63 models=(
fc4bf968
EMS
64 'project.rh.models.Classement',
65 'project.rh.models.Devise',
66 'project.rh.models.CategorieEmploi',
321fe481 67 'project.rh.models.FamilleProfessionnelle',
fc4bf968
EMS
68 'project.rh.models.OrganismeBstg',
69 'project.rh.models.Responsable',
70 'project.rh.models.Service',
71 'project.rh.models.Statut',
72 'project.rh.models.TauxChange',
73 'project.rh.models.TypeContrat',
74 'project.rh.models.TypePoste',
75 'project.rh.models.TypeRevalorisation',
76 'project.rh.models.TypeRemuneration',
77 'project.rh.models.ValeurPoint',
56fdab08 78 ),
8846b99e
OL
79 exclude=('django.contrib.*',),
80 ))
81
d69f7f42
DB
82 # append an app list module for "Inter-systèmes"
83 self.children.append(modules.AppList(
84 _(u'Inter-systèmes'),
85 models=(
6fb68b2f 86 'project.rh.models.ResponsableImplantationProxy',
d69f7f42
DB
87 ),
88 ))
89
8846b99e
OL
90 # append an app list module for "Administration"
91 self.children.append(modules.AppList(
92 _('Administration'),
d69f7f42 93 models=(
fc4bf968 94 'django.contrib.*',
d69f7f42 95 ),
8846b99e
OL
96 ))
97
7f43054e
PP
98class CustomAppIndexDashboard(AppIndexDashboard):
99 """
100 Custom app index dashboard for project.
101 """
102
103 # we disable title because its redundant with the model list module
104 title = ''
105
106 def __init__(self, *args, **kwargs):
107 AppIndexDashboard.__init__(self, *args, **kwargs)
108
109 def init_with_context(self, context):
110 """
111 Use this method if you need to access the request context.
112 """
113 if self.app_title != 'Rh':
114 # append a model list module and a recent actions module
115 self.children += [
fc4bf968 116 modules.ModelList(self.app_title, self.models),
7f43054e
PP
117 ]
118
119 return
120
121 # append an app list module for "Application"
122 self.children.append(modules.AppList(
123 _('Application'),
124 models=(
fc4bf968
EMS
125 'project.rh.models.AyantDroit',
126 'project.rh.models.Dossier',
127 'project.rh.models.DossierInactif',
128 'project.rh.models.Employe',
129 'project.rh.models.EmployeInactif',
130 'project.rh.models.Poste',
7f43054e
PP
131 ),
132 ))
133
134 # append an app list module for "Configuration"
135 self.children.append(modules.AppList(
136 _('Configuration'),
137 models=(
fc4bf968
EMS
138 'project.rh.models.Classement',
139 'project.rh.models.Devise',
140 'project.rh.models.CategorieEmploi',
321fe481 141 'project.rh.models.FamilleProfessionnelle',
fc4bf968
EMS
142 'project.rh.models.OrganismeBstg',
143 'project.rh.models.Responsable',
144 'project.rh.models.Service',
145 'project.rh.models.Statut',
146 'project.rh.models.TauxChange',
147 'project.rh.models.TypeContrat',
148 'project.rh.models.TypePoste',
149 'project.rh.models.TypeRevalorisation',
150 'project.rh.models.TypeRemuneration',
151 'project.rh.models.ValeurPoint',
7f43054e
PP
152 ),
153 ))
154
155 # append an app list module for "Inter-systèmes"
156 self.children.append(modules.AppList(
157 _(u'Inter-systèmes'),
158 models=(
fc4bf968 159 'project.rh.models.ResponsableImplantation',
7f43054e
PP
160 ),
161 ))