Closed mhl closed 8 years ago
Feels like 0e9750b should be squashed into the previous commit.
Tiny comments that aren't all that important but otherwise this looks good.
Yay, thanks @mhl!
Looks like this will just group posts within the same election - is that correct and if so any plans to implement or support for further grouping at a higher level, eg so DC could group all this year's Mayoral elections, Local Authority elections, etc?
Sorry I missed the review on this.
One thing I'd like to add is that by-elections have two groupings in the election ID, like local.braintree.witham-south.2016-05-05
. This means the migration should look like this:
diff --git a/elections/uk/migrations/0003_adjust_roles_for_grouping.py b/elections/uk/migrations/0003_adjust_roles_for_grouping.py
index 027cce1..969f8d1 100644
--- a/elections/uk/migrations/0003_adjust_roles_for_grouping.py
+++ b/elections/uk/migrations/0003_adjust_roles_for_grouping.py
@@ -9,7 +9,7 @@ from django.db import migrations
def adjust_roles_for_grouping(apps, schema_editor):
Election = apps.get_model('elections', 'Election')
for election in Election.objects.all():
- if re.search(r'^local\.[^.]+\.2016', election.slug):
+ if re.search(r'^local\.[^.]+(\.[^.]+)?\.2016', election.slug):
election.for_post_role = 'Local Councillor'
election.save()
if re.search(r'^mayor\.[^.]+\.2016', election.slug):
Given that I expect this hasn't been run anywhere yet (and even if it had, there aren't any by-elections in the system yet), should we update this migration or should I make a new one?
@jf1 The level of grouping above election is the "role", which for Mayors will all be "Mayor", for local elections it'll be "Local Councillor", so this should do what you want as far as grouping goes. (The presentation is very basic still—just different levels of heading—but it's a good basis for a better version, e.g. hiding / showing who sections, or whatever.
These pages are so much easier to look at now, and each group's elections are sorted alphabetically too :)
Some way to hide/expand each group's elections would help, and even better if collapsed groups in /numbers could display the total number of candidates, posts and unlocked posts within each group.
I previously suggested a sortorder value so eg Mayoral and PCC could go above Locals, but if they were all collapsed on initial display (ie so all top-level groups could be seen without scrolling down) then it wouldn't be necessary - or beneficial - so leaving them in alphabetical order seems best.
ps @symroe there are several current by-elections and I haven't noticed any problems with them tonight.
This got rid of the {% empty %}
clause in reports.html
, so there's no longer a message below an empty current or past election list.
@symroe Feel free to modify the migration in this case
Oops, the {% empty %}
clause was restored later 52ff24317d7ffbeff6e772719b7a9198c46a2f6e - thanks, @wfdd
These commits change the following pages:
/numbers
/posts
/help/api
... so that elections and posts are groups by:
current=True
, thencurrent=False
for_post_role
(ordered alphabetically)When there are a lot of elections, this should make their structure more obvious. Grouping by
for_post_role
means that the elections representing constituency and regional elections in the Scottish Parliament Elections come together.This also adds a link to the all candidates CSV file, which was missing.
Fixes #863 Fixes #598