mysociety/yournextmp-popit — pull request #110 by symroe (2014-12-13 15:08:18+00:00)
Title: WIP: candidates counts

Work in progress, with commends from @mhl below:

* Couldn't you use get_or_create to simplify add_or_update?
https://docs.djangoproject.com/en/1.6/ref/models/querysets/#get-or-create

* We discussed updating the cached counts when people add or
remove candidates, and I might have seemed a bit uncertain
about this, but I think it's going to be worth it - we could
get away with running the cached_counts_create script rarely
then (unless there's a problem with from race conditions in
updating PopIt, manual edits in PopIt, etc. but let's hope
they're pretty rare).

* I'd probably write this:

if person['standing_in'] and '2015' in person['standing_in']\
and person['standing_in']['2015']:

... as:

if person.get('standing_in', {}).get('2015'):

* It might be nice to make the ordering ['-count', 'name']
since there are lots of consituencies with the same name

* A very minor thing: could you remove any trailing whitespace
that's introduced?