Skip to content

Commit

Permalink
fix facet selection
Browse files Browse the repository at this point in the history
  • Loading branch information
fgregg committed Jan 6, 2024
1 parent ff2e5f7 commit 90281f6
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions chicago/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,15 @@ def _get_selected_facets(self):

for val in self.request.GET.getlist("selected_facets"):
if val:
# e.g., bill_type_exact:ordinance -> bill_type, ordinance
k, v = val.split("_exact:", 1)
k, v = val.split(":", 1)
k = remove_suffix(k, "_exact")
try:
selected_facets[k].append(v)
except KeyError:
selected_facets[k] = [v]

print(selected_facets)

return selected_facets

def _get_query_parameters(self):
Expand Down Expand Up @@ -422,7 +424,14 @@ def get_context_data(self, **kwargs):
] = person.latest_council_membership.end_date_dt.strftime("%B %d, %Y")

context["chair_positions"] = person.chair_role_memberships
context["sponsored_legislation"] = person.primary_sponsorships[:10]

context["sponsored_legislation"] = (
ChicagoBill.objects.filter(
sponsorships__person=person, sponsorships__primary=True
)
.annotate(last_action=Max("actions__date"))
.order_by("-last_action")[:10]
)

attendance = person.full_attendance
context["committee_count"] = len(person.current_memberships) - 1
Expand Down Expand Up @@ -701,3 +710,12 @@ def flush(request, flush_key):
@xframe_options_exempt
def pdfviewer(request):
return render(request, "pdfviewer.html")


def remove_suffix(string, suffix):

if string.endswith(suffix):
return string[: -len(suffix)]

else:
return string

0 comments on commit 90281f6

Please sign in to comment.