From c23eb6601f8ffd2e80b141709150af8bd22605ff Mon Sep 17 00:00:00 2001 From: Sverre Rabbelier Date: Wed, 8 Apr 2009 23:45:41 +0000 Subject: [PATCH] Add a submit method and button to slots view Patch by: Sverre Rabbelier --- app/soc/content/js/slot-allocator-090320.js | 5 +++++ app/soc/templates/soc/program/allocation/allocation.html | 2 ++ app/soc/views/models/program.py | 12 +++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/soc/content/js/slot-allocator-090320.js b/app/soc/content/js/slot-allocator-090320.js index cf619279..8bc74afc 100644 --- a/app/soc/content/js/slot-allocator-090320.js +++ b/app/soc/content/js/slot-allocator-090320.js @@ -52,6 +52,11 @@ function reCalculate() {  $.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 --git a/app/soc/templates/soc/program/allocation/allocation.html b/app/soc/templates/soc/program/allocation/allocation.html index 3f3fde75..18fdb276 100644 --- a/app/soc/templates/soc/program/allocation/allocation.html +++ b/app/soc/templates/soc/program/allocation/allocation.html @@ -19,6 +19,8 @@ {% block body %} + {{ block.super }} + {% endblock %} diff --git a/app/soc/views/models/program.py b/app/soc/views/models/program.py index 91722c25..6b8e9d90 100644 --- a/app/soc/views/models/program.py +++ b/app/soc/views/models/program.py @@ -298,9 +298,9 @@ class View(presence.View): 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 @@ class View(presence.View): 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 -- 2.11.4.GIT