# HG changeset patch # User Sverre Rabbelier # Date 1239378352 0 # Node ID 5dd2091c8f0ca33f30c6bf7d8515364c9b2c6714 # Parent 57c74ce47fa37f72a896dc04aa9a9e6f345f87e7 Allow loading a previously saved slot allocation Patch by: Sverre Rabbelier diff -r 57c74ce47fa3 -r 5dd2091c8f0c app/soc/content/js/slot-allocator-090320.js --- a/app/soc/content/js/slot-allocator-090320.js Fri Apr 10 15:32:11 2009 +0000 +++ b/app/soc/content/js/slot-allocator-090320.js Fri Apr 10 15:45:52 2009 +0000 @@ -57,6 +57,11 @@  $.postJSON(url, current_slots, updateFromJSON); } +function load() { + url = RETURN_URL+"?load=1&_="+(new Date().getTime()) +  $.postJSON(url, current_slots, updateFromJSON); +} + function updateOverlay() { updateCurrentSlots(); var remaining_slots = MAX_AVAILABLE_SLOTS - current_allocated_slots; diff -r 57c74ce47fa3 -r 5dd2091c8f0c app/soc/templates/soc/program/allocation/allocation.html --- a/app/soc/templates/soc/program/allocation/allocation.html Fri Apr 10 15:32:11 2009 +0000 +++ b/app/soc/templates/soc/program/allocation/allocation.html Fri Apr 10 15:45:52 2009 +0000 @@ -20,6 +20,7 @@ + {{ block.super }} diff -r 57c74ce47fa3 -r 5dd2091c8f0c app/soc/views/models/program.py --- a/app/soc/views/models/program.py Fri Apr 10 15:32:11 2009 +0000 +++ b/app/soc/views/models/program.py Fri Apr 10 15:45:52 2009 +0000 @@ -299,8 +299,14 @@ if request.method == 'POST' and 'result' in request.POST: result = request.POST['result'] submit = request.GET.get('submit') + load = request.GET.get('load') + stored = program.slots_allocation + + if load and stored: + result = stored from_json = simplejson.loads(result) + locked_slots = dicts.groupDictBy(from_json, 'locked', 'slots') if submit: