fix actif manager DAE
[auf_rh_dae.git] / project / rh / managers.py
index 4247d43..af71276 100644 (file)
@@ -1,6 +1,7 @@
 
 # -*- encoding: utf-8 -*-
 
 
 # -*- encoding: utf-8 -*-
 
+import datetime
 from django.db import models
 from django.db.models import Q
 from auf.django.metadata.managers import NoDeleteManager
 from django.db import models
 from django.db.models import Q
 from auf.django.metadata.managers import NoDeleteManager
@@ -79,8 +80,12 @@ class PosteManager(SecurityManager, NoDeleteManager):
     prefixe_service = "service"
     prefixe_implantation = "implantation__region"
 
     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 = (
@@ -112,13 +117,20 @@ class DossierManager(SecurityManager, NoDeleteManager):
                                         .select_related(*fkeys).all()
 
     def ma_region_ou_service(self, user):
                                         .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):
+
+    def get_query_set(self):
+        return super(DeviseManager, self).get_query_set().filter(archive=False)