Done
[auf_rh_dae.git] / project / dae / templatetags / dae.py
index ebb0c2e..dd87a5d 100644 (file)
@@ -9,6 +9,7 @@ from project import groups
 
 from project.dae.workflow import ETATS_EDITABLE
 from project.dae.forms import (
+    remun_formset_factory_factory,
     ReadOnlyRemunFormSet,
     PosteCompReadOnlyRemunFormSet,
     DossierCompReadOnlyRemunFormSet,
@@ -102,6 +103,14 @@ def remun_form(context, dossier):
 
 
 @register.inclusion_tag('dae/embauche-remun.html', takes_context=True)
+def rh_remun_form(context, dossier):
+
+    return {
+        'remunForm': RHReadOnlyRemunFormSet(instance=dossier)
+        }
+
+
+@register.inclusion_tag('dae/embauche-remun.html', takes_context=True)
 def poste_cmp_remun_form(context, poste_cmp):
     return {
         'remunForm': PosteCompReadOnlyRemunFormSet(instance=poste_cmp)
@@ -113,3 +122,27 @@ def dossier_cmp_remun_form(context, dossier_cmp):
     return {
         'remunForm': DossierCompReadOnlyRemunFormSet(instance=dossier_cmp)
         }
+
+
+@register.inclusion_tag('dae/embauche-remun.html', takes_context=True)
+def rh_remun_form_for_year(context, dossier, year):
+
+    fs = remun_formset_factory_factory(
+        read_only=True,
+        parent_model=rh.Dossier,
+        model=rh.Remuneration,
+        )
+
+    def _get_qs(inst):
+        return inst.model.objects.filter(
+            dossier=inst.instance,
+            date_debut__year=year,
+            )
+        
+    fs.get_queryset = _get_qs
+
+    return {
+        'remunForm': fs(instance=dossier)
+        }
+
+