Skip to content

Commit

Permalink
Merge pull request #1678 from DemocracyClub/hotfix/ynmp-parties
Browse files Browse the repository at this point in the history
Filter out legacy parties
  • Loading branch information
Bekabyx authored Aug 17, 2023
2 parents 178a954 + ea67a49 commit e0ab901
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion wcivf/apps/parties/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.db.models import Q
from django.views.generic import DetailView, TemplateView

from .filters import PartyRegisterFilter
Expand All @@ -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
)
Expand Down

0 comments on commit e0ab901

Please sign in to comment.