# HG changeset patch # User Sverre Rabbelier # Date 1239234341 0 # Node ID 5d55e61dd338e4ec9ba507c03a729bf55662c142 # Parent cafa4caec14ffa021104c125c9560f0c3bd20cc4 Add a submit method and button to slots view Patch by: Sverre Rabbelier diff -r cafa4caec14f -r 5d55e61dd338 app/soc/content/js/slot-allocator-090320.js --- a/app/soc/content/js/slot-allocator-090320.js Wed Apr 08 22:47:46 2009 +0000 +++ b/app/soc/content/js/slot-allocator-090320.js Wed Apr 08 23:45:41 2009 +0000 @@ -52,6 +52,11 @@  $.postJSON(url, current_slots, updateFromJSON); } +function submit() { + url = RETURN_URL+"?submit=1&_="+(new Date().getTime()) +  $.postJSON(url, current_slots, updateFromJSON); +} + function updateOverlay() { updateCurrentSlots(); var remaining_slots = MAX_AVAILABLE_SLOTS - current_allocated_slots; diff -r cafa4caec14f -r 5d55e61dd338 app/soc/templates/soc/program/allocation/allocation.html --- a/app/soc/templates/soc/program/allocation/allocation.html Wed Apr 08 22:47:46 2009 +0000 +++ b/app/soc/templates/soc/program/allocation/allocation.html Wed Apr 08 23:45:41 2009 +0000 @@ -19,6 +19,8 @@ {% block body %} + {{ block.super }} + {% endblock %} diff -r cafa4caec14f -r 5d55e61dd338 app/soc/views/models/program.py --- a/app/soc/views/models/program.py Wed Apr 08 22:47:46 2009 +0000 +++ b/app/soc/views/models/program.py Wed Apr 08 23:45:41 2009 +0000 @@ -298,9 +298,9 @@ if request.method == 'POST' and 'result' in request.POST: result = request.POST['result'] + submit = request.GET.get('submit') from_json = simplejson.loads(result) - locked_slots = dicts.groupDictBy(from_json, 'locked', 'slots') orgs = {} @@ -312,6 +312,16 @@ applications[org.link_id] = org.nr_applications max[org.link_id] = min(org.nr_mentors, org.slots_desired) + if submit: + org_post = from_json[org.link_id] + org_slots = org_post['slots'] + try: + org_slots = int(org_slots) + except ValueError: + continue + org.slots = org_slots + org.put() + # TODO: Use configuration variables here max_slots_per_org = 50 min_slots_per_org = 2