Merge branch 'hotfix/employe_anterieur_fix_form_val_fix' into dev
authorBenoit C. Sirois <benoit.clennett-sirois@auf.org>
Tue, 16 Apr 2013 19:09:56 +0000 (15:09 -0400)
committerBenoit C. Sirois <benoit.clennett-sirois@auf.org>
Tue, 16 Apr 2013 19:09:56 +0000 (15:09 -0400)
project/assets/js/remun.js
project/dae/forms.py
project/dae/views.py

index c0fd635..27ae64e 100644 (file)
@@ -30,6 +30,7 @@ function ajouterLigne(addLnk) {
     if (formCount == null) {
        formCount = addLnk.closest('table').find('.remunform').length;
     }
+    var f_counter = addLnk.closest('table').prevAll('input[id$="TOTAL_FORMS"]');
     var prev = addLnk.parent('td').parent('tr').prev('tr');
     var copyOfLastInGroup = prev.clone();
     copyOfLastInGroup.find('input, select, td.cumulable').each(function(i, e){
@@ -46,6 +47,7 @@ function ajouterLigne(addLnk) {
        remun_totaux();
     });
     formCount++;
+    f_counter.val(formCount);
 }
 
 
index 841025e..3b432a7 100644 (file)
@@ -6,6 +6,7 @@ from dateutil.relativedelta import relativedelta
 from django import forms
 from django.core.urlresolvers import reverse
 from django.core.exceptions import MultipleObjectsReturned
+from django.forms.formsets import TOTAL_FORM_COUNT
 from django.forms.models import BaseInlineFormSet
 from django.forms.models import (
     inlineformset_factory,
@@ -360,6 +361,15 @@ class ReadOnlyRemunForm(FlexibleRemunForm):
 
 class GroupedInlineFormset(BaseInlineFormSet):
 
+    def total_form_count(self):
+        """Returns the total number of forms in this FormSet."""
+        if self.is_bound:
+            return self.management_form.cleaned_data[TOTAL_FORM_COUNT]
+        else:
+            return len(self.forms)
+        print total_forms
+        return total_forms
+
     def set_groups(self,
                    groups,
                    group_accessor,
@@ -774,6 +784,7 @@ class DossierForm(
         ),
     forms.ModelForm):
     """ Formulaire des dossiers. """
+
     class Meta:
         exclude = ('etat', 'employe', 'poste', 'date_debut',)
         model = dae.Dossier
index f9711d0..e61776a 100644 (file)
@@ -595,6 +595,12 @@ def embauche(request, key=None, dossier_id=None):
     for cmp_form in comparaisons_formset.forms:
         cmp_form.fields['implantation'].queryset = imp_qs
 
+    if dossier and dossier.poste:
+        dossier_form.fields['employe_anterieur'].queryset = (
+            dossier_form.fields['employe_anterieur'].queryset.filter(
+                rh_dossiers__poste=dossier.poste,
+                ).distinct()
+            )
 
     c = {
         'type_remun': filtered_type_remun(),