diff -r 0321f984fb16 -r 91cf6872d853 app/projrev/views/proposal.py --- a/app/projrev/views/proposal.py Sun Aug 09 22:52:45 2009 +0530 +++ b/app/projrev/views/proposal.py Sun Aug 09 23:24:48 2009 +0530 @@ -8,6 +8,7 @@ ] +import json import os import time @@ -366,23 +367,26 @@ def getDistrictsForState(request): """View function that sends the districts for the given state code via AJAXy. """ - import json + get_params = request.GET - st_code = get_params['_value'] - dt_dict = Project.DISTRICT_CHOICES + if get_params: + st_code = get_params['_value'] + dt_dict = Project.DISTRICT_CHOICES - # Get the Districts corresponding to the given State code. - dt_names = {} - count = 1 - for dt_code in dt_dict: - if dt_code[:2] == st_code: - dt_names[dt_code] = dt_dict[dt_code] - count += 1 + # Get the Districts corresponding to the given State code. + dt_names = {} + count = 1 + for dt_code in dt_dict: + if dt_code[:2] == st_code: + dt_names[dt_code] = dt_dict[dt_code] + count += 1 - # Sort the List based on District Name. - dt_send = [{'': "---------" }] - dt_names_sorted = sorted(dt_names.items(), key=lambda (k,v): (v,k)) - for dt_code, dt_name in dt_names_sorted: - dt_send.append({dt_code: dt_name}) - - return HttpResponse(json.dumps(dt_send)) \ No newline at end of file + # Sort the List based on District Name. + dt_send = [{'': "---------" }] + dt_names_sorted = sorted(dt_names.items(), key=lambda (k,v): (v,k)) + for dt_code, dt_name in dt_names_sorted: + dt_send.append({dt_code: dt_name}) + + return HttpResponse(json.dumps(dt_send)) + + return HttpResponse(None) \ No newline at end of file