I have multiple tracker lists with different people tracked in each. However, when an e-mail update comes out, each vote record shows the votes for every person across all trackers. This leads to duplicated information and, in many cases (like the recent vote-a-rama), very long e-mails.
I think the code responsible is here:
|
def render_event(self, eventid, feeds): |
|
if feeds: |
|
from person.models import Person |
|
my_reps = set() |
|
for f in feeds: |
|
try: |
|
my_reps.add(Person.from_feed(f)) |
|
except ValueError: |
|
pass # not a person-related feed |
|
my_reps = sorted(my_reps, key = lambda p : p.sortname) |
|
else: |
|
my_reps = [] |
|
|
|
# fetch the whole vote and our summary, and keep it cached with this object |
|
# because in email updates this object is held in memory for the duration of |
|
# sending out all email updates |
|
if not hasattr(self, "_cached_event_data"): |
|
oursummary = self.get_summary() |
|
all_votes = { |
|
vv.person: vv.option |
|
for vv in |
|
self.voters.select_related('person', 'option') |
|
} |
|
self._cached_event_data = [oursummary, all_votes] |
|
else: |
|
oursummary, all_votes = self._cached_event_data |
|
|
|
return { |
|
"type": "Vote", |
|
"date": self.created, |
|
"title": self.question, |
|
"url": self.get_absolute_url(), |
|
"body_text_template": |
|
"""{{summary|safe}} |
|
{% for voter in voters %}{{voter.name|safe}}: {{voter.vote|safe}} |
|
{% endfor %} |
|
{% if oursummary %}{{oursummary.plain_text|truncatewords:120|safe}}{% endif %}""", |
|
"body_html_template": |
|
"""<p>{{summary}}</p> |
|
{% for voter in voters %} |
|
<p><a href="{{SITE_ROOT}}{{voter.url}}">{{voter.name}}</a>: {{voter.vote}}</p> |
|
{% endfor %} |
|
{% if oursummary %}{{oursummary.as_html|truncatewords_html:120|safe}}{% endif %} |
|
""", |
|
"context": { |
|
"summary": self.summary(), |
|
"oursummary": oursummary, |
|
"voters": |
|
[ |
|
{ "url": p.get_absolute_url(), "name": p.name_lastonly(), "vote": all_votes[p].value } |
|
for p in my_reps if p in all_votes |
|
] |
|
if feeds != None else [] |
|
}, |
|
"thumbnail_url": self.get_thumbnail_url(), |
|
"large_thumbnail_url": self.get_absolute_url() + "/card", |
|
} |
I have multiple tracker lists with different people tracked in each. However, when an e-mail update comes out, each vote record shows the votes for every person across all trackers. This leads to duplicated information and, in many cases (like the recent vote-a-rama), very long e-mails.
I think the code responsible is here:
govtrack.us-web/vote/models.py
Lines 362 to 418 in b99167c