Skip to content

Commit

Permalink
Merge branch 'main' into deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
fgregg committed Jan 6, 2024
2 parents 341049a + 96af9e1 commit 48ae373
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
8 changes: 3 additions & 5 deletions chicago/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.urls import reverse, reverse_lazy
from django.conf import settings

from .models import Person, Bill, Organization, Event
from .models import ChicagoPerson, Bill, Organization, Event
from .utils import to_datetime


Expand Down Expand Up @@ -107,7 +107,7 @@ class PersonDetailFeed(Feed):
NUM_RECENT_BILLS = 20

def get_object(self, request, slug):
o = Person.objects.get(slug=slug)
o = ChicagoPerson.objects.get(slug=slug)
return o

def title(self, obj):
Expand All @@ -132,9 +132,7 @@ def description(self, obj):
return "Recent sponsored bills from " + obj.name + "."

def items(self, person):
sponsored_bills = [s.bill for s in person.primary_sponsorships][:10]
recent_sponsored_bills = sponsored_bills[: self.NUM_RECENT_BILLS]
return recent_sponsored_bills
return person.primary_sponsorships[: self.NUM_RECENT_BILLS]


class CommitteeDetailEventsFeed(Feed):
Expand Down
10 changes: 10 additions & 0 deletions chicago/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,16 @@ def years_in_office(self):
else:
return years

@property
def primary_sponsorships(self):
return (
ChicagoBill.objects.filter(
sponsorships__person=self, sponsorships__primary=True
)
.annotate(last_action=models.Max("actions__date"))
.order_by("-last_action")
)


class ChicagoPersonStatistic(models.Model):
person = models.OneToOneField(
Expand Down
9 changes: 1 addition & 8 deletions chicago/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,14 +422,7 @@ 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"] = (
ChicagoBill.objects.filter(
sponsorships__person=person, sponsorships__primary=True
)
.annotate(last_action=Max("actions__date"))
.order_by("-last_action")[:10]
)
context["sponsored_legislation"] = person.primary_sponsorships[:10]

attendance = person.full_attendance
context["committee_count"] = len(person.current_memberships) - 1
Expand Down

0 comments on commit 48ae373

Please sign in to comment.