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 admin_tools
.dashboard
import modules
, Dashboard
, AppIndexDashboard
16 from django
.utils
.translation
import ugettext_lazy
as _
17 from reversion
.models
import Revision
18 from project
.decorators
import in_drh_or_admin
19 from project
.rh
.historique
import format_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
= format_revisions(Revision
.objects
.order_by('-date_created')[:10])
47 if rev
['objet'] is None:
49 titre
= u
"[%s %s] %s %s" % (rev
['user'], rev
['date_created'],
50 rev
['objet'], rev
['comment'])
53 'url': rev
['history_url'],
56 self
.children
.append(modules
.LinkList(
57 title
='10 dernières modifications',
63 # append an app list module for "Configuration"
64 self
.children
.append(modules
.AppList(
67 'project.rh.models.Classement',
68 'project.rh.models.Devise',
69 'project.rh.models.CategorieEmploi',
70 'project.rh.models.FamilleProfessionnelle',
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',
82 exclude
=('django.contrib.*',),
85 # append an app list module for "Inter-systèmes"
86 self
.children
.append(modules
.AppList(
89 'project.rh.models.ResponsableImplantationProxy',
93 # append an app list module for "Administration"
94 self
.children
.append(modules
.AppList(
101 class CustomAppIndexDashboard(AppIndexDashboard
):
103 Custom app index dashboard for project.
106 # we disable title because its redundant with the model list module
109 def __init__(self
, *args
, **kwargs
):
110 AppIndexDashboard
.__init__(self
, *args
, **kwargs
)
112 def init_with_context(self
, context
):
114 Use this method if you need to access the request context.
116 if self
.app_title
!= 'Rh':
117 # append a model list module and a recent actions module
119 modules
.ModelList(self
.app_title
, self
.models
),
124 # append an app list module for "Application"
125 self
.children
.append(modules
.AppList(
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',
137 # append an app list module for "Configuration"
138 self
.children
.append(modules
.AppList(
141 'project.rh.models.Classement',
142 'project.rh.models.Devise',
143 'project.rh.models.CategorieEmploi',
144 'project.rh.models.FamilleProfessionnelle',
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',
158 # append an app list module for "Inter-systèmes"
159 self
.children
.append(modules
.AppList(
160 _(u
'Inter-systèmes'),
162 'project.rh.models.ResponsableImplantation',