From ea67a49433fe0ed4d2403e32b7a3f667cf22022c Mon Sep 17 00:00:00 2001 From: Beka Lewis Date: Wed, 16 Aug 2023 15:23:34 +0100 Subject: [PATCH] Filter out legacy parties --- wcivf/apps/parties/views.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/wcivf/apps/parties/views.py b/wcivf/apps/parties/views.py index 9c7cff219..f2706dd66 100644 --- a/wcivf/apps/parties/views.py +++ b/wcivf/apps/parties/views.py @@ -1,3 +1,4 @@ +from django.db.models import Q from django.views.generic import DetailView, TemplateView from .filters import PartyRegisterFilter @@ -6,10 +7,19 @@ class PartiesView(TemplateView): template_name = "parties/parties_view.html" + # "Parties" which are not EC registered but belong on the parties page + # e.g. Independent, Speaker seeking re-election + special_parties = ["ynmp-party:2", "ynmp-party:12522"] def get_context_data(self, *args, **kwargs): context = super(PartiesView, self).get_context_data(*args, **kwargs) - queryset = Party.objects.exclude(personpost=None).order_by("party_name") + queryset = ( + Party.objects.exclude(personpost=None) + .filter( + ~Q(ec_id__startswith="ynmp") | Q(ec_id__in=self.special_parties) + ) + .order_by("party_name") + ) f = PartyRegisterFilter( data=self.request.GET, queryset=queryset, request=self.request )