add election timetable to schema#20
Conversation
| class Timetable(BaseModel): | ||
| notice_of_election_deadline: datetime.date = Field(default=None) | ||
| close_of_nominations: datetime.date = Field(default=None) | ||
| registration_deadline: datetime.date = Field(default=None) | ||
| postal_vote_application_deadline: datetime.date = Field(default=None) | ||
| vac_application_deadline: datetime.date = Field(default=None) |
There was a problem hiding this comment.
I've already added notice_of_election_deadline here on the basis there is an open PR for it.
Just to avoid having to do too much cross-repo faffing about, I'd like to also think about the other dates we plan to add in the near future. Lets talk about this one in surgery tomorrow. One of the useful things about them defaulting to None is that pydantic will tolerate missing properties. For example, the test object I've added in tests/test_models.py lacks a notice_of_election_deadline property but it still validates. This means we can map out the other stuff we think we're going to add soon once, release a version, and it will tolerate those properties being missing until we add them.
There was a problem hiding this comment.
Following discussion in surgery, the only other date we expect to add is sopn_publish_deadline so I've added that to the schema as well in 6a9a2ac
| def get_default_timetable( | ||
| ballot_paper_id: str, poll_date: str, requires_id: bool | ||
| ): | ||
| """ | ||
| Generate a plausible-ish fake timetable | ||
| ignoring a lot of complexity and nuance | ||
| """ |
There was a problem hiding this comment.
A few notes on this:
- The builder library currently doesn't support provisional/date-less elections. So given we must have a poll date for any ballot it seems reasonable to auto-populate a timetable from that.
- One option here would be to pull in the timetable library to generate the timetable. However, I decided to go with not doing that and just creating some dates that are in the right sort of ballpark-ish. This is broadly in line with what we do elsewhere in this library. If we need a test object with specific or tediously correct dates then we can use the
with_methods for each timetable event.
There was a problem hiding this comment.
The EC postcode pages relies on dates from the timetable library in it's mock responses. Let's make sure this works properly, and that they give sensible dates. We don't want EC people feeding back that the dates are wrong in that project (e.g it might say 'expect candidates after X date' but if X is made up here, that might be a problem). As you say, we can alter this when we make the mock data there, but let's make sure we're thinking about that case
There was a problem hiding this comment.
Do they use the mock responses?
I thought they were only dev-facing.
There was a problem hiding this comment.
Just to explain my thinking more here: There plenty of obvious holes you could pick in the test data we generate to model various scenarios. For example:
is clearly not right, but as a test fixture, it is good enough to make sure the page is doing the right thing.
As long as we can fiddle dates to some point before and after the SOPN date to see what the page looks like before and after, its doing the job as well as it needs to, right.
There was a problem hiding this comment.
If we can have number 10 in Manchester, we can have the Mayor of London in Stroud. It's not right, it's aspirational.
I guess we can talk about how they use those pages later, but the point of the site is to allow non-devs to see what the site looks like in various stages through an election. I guess if it becomes a problem we can always change how we make that data.
| if ballot_paper_id.startswith("ref."): | ||
| notice_of_election_deadline = None |
There was a problem hiding this comment.
TODO: change this if we change DemocracyClub/uk-election-timetables#61 (comment)
There was a problem hiding this comment.
Following discussion in surgery:
notice_of_election_deadline is not implemented for referenda in the timetables lib, but we would be able to/expect to manually populate it in EE.
So when building a fake object, it makes sense to set a value.
Have done that in 0d461d2
symroe
left a comment
There was a problem hiding this comment.
One comment about the EC postcode pages. Also, let's get the SOPN dates in from the other PR before merging this.
This PR adds code to validate the timetable property in API responses and generate fake objects with a timetable.
This is needed to finish DemocracyClub/aggregator-api#642 and then we'll also want it when we move on to consuming the data in projects that parse/validate the API response.