5696
authorBenoit C. Sirois <benoit.clennett-sirois@auf.org>
Tue, 5 Mar 2013 21:28:05 +0000 (16:28 -0500)
committerBenoit C. Sirois <benoit.clennett-sirois@auf.org>
Tue, 5 Mar 2013 21:28:05 +0000 (16:28 -0500)
project/dae/forms.py

index 3c777a5..4302bc4 100644 (file)
@@ -479,7 +479,11 @@ def remun_formset_factory(parent_model,
     return FormSet
 
 
-def remun_formset_factory_factory(read_only=False, parent_model=dae.Dossier, model=dae.Remuneration):
+def remun_formset_factory_factory(
+    read_only=False,
+    parent_model=dae.Dossier,
+    model=dae.Remuneration,
+    exclude_archived=False):
     """
     Don't we love factory factories?
     """
@@ -489,6 +493,13 @@ def remun_formset_factory_factory(read_only=False, parent_model=dae.Dossier, mod
     can_delete = False if read_only else True
     form_class = ReadOnlyRemunForm if read_only else FlexibleRemunForm
 
+    choice_override_extra_q = {}
+
+    if exclude_archived:
+        choice_override_extra_q.update({
+            'archive': False
+            })
+    
     return remun_formset_factory(
         parent_model,
         model,
@@ -501,45 +512,51 @@ def remun_formset_factory_factory(read_only=False, parent_model=dae.Dossier, mod
             u'Traitement': {
                 'type': [null_choice] + list(
                     rh.TypeRemuneration.objects.filter(
-                        nature_remuneration=u'Traitement').values_list(
+                        nature_remuneration=u'Traitement',
+                        **choice_override_extra_q).values_list(
                         'id', 'nom')
                     )
                 },
             u'Indemnité': {
                 'type': [null_choice] + list(
                     rh.TypeRemuneration.objects.filter(
-                        nature_remuneration=u'Indemnité').values_list(
+                        nature_remuneration=u'Indemnité',
+                        **choice_override_extra_q).values_list(
                         'id', 'nom')
                     )
                 },
             u'Charges': {
                 'type': [null_choice] + list(
                     rh.TypeRemuneration.objects.filter(
-                        nature_remuneration=u'Charges').values_list(
+                        nature_remuneration=u'Charges',
+                        **choice_override_extra_q).values_list(
                         'id', 'nom')
                     )
                 },
             u'Accessoire': {
                 'type': [null_choice] + list(
                     rh.TypeRemuneration.objects.filter(
-                        nature_remuneration=u'Accessoire').values_list(
+                        nature_remuneration=u'Accessoire',
+                        **choice_override_extra_q).values_list(
                         'id', 'nom')
                     )
                 },
             u'RAS': {
                 'type': [null_choice] + list(
                     rh.TypeRemuneration.objects.filter(
-                        nature_remuneration=u'RAS').values_list(
+                        nature_remuneration=u'RAS',
+                        **choice_override_extra_q).values_list(
                         'id', 'nom')
                     )
                 },
-            }
+            },
         )
 
 RemunForm = remun_formset_factory_factory(
     read_only=False,
     parent_model=dae.Dossier,
     model=dae.Remuneration,
+    exclude_archived=True,
 )
 
 ReadOnlyRemunFormSet = remun_formset_factory_factory(