1 from django.http import HttpResponse
2 from portal.actions import authority_add_pis, authority_remove_pis
5 def dispatch(request, action):
8 if request.method == 'POST':
9 req_items = request.POST
10 elif request.method == 'GET':
11 req_items = request.GET
13 if 'user_hrn' in req_items:
14 user_hrn = str(req_items['user_hrn'])
15 if 'authority_hrn' in req_items:
16 authority_hrn = str(req_items['authority_hrn'])
18 if (action == 'add') :
19 new_pis = authority_add_pis(request, authority_hrn, user_hrn)
21 elif (action == 'remove'):
22 new_pis = authority_remove_pis(request, authority_hrn, user_hrn)
25 raise Exception, "action not supported"
26 except Exception as e:
27 result = {'ret': -1, 'msg':'error: %s' % e}
28 return HttpResponse(json.dumps(result), content_type="application/json")