Provide the 'return_url' in the allocate slots view
This url can then be used to post and receive JSON data from.
Patch by: Sverre Rabbelier
--- a/app/soc/content/js/slot-allocator.js Sun Mar 08 14:37:28 2009 +0000
+++ b/app/soc/content/js/slot-allocator.js Sun Mar 08 14:38:24 2009 +0000
@@ -39,14 +39,14 @@
}
function retrieveJSON() {
- $.getJSON("http://localhost:8080/program/slots/google/gsoc2009?_="+(new Date().getTime()),
+ $.getJSON(RETURN_URL+"?_="+(new Date().getTime()),
updateFromJSON
);
}
function reCalculate() {
- url = "http://localhost:8080/program/slots/google/gsoc2009?_="+(new Date().getTime())
- $.postJSON(url, current_slots, updateFromJSON);
+ url = RETURN_URL+"?_="+(new Date().getTime())
+ $.postJSON(url, current_slots, updateFromJSON);
}
function updateOverlay() {
--- a/app/soc/templates/soc/program/allocation/allocation.html Sun Mar 08 14:37:28 2009 +0000
+++ b/app/soc/templates/soc/program/allocation/allocation.html Sun Mar 08 14:38:24 2009 +0000
@@ -5,6 +5,7 @@
<script type="text/javascript">
var MAX_AVAILABLE_SLOTS = {{ total_slots }};
+ var RETURN_URL = "{{ return_url }}";
$(document).ready(function(){
$('[id^=id_spin_slot_count_]').spin({min:0, max:MAX_AVAILABLE_SLOTS});
$('[id^=id_spin_adjustment_count_]').spin();
--- a/app/soc/views/models/program.py Sun Mar 08 14:37:28 2009 +0000
+++ b/app/soc/views/models/program.py Sun Mar 08 14:38:24 2009 +0000
@@ -23,6 +23,8 @@
]
+import os
+
from django import http
from django import forms
from django.utils import simplejson
@@ -254,10 +256,16 @@
content = lists.getListContent(request, org_params, filter=filter)
contents = [content]
+ return_url = "http://%(host)s%(index)s" % {
+ 'host' : os.environ['HTTP_HOST'],
+ 'index': redirects.getSlotsRedirect(program, params)
+ }
+
context = {
'total_slots': program.slots,
'uses_json': True,
- 'uses_slot_allocator': True
+ 'uses_slot_allocator': True,
+ 'return_url': return_url,
}
return self._list(request, org_params, contents, page_name, context)