fix creation date
[auf_rh_dae.git] / project / menu.py
CommitLineData
e2c0b1ac
PP
1# -*- coding: utf-8 -*-
2
6f38ca31
PP
3"""
4This file was generated with the custommenu management command, it contains
5the classes for the admin menu, you can customize this class as you want.
6
7To activate your custom menu add the following to your settings.py::
8 ADMIN_TOOLS_MENU = 'project.menu.CustomMenu'
9"""
10
11from django.core.urlresolvers import reverse
12from django.utils.translation import ugettext_lazy as _
13
14from admin_tools.menu import items, Menu
018c8eaf
DB
15
16from project.decorators import in_drh_or_admin
82c5e37d
DB
17from project import groups
18
6f38ca31 19
fb4ded65 20
6f38ca31
PP
21class CustomMenu(Menu):
22 """
23 Custom Menu for project admin site.
24 """
fb4ded65 25
6f38ca31
PP
26 def __init__(self, **kwargs):
27 Menu.__init__(self, **kwargs)
28 self.children += [
29 items.MenuItem(_('Dashboard'), reverse('admin:index')),
d53e80f7 30 #items.Bookmarks(),
83ebc284
PP
31 #items.AppList(
32 # _('Applications'),
33 # exclude=('django.contrib.*', 'project.rh.models.EmployeProxy')
34 #),
6f38ca31
PP
35 items.AppList(
36 _('Administration'),
fb4ded65 37 models=('django.contrib.*',))]
6f38ca31
PP
38
39 def init_with_context(self, context):
40 """
41 Use this method if you need to access the request context.
42 """
595ad88d 43 request = context['request']
fb4ded65
OL
44
45 if request.user.is_superuser:
46 self.children += [
47 items.MenuItem('DAE', reverse('admin:app_list',
48 kwargs={'app_label': 'dae'})),
49 ]
50
3383b2d1 51 user_groups = [g.name for g in request.user.groups.all()]
f96ec25c 52 if in_drh_or_admin(request.user) or\
3383b2d1
OL
53 groups.CORRESPONDANT_RH in user_groups or\
54 groups.ADMINISTRATEURS in user_groups or\
55 groups.DIRECTEUR_DE_BUREAU in user_groups:
595ad88d
OL
56 self.children += [
57 items.MenuItem('Rapports',
fb4ded65
OL
58 children=[
59 #items.MenuItem('Rapport des postes',
60 # reverse('rhr_postes')),
61 items.MenuItem('Rapport des contrats',
62 reverse('rhr_contrats')),
63 items.MenuItem(u'Rapport des employés sans contrat',
64 reverse('rhr_employe_sans_contrat')),
65 #items.MenuItem('Rapport de rémunération',
66 # reverse('rhr_remuneration')),
67
68 # A corriger
69 #items.MenuItem('Rapport des postes par service',
70 # reverse('rhr_postes_service')),
71 #items.MenuItem('Rapport des postes par implantation',
72 # reverse('rhr_postes_implantation')),
73
74 #items.MenuItem('Modelisation des postes',
75 # reverse('rhr_postes_modelisation')),
76 #items.MenuItem('Rapport hiérarchique des postes',
77 # reverse('rhr_postes_hierarchie')),
78 items.MenuItem('Rapport de masse salariale',
79 reverse('rhr_masse_salariale')),
8e26a99b
OL
80 items.MenuItem('Rapport des modifications',
81 reverse('rhr_historique_des_modifications')),
fb4ded65 82 ]),
fdfa21cc 83
08faf06e
JPC
84 items.MenuItem('Organigrammes',
85 children=[
fb4ded65
OL
86 items.MenuItem('Organigramme par employé',
87 reverse('admin:rh_employeproxy_changelist')),
88 items.MenuItem('Organigramme par service',
89 reverse('admin:rh_serviceproxy_changelist')),
90 items.MenuItem('Organigramme par implantation',
91 reverse('admin:rh_implantationproxy_changelist')),
92 items.MenuItem('Organigramme par bureau',
93 reverse('admin:rh_regionproxy_changelist')),
94 ]),
337c42e0
PP
95 items.MenuItem('Requêtes',
96 children=[
fb4ded65
OL
97 items.MenuItem('Requêtes sauvegardées',
98 reverse('admin:django_qbe_savedquery_changelist')),
99 items.MenuItem('Constructeur de requêtes',
100 reverse('qbe_form')),
101 ]),
595ad88d
OL
102 ]
103 super(CustomMenu, self).init_with_context(context)