Changed a list of tuples so as to always make them sortable. Fixes an issue with bluesheet uploads for 'groups' like 'ietf' that could have multiple sessions starting at the same time.

- Legacy-Id: 18340
This commit is contained in:
Henrik Levkowetz 2020-08-06 11:32:46 +00:00
parent 57938b039d
commit 27eab28a31

View file

@ -3082,14 +3082,14 @@ def api_upload_bluesheet(request):
sessions = sessions.filter(group__acronym=acronym) sessions = sessions.filter(group__acronym=acronym)
if not sessions.exists(): if not sessions.exists():
return err(400, "No sessions found in meeting '%s' for group '%s'" % (number, acronym)) return err(400, "No sessions found in meeting '%s' for group '%s'" % (number, acronym))
session_times = [ (s.official_timeslotassignment().timeslot.time, s) for s in sessions if s.official_timeslotassignment() ] session_times = [ (s.official_timeslotassignment().timeslot.time, s.id, s) for s in sessions if s.official_timeslotassignment() ]
session_times.sort() session_times.sort()
item = request.POST.get('item') item = request.POST.get('item')
if not item.isdigit(): if not item.isdigit():
return err(400, "Expected a numeric value for 'item', found '%s'" % (item, )) return err(400, "Expected a numeric value for 'item', found '%s'" % (item, ))
n = int(item)-1 # change 1-based to 0-based n = int(item)-1 # change 1-based to 0-based
try: try:
time, session = session_times[n] time, __, session = session_times[n]
except IndexError: except IndexError:
return err(400, "No item '%s' found in list of sessions for group" % (item, )) return err(400, "No item '%s' found in list of sessions for group" % (item, ))
bjson = request.POST.get('bluesheet') bjson = request.POST.get('bluesheet')