Fix setup_election_config for combined election events

Most of the election tooling work on seperate events
of PTL and TC election. If election is combined then
setup_election_config generate the combined event(
for example 'TC & PTL Election') and it does not work
with those tools/scripts.

This fixes it and even for combined election it generates
the separate events. If we look at the election site, the
separate events are more clear for users.

Generated config looks like below:

Change-Id: I7d2e540dea9d89c832f6d9e3e9da743fe8d39295

---
release: 2023.2
election_type: combined
tag: mar-2023-elections
tc_seats: 4
timeframe:
  name: Zed-2023.1
  start: 2022-03-11T00:00
  end: 2023-02-15T00:00
  email_deadline: 2023-02-15T00:00
timeline:
- name: TC Nominations
  start: 2023-02-01T23:45
  end: 2023-02-15T23:45
- name: PTL Nominations
  start: 2023-02-01T23:45
  end: 2023-02-15T23:45
- name: TC Campaigning
  start: 2023-02-15T23:45
  end: 2023-02-22T23:45
- name: TC Election
  start: 2023-02-22T23:45
  end: 2023-03-08T23:45
- name: PTL Election
  start: 2023-02-22T23:45
  end: 2023-03-08T23:45

Change-Id: I5b1766d0fce9eb7ded000a7b582a8e4086314831
This commit is contained in:
Ghanshyam Mann 2023-03-03 15:09:09 -08:00
parent 61bc1d5bed
commit ecbdd0dbb9
1 changed files with 9 additions and 9 deletions

View File

@ -194,13 +194,11 @@ def main():
end = end.replace(hour=23, minute=45)
events = []
for event in params['events']:
e_types = [args.type]
if args.type == 'combined':
e_types = ['PTL', 'TC']
if event == 'Campaigning':
name = 'TC %s' % event
else:
name = 'TC & PTL %s' % event
else:
name = '%s %s' % (args.type, event)
e_types = ['TC']
start = end - TWO_WEEK
# For a TC or combined election we want the email deadline to match the
# beginning of the Campaigning period, which gives the officials time
@ -218,10 +216,12 @@ def main():
if event == 'Election':
schedule = utils.get_schedule_data(names[idx+1])
validate_tc_charter(args.type, schedule, start, end)
events.insert(0, OrderedDict(name=name,
start=iso_fmt(start),
end=iso_fmt(end)))
print('%s from %s to %s' % (name, iso_fmt(start), iso_fmt(end)))
for e_type in e_types:
name = '%s %s' % (e_type, event)
events.insert(0, OrderedDict(name=name,
start=iso_fmt(start),
end=iso_fmt(end)))
print('%s from %s to %s' % (name, iso_fmt(start), iso_fmt(end)))
end = start
print('Set email_deadline to %s' % (iso_fmt(email_deadline)))