register = Library()
+COMBLE_CHOICES = (('c', 'Comblé'), ('n', 'Non-comblé'))
+
+
+@register.inclusion_tag('admin/filter.html', takes_context=True)
+def filter_comble(context):
+ return {'title': 'comblé',
+ 'choices': prepare_choices(COMBLE_CHOICES, 'comble', context)}
+
+
@register.inclusion_tag('admin/filter_select.html', takes_context=True)
def filter_region(context):
return {'title': u"région",
lookup_params = dict(request.GET.items())
+ comble = 'all'
+
for key, value in lookup_params.items():
if not isinstance(key, str):
# 'key' will be used as a keyword argument later, so Python
del lookup_params[key]
lookup_params[smart_str(key)] = value
+ if key == 'comble':
+ comble = value
+ del lookup_params[key]
+
postes = rh.Poste.actifs.select_related('implantation').all()
postes = postes.filter(**lookup_params)
out = []
for p in postes:
+ employe = employes.get(p.id)
+
+ if comble == 'c' and not employe:
+ continue
+
+ if comble == 'n' and employe:
+ continue
+
line = {}
out.append(line)
line['id'] = p.id
line['nom'] = p.nom
line['implantation'] = p.implantation.nom
- employe = employes.get(p.id)
if employe:
line['employe_id'] = employe.id
line['employe_nom'] = employe.nom