Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize person detail page #1117

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lametro/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ class Meta:
def slug_name(self):
return slugify(self.name)

@property
@cached_property
def latest_council_membership(self):
filter_kwarg = {
"organization__name": settings.OCD_CITY_COUNCIL_NAME,
Expand Down
4 changes: 2 additions & 2 deletions lametro/templates/person/person.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ <h4>
<div id='map-detail'></div>
{% endif %}

{% if person.headshot_source %}
{% if headshot_source %}
<p class='small'>
<i class='fa fa-fw fa-camera'></i> Credit: {{person.headshot_source}}
<i class='fa fa-fw fa-camera'></i> Credit: {{ headshot_source }}
</p>
{% endif %}

Expand Down
10 changes: 7 additions & 3 deletions lametro/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,13 +701,15 @@ def get_context_data(self, **kwargs):
except AttributeError:
context["map_geojson"] = None

if person.committee_sponsorships:
context["sponsored_legislation"] = person.committee_sponsorships
sponsored_legislation = list(person.committee_sponsorships.iterator())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful.

if sponsored_legislation:
context["sponsored_legislation"] = sponsored_legislation
else:
context["sponsored_legislation"] = []

context["memberships_list"] = (
person.current_memberships.exclude(organization__name="Board of Directors")
person.current_memberships.prefetch_related("organization")
.exclude(organization__name="Board of Directors")
.annotate(
index=Case(
When(role="Chair", then=Value(0)),
Expand All @@ -730,6 +732,8 @@ def get_context_data(self, **kwargs):
except PersonLink.DoesNotExist:
pass

context["headshot_source"] = person.headshot_source

return context


Expand Down
Loading