fix group machinerie
[auf_rh_dae.git] / project / menu.py
1 # -*- coding: utf-8 -*-
2
3 """
4 This file was generated with the custommenu management command, it contains
5 the classes for the admin menu, you can customize this class as you want.
6
7 To activate your custom menu add the following to your settings.py::
8 ADMIN_TOOLS_MENU = 'project.menu.CustomMenu'
9 """
10
11 from django.core.urlresolvers import reverse
12 from django.utils.translation import ugettext_lazy as _
13
14 from admin_tools.menu import items, Menu
15
16 from project.decorators import in_drh_or_admin
17 from project import groups
18
19
20
21 class CustomMenu(Menu):
22 """
23 Custom Menu for project admin site.
24 """
25
26 def __init__(self, **kwargs):
27 Menu.__init__(self, **kwargs)
28 self.children += [
29 items.MenuItem(_('Dashboard'), reverse('admin:index')),
30 #items.Bookmarks(),
31 #items.AppList(
32 # _('Applications'),
33 # exclude=('django.contrib.*', 'project.rh.models.EmployeProxy')
34 #),
35 items.AppList(
36 _('Administration'),
37 models=('django.contrib.*',))]
38
39 def init_with_context(self, context):
40 """
41 Use this method if you need to access the request context.
42 """
43 request = context['request']
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
51 user_groups = [g.name for g in request.user.groups.all()]
52 if in_drh_or_admin(request.user) or\
53 groups.CORRESPONDANT_RH in user_groups or\
54 groups.ADMINISTRATEURS in user_groups or\
55 groups.DIRECTEUR_DE_BUREAU in user_groups:
56 self.children += [
57 items.MenuItem('Rapports',
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')),
80 items.MenuItem('Rapport des modifications',
81 reverse('rhr_historique_des_modifications')),
82 ]),
83
84 items.MenuItem('Organigrammes',
85 children=[
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 ]),
95 items.MenuItem('Requêtes',
96 children=[
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 ]),
102 ]
103 super(CustomMenu, self).init_with_context(context)