Skip to content

Commit

Permalink
fixes alphabet filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
actlikewill committed Jul 29, 2024
1 parent 04c094b commit ca86db3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions peachjam/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class BaseDocumentFilterForm(forms.Form):
"""

years = PermissiveTypedListField(coerce=int, required=False)
alphabet = PermissiveTypedListField(required=False)
alphabet = forms.CharField(required=False)
authors = PermissiveTypedListField(coerce=remove_nulls, required=False)
doc_type = PermissiveTypedListField(coerce=remove_nulls, required=False)
judges = PermissiveTypedListField(coerce=remove_nulls, required=False)
Expand Down Expand Up @@ -140,7 +140,7 @@ def __init__(self, defaults, data, *args, **kwargs):

def filter_queryset(self, queryset, exclude=None, filter_q=False):
years = self.cleaned_data.get("years", [])
alphabet = self.cleaned_data.get("alphabet", [])
alphabet = self.cleaned_data.get("alphabet")
authors = self.cleaned_data.get("authors", [])
courts = self.cleaned_data.get("courts", [])
doc_type = self.cleaned_data.get("doc_type", [])
Expand All @@ -159,7 +159,7 @@ def filter_queryset(self, queryset, exclude=None, filter_q=False):
queryset = queryset.filter(date__year__in=years)

if alphabet and exclude != "alphabet":
queryset = queryset.filter(title__istartswith=alphabet[0])
queryset = queryset.filter(title__istartswith=alphabet)

if authors and exclude != "authors":
queryset = queryset.filter(authors__name__in=authors)
Expand Down

0 comments on commit ca86db3

Please sign in to comment.