Commit d0daa705 authored by Nicolas Joyard's avatar Nicolas Joyard

Fix group filtering of reps

parent 014b48c4
......@@ -80,24 +80,24 @@ class RepresentativeList(RepresentativeViewMixin, generic.ListView):
if group_kind and group:
if group.isnumeric():
# Search group based on pk
qs = qs.filter(
models.Q(mandates__end_date__gte=today) |
models.Q(mandates__end_date__isnull=True),
mandates__group_id=int(group),
group_qs = Group.objects.filter(
id=int(group)
)
else:
# Search group based on abbreviation
group_qs = Group.objects.filter(
name=group,
kind=group_kind
)
if chamber:
group_qs = group_qs.filter(chamber__name=chamber)
qs = qs.filter(
models.Q(mandates__end_date__gte=today) |
models.Q(mandates__end_date__isnull=True),
mandates__group__name=group,
mandates__group__kind=group_kind,
mandates__group__in=group_qs
)
if chamber:
qs = qs.filter(mandates__group__chamber__name=chamber)
return qs
def get_queryset(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment