feature complete.. now need a bit of testing
[auf_rh_dae.git] / project / dae / forms.py
index 56f9950..e9fa7c5 100644 (file)
@@ -2,6 +2,7 @@
 
 import datetime
 from ordereddict import OrderedDict
+from dateutil.relativedelta import relativedelta
 from django import forms
 from django.core.urlresolvers import reverse
 from django.core.exceptions import MultipleObjectsReturned
@@ -217,6 +218,10 @@ class DossierComparaisonForm(forms.ModelForm):
     poste = forms.CharField(
         max_length=255, widget=forms.TextInput(attrs={'size': '60'})
     )
+    cmp_dossier = forms.IntegerField(
+        widget=forms.widgets.HiddenInput,
+        required=False
+        )
 
     class Meta:
         model = dae.DossierComparaison
@@ -231,6 +236,11 @@ class PosteComparaisonForm(forms.ModelForm):
 
     recherche = AutoCompleteSelectField('dae_postes', required=False)
 
+    cmp_poste = forms.IntegerField(
+        widget=forms.widgets.HiddenInput,
+        required=False,
+        )
+
     class Meta:
         model = dae.PosteComparaison
         exclude = ('poste',)
@@ -467,7 +477,7 @@ def remun_formset_factory(parent_model,
     return FormSet
 
 
-def remun_formset_factory_factory(read_only=False):
+def remun_formset_factory_factory(read_only=False, parent_model=dae.Dossier, model=dae.Remuneration):
     """
     Don't we love factory factories?
     """
@@ -478,8 +488,8 @@ def remun_formset_factory_factory(read_only=False):
     form_class = ReadOnlyRemunForm if read_only else FlexibleRemunForm
 
     return remun_formset_factory(
-        dae.Dossier,
-        dae.Remuneration,
+        parent_model,
+        model,
         form=form_class,
         extra=extras,
         can_delete=can_delete,
@@ -530,8 +540,29 @@ def remun_formset_factory_factory(read_only=False):
             }
         )
 
-RemunForm = remun_formset_factory_factory(read_only=False)
-ReadOnlyRemunFormSet = remun_formset_factory_factory(read_only=True)
+RemunForm = remun_formset_factory_factory(
+    read_only=False,
+    parent_model=dae.Dossier,
+    model=dae.Remuneration,
+)
+
+ReadOnlyRemunFormSet = remun_formset_factory_factory(
+    read_only=True,
+    parent_model=dae.Dossier,
+    model=dae.Remuneration,
+    )
+
+PosteCompReadOnlyRemunFormSet = remun_formset_factory_factory(
+    read_only=True,
+    parent_model=dae.PosteComparaison,
+    model=dae.PosteComparaisonRemuneration,
+    )
+
+DossierCompReadOnlyRemunFormSet = remun_formset_factory_factory(
+    read_only=True,
+    parent_model=dae.DossierComparaison,
+    model=dae.DossierComparaisonRemuneration,
+    )
 
 
 class PosteForm(forms.ModelForm):