Skip to content
This repository has been archived by the owner on Jan 28, 2020. It is now read-only.

move list of elections into a data structure in settings #354

Closed
mhl opened this issue Apr 28, 2015 · 2 comments
Closed

move list of elections into a data structure in settings #354

mhl opened this issue Apr 28, 2015 · 2 comments
Labels

Comments

@mhl
Copy link
Contributor

mhl commented Apr 28, 2015

At the moment the source hard-codes two elections, referred to consistently by the slugs "2010" and "2015". These also have metadata associated with them, e.g. the dates of those elections, and (less explicitly):

  • The default start and end dates of candidacies for those elections. Since it's very rare (in the UK anyway) to have a defined date for the start of a candidacies, and tracking changes with precise dates is similarly, we just use a start date for the candidacy as the day after the previous election.
  • For the UK, these are implicitly elections for posts with the role "Member of Parliament"
  • [... etc. probably others, which I'll come back to]

Instead, this should be a data structure in a country-specific settings.py which might look something like:

ELECTIONS = {
    'general-election-2010': {
        'for_post_label': 'Member of Parliament',
        'election_date': date(2010, 5, 6),   
        'candidacy_start_date': date(2005, 5, 6),
        'organization_id': 'commons',
    },
    'general-election-2015': {
        'for_post_label': 'Member of Parliament',
        'election_date': date(2015, 5, 7),
        'candidacy_start_date': date(2010, 5, 7),
        'organization_id': 'commons',
    }
}

... and then any code that refers to elections as "2010" or "2015" be updated to use the ELECTIONS setting instead.

@tmtmtmtm
Copy link

Would it make sense to have this at the PopIt/Popolo level? For example, these could be Events connected to[1] the Organisation and Term for which the election is happening.

This would then also make this data re-usable, from the same source, in consuming apps, rather than them needing to duplicate it themselves (this becomes more valuable when there are multiple parallel elections, rather than just a single general election).


[1] Until PopIt natively supports Events (mysociety/popit-api#142) these could simply be embedded on the Organization, similarly to how EveryPolitician is using legislative periods (see, for example https://inatsisartut.popit.mysociety.org/api/v0.1/organizations/legislature)

@mhl
Copy link
Contributor Author

mhl commented Jul 3, 2015

@tmtmtmtm I see what you're saying, but that would have added some complexity to the time-constrained development of YNR - I'll create a new, more specific, ticket for your suggestion so we can deal with that in the future, but close this one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants