Skip to content

Commit 8b6839d

Browse files
Merge pull request #1415 from learning-unlimited/two-phase-with-one-priority
Use the same API for the two-phase lottery even with a single priority
2 parents a23764f + cf2f48d commit 8b6839d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

esp/esp/program/modules/handlers/jsondatamodule.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,23 @@ def interested_classes(self, request, tl, one, two, module, extra, prog):
365365
@aux_call
366366
@json_response()
367367
@needs_student
368-
def lottery_preferences(self, request, tl, one, two, module, extra, prog):
368+
def lottery_preferences(self, request, tl, one, two, module, extra, prog):
369369
if prog.priorityLimit() > 1:
370370
return self.lottery_preferences_usepriority(request, prog)
371-
371+
else:
372+
# TODO: determine if anything still relies on the legacy format.
373+
# merge the legacy format with the current format, just in case
374+
sections = self.lottery_preferences_usepriority(request, prog)['sections']
375+
sections_legacy = self.lottery_preferences_legacy(request, prog)['sections']
376+
sections_merged = []
377+
for item, item_legacy in zip(sections, sections_legacy):
378+
assert item['id'] == item_legacy['id']
379+
item_merged = dict(item_legacy.items() + item.items())
380+
sections_merged.append(item_merged)
381+
return {'sections': sections_merged}
382+
383+
def lottery_preferences_legacy(self, request, prog):
384+
# DEPRECATED: see comments in lottery_preferences method
372385
sections = list(prog.sections().values('id'))
373386
sections_interested = StudentRegistration.valid_objects().filter(relationship__name='Interested', user=request.user, section__parent_class__parent_program=prog).select_related('section__id').values_list('section__id', flat=True).distinct()
374387
sections_priority = StudentRegistration.valid_objects().filter(relationship__name='Priority/1', user=request.user, section__parent_class__parent_program=prog).select_related('section__id').values_list('section__id', flat=True).distinct()

0 commit comments

Comments
 (0)