Add 'combined' election support in setup-election-config

setup-election-config script is used to generate the
election dates. As we started doing the combined election
of PTL and TC, we need to add that type of election support
in this tool which will help to generate dates for any
type of election.

Below the is generated data will looks like:

release: yoga
election_type: combined
tag: oct-2021-elections
tc_seats: 4
timeframe:
  name: Wallaby-Xena
  start: 2020-09-25T00:00
  end: 2021-08-24T00:00
  email_deadline: 2021-08-24T00:00
timeline:
- name: TC & PTL Nominations
  start: 2021-08-17T23:45
  end: 2021-08-24T23:45
- name: TC Campaigning
  start: 2021-08-24T23:45
  end: 2021-08-31T23:45
- name: TC & PTL Election
  start: 2021-08-31T23:45
  end: 2021-09-07T23:45

Change-Id: Ib97f7ba794078ed78c9241dce7d40b3fc3519948
This commit is contained in:
Ghanshyam Mann 2021-07-20 17:40:05 -05:00
parent 6d6494721d
commit b75831be28
1 changed files with 18 additions and 7 deletions

View File

@ -33,6 +33,11 @@ election_parameters = {
'weeks_prior': 4,
'events': ['Election', 'Campaigning', 'Nominations', ],
},
'combined': {
'milestone': 'Release',
'weeks_prior': 4,
'events': ['Election', 'Campaigning', 'Nominations'],
},
}
@ -68,7 +73,7 @@ def main():
# repo so just get the date from the command line.
parser.add_argument('date', type=valid_date, help='in the form YYYY-MM-DD')
parser.add_argument('release', help='release name')
parser.add_argument('type', choices=['TC', 'PTL'])
parser.add_argument('type', choices=['TC', 'PTL', 'combined'])
parser.add_argument('--tc-seats', default=4, choices=['4', '5'],
help='number of TC seats up for election')
@ -115,16 +120,22 @@ def main():
end = end.replace(hour=23, minute=45)
events = []
for event in params['events']:
name = '%s %s' % (args.type, event)
if args.type == 'combined':
if event == 'Campaigning':
name = 'TC %s' % event
else:
name = 'TC & PTL %s' % event
else:
name = '%s %s' % (args.type, event)
start = end - ONE_WEEK
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 a TC election we want the email deadline to match the beginning
# of the Campaigning period, which gives the officials time to
# validate the rolls
if args.type == 'TC' and event == 'Campaigning':
# For a TC or combined election we want the email deadline to match the
# beginning of the Campaigning period, which gives the officials time
# to validate the rolls
if args.type in ['TC', 'combined'] and event == 'Campaigning':
email_deadline = start.replace(hour=0, minute=0)
# Otherise for a PTL election we want to set the email deadline to the
# begining of the Nomination period, agin to give officials time to
@ -177,7 +188,7 @@ def main():
print('Maximum: %s' % (datetime.timedelta(13*365/12)))
configuration = OrderedDict(
release=args.release,
release=args.release.lower(),
election_type=args.type.lower(),
tag=args.date.strftime('%b-%Y-elections').lower(),
tc_seats=int(args.tc_seats),