justification embauche
[auf_rh_dae.git] / project / dae / views.py
index 3f92f0d..4ad6b3f 100644 (file)
@@ -159,11 +159,17 @@ def embauche(request, key=None, dossier=None):
                     dossier = get_object_or_404(dae.Dossier, pk=dossier)
                 dossier_form = DossierForm(request.POST, instance=dossier)
                 piecesForm = DossierPieceForm(request.POST, request.FILES, instance=dossier)
+                justificationsNouveauForm = JustificationNouvelEmployeForm(request.POST, instance=dossier)
+                justificationsAutreForm = JustificationAutreEmployeForm(request.POST, instance=dossier)
 
-                if dossier_form.is_valid() and piecesForm.is_valid():
+                if dossier_form.is_valid() and piecesForm.is_valid() and justificationsNouveauForm.is_valid() and justificationsAutreForm.is_valid():
                     dossier = dossier_form.save()
                     piecesForm.instance = dossier
                     piecesForm.save()
+                    justificationsNouveauForm.instance = dossier
+                    justificationsNouveauForm.save()
+                    justificationsAutreForm.instance = dossier
+                    justificationsAutreForm.save()
                     if not dossier.remuneration_set.all():
                         # Pré-peuplement des entrées de la section "coût
                         # global", à l'exclusion de "Indemnité de fonction"
@@ -198,6 +204,8 @@ def embauche(request, key=None, dossier=None):
             else:
                 dossier_form = DossierForm(instance=dossier)
                 piecesForm = DossierPieceForm(instance=dossier)
+                justificationsNouveauForm = JustificationNouvelEmployeForm(instance=dossier)
+                justificationsAutreForm = JustificationAutreEmployeForm(instance=dossier)
         else:
             # Initialisation d'un formulaire vide
             dossier_rh = rh.Dossier()
@@ -213,9 +221,17 @@ def embauche(request, key=None, dossier=None):
 
             dossier_form = DossierForm(instance=dossier)
             piecesForm = DossierPieceForm(instance=dossier)
-
-        vars = dict(step='employe', poste=poste, dossier=dossier, piecesForm=piecesForm,
-                    forms=dict(employe=employe_form, dossier=dossier_form, ))
+            justificationsNouveauForm = JustificationNouvelEmployeForm(instance=dossier)
+            justificationsAutreForm = JustificationAutreEmployeForm(instance=dossier)
+
+        vars = dict(step='employe',
+                poste=poste,
+                dossier=dossier,
+                piecesForm=piecesForm,
+                justificationsNouveauForm=justificationsNouveauForm,
+                justificationsAutreForm=justificationsAutreForm,
+                forms=dict(employe=employe_form, dossier=dossier_form, )
+                )
 
     return render_to_response('dae/embauche.html', vars,
                               RequestContext(request))