Commit d0daa705 authored by Nicolas Joyard's avatar Nicolas Joyard

Fix group filtering of reps

parent 014b48c4
...@@ -80,23 +80,23 @@ class RepresentativeList(RepresentativeViewMixin, generic.ListView): ...@@ -80,23 +80,23 @@ class RepresentativeList(RepresentativeViewMixin, generic.ListView):
if group_kind and group: if group_kind and group:
if group.isnumeric(): if group.isnumeric():
# Search group based on pk group_qs = Group.objects.filter(
qs = qs.filter( id=int(group)
models.Q(mandates__end_date__gte=today) |
models.Q(mandates__end_date__isnull=True),
mandates__group_id=int(group),
) )
else: else:
# Search group based on abbreviation group_qs = Group.objects.filter(
qs = qs.filter( name=group,
models.Q(mandates__end_date__gte=today) | kind=group_kind
models.Q(mandates__end_date__isnull=True),
mandates__group__name=group,
mandates__group__kind=group_kind,
) )
if chamber: if chamber:
qs = qs.filter(mandates__group__chamber__name=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__in=group_qs
)
return qs return qs
......
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