cacher le lien de rapport modif
[auf_rh_dae.git] / project / menu.py
index f818fe4..03e4c1a 100644 (file)
@@ -14,11 +14,15 @@ from django.utils.translation import ugettext_lazy as _
 from admin_tools.menu import items, Menu
 
 from project.decorators import in_drh_or_admin
+from project import groups
+
+
 
 class CustomMenu(Menu):
     """
     Custom Menu for project admin site.
     """
+
     def __init__(self, **kwargs):
         Menu.__init__(self, **kwargs)
         self.children += [
@@ -30,47 +34,59 @@ class CustomMenu(Menu):
             #),
             items.AppList(
                 _('Administration'),
-                models=('django.contrib.*',)
-            )
-        ]
+                models=('django.contrib.*',))]
 
     def init_with_context(self, context):
         """
         Use this method if you need to access the request context.
         """
         request = context['request']
-        if in_drh_or_admin(request.user):
+
+        if request.user.is_superuser:
+            self.children += [
+                    items.MenuItem('DAE', reverse('admin:app_list',
+                        kwargs={'app_label': 'dae'})),
+                    ]
+
+        user_groups = [g.name for g in request.user.groups.all()]
+        if in_drh_or_admin(request.user) or\
+           groups.CORRESPONDANT_RH in user_groups or\
+           groups.ADMINISTRATEURS in user_groups or\
+           groups.DIRECTEUR_DE_BUREAU in user_groups:
+            rapports = [
+                        items.MenuItem('Rapport des contrats',
+                            reverse('rhr_contrats')),
+                        items.MenuItem(u'Rapport des employés sans contrat',
+                            reverse('rhr_employe_sans_contrat')),
+                        items.MenuItem('Rapport de masse salariale',
+                            reverse('rhr_masse_salariale')),
+                    ]
+            if in_drh_or_admin(request.user):
+                rapports.append(
+                        items.MenuItem('Rapport des modifications',
+                            reverse('rhr_historique_des_modifications')),
+                        )
             self.children += [
                 items.MenuItem('Rapports',
-                               children=[
-                                   #items.MenuItem('Rapport des postes', reverse('rhr_postes')),
-                                   items.MenuItem('Rapport des contrats', reverse('rhr_contrats')),
-                                   items.MenuItem(u'Rapport des employés sans contrat', reverse('rhr_employe_sans_contrat')),
-                                   #items.MenuItem('Rapport de rémunération', reverse('rhr_remuneration')),
+                    children=rapports),
 
-                                   # A corriger
-                                   #items.MenuItem('Rapport des postes par service', reverse('rhr_postes_service')),
-                                   #items.MenuItem('Rapport des postes par implantation', reverse('rhr_postes_implantation')),
-                                   
-                                   #items.MenuItem('Modelisation des postes', reverse('rhr_postes_modelisation')),
-                                   #items.MenuItem('Rapport hiérarchique des postes', reverse('rhr_postes_hierarchie')),
-                                   items.MenuItem('Rapport de masse salariale', reverse('rhr_masse_salariale')),
-                               ]
-                              ),
                 items.MenuItem('Organigrammes',
                     children=[
-                        items.MenuItem('Organigramme par employé', reverse('admin:rh_employeproxy_changelist')),
-                        items.MenuItem('Organigramme par service', reverse('admin:rh_serviceproxy_changelist')),
-                        items.MenuItem('Organigramme par implantation', reverse('admin:rh_implantationproxy_changelist')),
-                        items.MenuItem('Organigramme par bureau', reverse('admin:rh_regionproxy_changelist')),
-                        ]
-                    ),
+                        items.MenuItem('Organigramme par employé',
+                            reverse('admin:rh_employeproxy_changelist')),
+                        items.MenuItem('Organigramme par service',
+                            reverse('admin:rh_serviceproxy_changelist')),
+                        items.MenuItem('Organigramme par implantation',
+                            reverse('admin:rh_implantationproxy_changelist')),
+                        items.MenuItem('Organigramme par bureau',
+                            reverse('admin:rh_regionproxy_changelist')),
+                        ]),
                 items.MenuItem('Requêtes',
                     children=[
-                        items.MenuItem('Requêtes sauvegardées', reverse('admin:django_qbe_savedquery_changelist')),
-                        items.MenuItem('Constructeur de requêtes', reverse('qbe_form')),
-                        ]
-                    ),
+                        items.MenuItem('Requêtes sauvegardées',
+                            reverse('admin:django_qbe_savedquery_changelist')),
+                        items.MenuItem('Constructeur de requêtes',
+                            reverse('qbe_form')),
+                        ]),
             ]
         super(CustomMenu, self).init_with_context(context)
-