# -*- encoding: utf-8 -*-
+import datetime
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, \
if grp_drh in user.groups.all() or grp_drh2 in user.groups.all():
liste = self.get_query_set().all()
+ if user.is_superuser:
+ liste = self.get_query_set().all()
+
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"
+ 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):
- 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 = (
- 'id_rh',
- 'responsable',
- 'implantation',
- 'implantation.bureau_rattachement',
+ #'id_rh',
+ #'responsable',
+ #'implantation',
+ #'implantation.bureau_rattachement',
'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()
-class DossierManager(SecurityManager):
+class DossierManager(SecurityManager, NoDeleteManager):
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).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 DossierComparaisonManager(SecurityManager):
use_for_related_fields = True
prefixe_implantation = "implantation__region"
+
+
+class DeviseManager(NoDeleteManager):
+ pass
+
+class ServiceManager(NoDeleteManager):
+ pass
+
+class TypeRemunerationManager(NoDeleteManager):
+ pass