DAE reactivation modfication de statut dans l admin pour superuser
authorOlivier Larchevêque <olivier.larcheveque@auf.org>
Tue, 26 Jun 2012 16:25:12 +0000 (12:25 -0400)
committerOlivier Larchevêque <olivier.larcheveque@auf.org>
Tue, 26 Jun 2012 16:25:12 +0000 (12:25 -0400)
project/dae/admin.py
project/dae/models.py
project/menu.py

index 32576e9..b8e3f5f 100644 (file)
@@ -7,7 +7,8 @@ from reversion.admin import VersionAdmin
 
 from auf.django.workflow.models import WorkflowCommentaire
 
-from project.dae.models import Poste, Dossier
+from project.dae.models import Poste, Dossier, ProxyDossierStatut, \
+        ProxyPosteStatut
 
 
 class BaseAdmin(admin.ModelAdmin):
@@ -39,20 +40,6 @@ class DossierAdmin(BaseAdmin, VersionAdmin):
         return obj.poste.implantation
 
 
-class ProxyDossierStatut(Dossier):
-    class Meta:
-        proxy = True
-        verbose_name = "Statut du dossier"
-        verbose_name_plural = "Statut des dossiers"
-
-
-class ProxyPosteStatut(Poste):
-    class Meta:
-        proxy = True
-        verbose_name = "Statut du poste"
-        verbose_name_plural = "Statut des postes"
-
-
 class StatutForm(forms.ModelForm):
     commentaire = forms.CharField(label="Commentaire",
             widget=forms.widgets.Textarea())
index 24823b1..9a0021e 100644 (file)
@@ -791,3 +791,19 @@ class Contrat(rh.Contrat_):
     dossier = models.ForeignKey(
         Dossier, db_column='dossier', related_name='dae_contrats'
     )
+
+
+class ProxyDossierStatut(Dossier):
+    class Meta:
+        proxy = True
+        verbose_name = "Statut du dossier"
+        verbose_name_plural = "Statut des dossiers"
+
+
+class ProxyPosteStatut(Poste):
+    class Meta:
+        proxy = True
+        verbose_name = "Statut du poste"
+        verbose_name_plural = "Statut des postes"
+
+
index f818fe4..2b83d25 100644 (file)
@@ -15,10 +15,12 @@ from admin_tools.menu import items, Menu
 
 from project.decorators import in_drh_or_admin
 
+
 class CustomMenu(Menu):
     """
     Custom Menu for project admin site.
     """
+
     def __init__(self, **kwargs):
         Menu.__init__(self, **kwargs)
         self.children += [
@@ -30,47 +32,64 @@ 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 request.user.is_superuser:
+            self.children += [
+                    items.MenuItem('DAE', reverse('admin:app_list',
+                        kwargs={'app_label': 'dae'})),
+                    ]
+
         if in_drh_or_admin(request.user):
             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=[
+                        #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')),
+
+                        # 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')),
+                        ]),
 
-                                   # 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)
-