fix candidat
[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:
aa66aa1e 56 rapports = [
fb4ded65
OL
57 items.MenuItem('Rapport des contrats',
58 reverse('rhr_contrats')),
59 items.MenuItem(u'Rapport des employés sans contrat',
60 reverse('rhr_employe_sans_contrat')),
fb4ded65
OL
61 items.MenuItem('Rapport de masse salariale',
62 reverse('rhr_masse_salariale')),
aa66aa1e
OL
63 ]
64 if in_drh_or_admin(request.user):
65 rapports.append(
8e26a99b
OL
66 items.MenuItem('Rapport des modifications',
67 reverse('rhr_historique_des_modifications')),
aa66aa1e
OL
68 )
69 self.children += [
70 items.MenuItem('Rapports',
71 children=rapports),
fdfa21cc 72
08faf06e
JPC
73 items.MenuItem('Organigrammes',
74 children=[
fb4ded65
OL
75 items.MenuItem('Organigramme par employé',
76 reverse('admin:rh_employeproxy_changelist')),
77 items.MenuItem('Organigramme par service',
78 reverse('admin:rh_serviceproxy_changelist')),
79 items.MenuItem('Organigramme par implantation',
80 reverse('admin:rh_implantationproxy_changelist')),
81 items.MenuItem('Organigramme par bureau',
82 reverse('admin:rh_regionproxy_changelist')),
83 ]),
337c42e0
PP
84 items.MenuItem('Requêtes',
85 children=[
fb4ded65
OL
86 items.MenuItem('Requêtes sauvegardées',
87 reverse('admin:django_qbe_savedquery_changelist')),
88 items.MenuItem('Constructeur de requêtes',
89 reverse('qbe_form')),
90 ]),
595ad88d
OL
91 ]
92 super(CustomMenu, self).init_with_context(context)