#2784
[auf_rh_dae.git] / project / rh / managers.py
index d9487b8..9d04f69 100644 (file)
@@ -1,8 +1,10 @@
 
 # -*- encoding: utf-8 -*-
 
 
 # -*- encoding: utf-8 -*-
 
+import datetime
 from django.db import models
 from django.db.models import Q
 from django.db import models
 from django.db.models import Q
+from auf.django.metadata.managers import NoDeleteManager
 from utils import get_employe_from_user
 from workflow import dae_groupes, \
                      grp_administrateurs, \
 from utils import get_employe_from_user
 from workflow import dae_groupes, \
                      grp_administrateurs, \
@@ -71,52 +73,68 @@ class SecurityManager(models.Manager):
         return liste
 
 
         return liste
 
 
-class PosteManager(SecurityManager):
+class PosteManager(SecurityManager, NoDeleteManager):
     """
     Chargement de tous les objets FK existants sur chaque QuerySet.
     """
     prefixe_service = "service"
     prefixe_implantation = "implantation__region"
 
     """
     Chargement de tous les objets FK existants sur chaque QuerySet.
     """
     prefixe_service = "service"
     prefixe_implantation = "implantation__region"
 
+    def actifs(self):
+        q_actif = Q(date_fin__gt=datetime.datetime.now()) | Q(date_fin__isnull=True)
+        return super(PosteManager, self).get_query_set().filter(q_actif)
+
     def ma_region_ou_service(self, user):
     def ma_region_ou_service(self, user):
-        return super(PosteManager, self).ma_region_ou_service(user).filter(actif=True)
+        return super(PosteManager, self).ma_region_ou_service(user)
 
     def get_query_set(self):
         fkeys = (
 
     def get_query_set(self):
         fkeys = (
-            'id_rh',
-            'responsable',
-            'implantation',
-            'implantation.bureau_rattachement',
+            #'id_rh',
+            #'responsable',
+            #'implantation',
+            #'implantation.bureau_rattachement',
             'type_poste',
             'type_poste',
-            'service',
-            'classement_min',
-            'classement_max',
-            'valeur_point_min',
-            'valeur_point_max',
+            #'service',
+            #'classement_min',
+            #'classement_max',
+            #'valeur_point_min',
+            #'valeur_point_max',
         )
         return super(PosteManager, self).get_query_set() \
                                         .select_related(*fkeys).all()
 
 
         )
         return super(PosteManager, self).get_query_set() \
                                         .select_related(*fkeys).all()
 
 
-class DossierManager(SecurityManager):
+class DossierManager(SecurityManager, NoDeleteManager):
     prefixe_service = "poste__service"
     prefixe_implantation = "poste__implantation__region"
 
     def get_query_set(self):
         fkeys = (
             'poste',
     prefixe_service = "poste__service"
     prefixe_implantation = "poste__implantation__region"
 
     def get_query_set(self):
         fkeys = (
             'poste',
+            'employe',
         )
         return super(DossierManager, self).get_query_set() \
                                         .select_related(*fkeys).all()
 
     def ma_region_ou_service(self, user):
         )
         return super(DossierManager, self).get_query_set() \
                                         .select_related(*fkeys).all()
 
     def ma_region_ou_service(self, user):
-        return super(DossierManager, self).ma_region_ou_service(user).filter(poste__actif=True)
+        return super(DossierManager, self).ma_region_ou_service(user)
 
 
 class PosteComparaisonManager(SecurityManager):
     use_for_related_fields = True
     prefixe_implantation = "implantation__region"
 
 
 
 class PosteComparaisonManager(SecurityManager):
     use_for_related_fields = True
     prefixe_implantation = "implantation__region"
 
+
 class DossierComparaisonManager(SecurityManager):
     use_for_related_fields = True
     prefixe_implantation = "implantation__region"
 class DossierComparaisonManager(SecurityManager):
     use_for_related_fields = True
     prefixe_implantation = "implantation__region"
+
+
+class DeviseManager(NoDeleteManager):
+    pass
+
+class ServiceManager(NoDeleteManager):
+    pass
+
+class TypeRemunerationManager(NoDeleteManager):
+    pass