merge regio
authorOlivier Larchevêque <olivier.larcheveque@auf.org>
Thu, 27 Sep 2012 18:24:09 +0000 (14:24 -0400)
committerOlivier Larchevêque <olivier.larcheveque@auf.org>
Thu, 27 Sep 2012 18:24:09 +0000 (14:24 -0400)
1  2 
project/dae/catalogues.py
project/dae/forms.py
project/dae/views.py
project/rh/managers.py
project/rh/models.py
project/rh/views.py

Simple merge
@@@ -103,22 -97,19 +98,20 @@@ def _implantation_choices(obj, request)
  def _employe_choices(obj, request):
      # TRAITEMENT NORMAL
      employe = groups.get_employe_from_user(request.user)
-     # SERVICE
-     if groups.is_user_dans_services_centraux(request.user):
-         q_dae_region_service = Q(poste__implantation=employe.implantation)
-         q_rh_region_service = Q(poste__implantation=employe.implantation)
-     # REGION
-     else:
-         q_dae_region_service = Q(
-             poste__implantation__region=employe.implantation.region
+     q_dae_region_service = Q(
+         poste__implantation__zone_administrative=(
+             employe.implantation.zone_administrative
          )
-         q_rh_region_service = Q(
-             poste__implantation__region=employe.implantation.region
+     )
+     q_rh_region_service = Q(
+         poste__implantation__zone_administrative=(
+             employe.implantation.zone_administrative
          )
+     )
      # TRAITEMENT DRH
      user_groupes = [g.name for g in request.user.groups.all()]
 -    if groups.DRH_NIVEAU_1 in user_groupes:
 +    if groups.DRH_NIVEAU_1 in user_groupes or \
 +       groups.DRH_NIVEAU_2 in user_groupes:
          q_dae_region_service = Q()
          q_rh_region_service = Q()
  
Simple merge
@@@ -223,19 -177,9 +226,19 @@@ class EmployeManager(models.Manager)
          return self.get_query_set().actifs(*args, **kwargs)
  
  
 +class ContratQuerySet(ActifsQuerySet):
 +    pass
 +
 +class ContratManager(models.Manager):
 +
 +    def get_query_set(self):
 +        return ContratQuerySet(self.model)\
 +                .select_related('dossier', 'dossier__poste')
 +
 +
  class PosteComparaisonManager(SecurityManager):
      use_for_related_fields = True
-     prefixe_implantation = "implantation__region"
+     prefixe_implantation = "implantation__zone_administrative"
  
  
  class DossierComparaisonManager(SecurityManager):
Simple merge
@@@ -272,13 -276,8 +277,13 @@@ def rapports_masse_salariale(request)
                          'taux_change': 'rh_tauxchange.taux'
                      }
                  )
 +
 +        if len(remun_actives) != len(remuns):
 +            raise rh.RemunIntegrityException("Toutes les remunerations ne disposent pas d'un "
 +                "taux de change pour l'année %d" % annee)
 +
-         if region:
-             remuns = remuns.filter(dossier__poste__implantation__region=region)
+         if zone_administrative:
+             remuns = remuns.filter(dossier__poste__implantation__zone_administrative=zone_administrative)
          if implantation:
              remuns = remuns.filter(dossier__poste__implantation=implantation)
          remuns_par_dossier = defaultdict(list)