Merge branch 'hotfix/dae_error_500' into dev
authorBenoit C. Sirois <benoit.clennett-sirois@auf.org>
Wed, 10 Apr 2013 17:55:57 +0000 (13:55 -0400)
committerBenoit C. Sirois <benoit.clennett-sirois@auf.org>
Wed, 10 Apr 2013 17:55:57 +0000 (13:55 -0400)
project/dae/views.py

index aebd7d6..b8a0149 100644 (file)
@@ -225,8 +225,14 @@ def poste(request, key=None):
             for comparaison in zip(
                 comparaisons,
                 comparaisons_formset.forms):
-                dossier = rh.Dossier.objects.get(
-                    id=comparaison[1].cleaned_data['cmp_poste'])
+                cmp_dossier_id = comparaison[1].cleaned_data.get(
+                    'cmp_poste', None)
+                if not cmp_dossier_id:
+                    continue
+                cmp_dossier_qs = rh.Dossier.objects.filter(id=cmp_dossier_id)
+                if not cmp_dossier_qs.count() > 0:
+                    continue
+                dossier = rh.Dossier.objects.get(id=cmp_dossier_qs.get().id)
 
                 # Get all remunerations for a period of 1 year,
                 # going back from either: today (if dossier has not
@@ -500,8 +506,16 @@ def embauche(request, key=None, dossier_id=None):
             for comparaison in zip(
                 comparaisons,
                 comparaisons_formset.forms):
-                rhdossier = rh.Dossier.objects.get(
-                    id=comparaison[1].cleaned_data['cmp_dossier'])
+
+                cmp_dossier_id = comparaison[1].cleaned_data.get(
+                    'cmp_dossier', None)
+                if not cmp_dossier_id:
+                    continue
+                cmp_dossier_qs = rh.Dossier.objects.filter(id=cmp_dossier_id)
+                if not cmp_dossier_qs.count() > 0:
+                    continue
+                rhdossier = rh.Dossier.objects.get(id=cmp_dossier_qs.get().id)
+
 
                 # Get all remunerations for a period of 1 year,
                 # going back from either: today (if cdossier has not