1 from django.shortcuts import render_to_response
3 from unfold.loginrequired import LoginRequiredView
5 from rest import ObjectRequest, error
7 from string import join
9 def dispatch(request, object_type, object_name):
11 o = ObjectRequest(request, object_type, object_name)
13 if request.method == 'POST':
14 req_items = request.POST
15 elif request.method == 'GET':
16 req_items = request.GET
18 for el in req_items.items():
19 if el[0].startswith('filters'):
20 o.filters[el[0][8:-1]] = el[1]
21 elif el[0].startswith('fields'):
22 o.setFields(req_items.getlist('fields[]'))
23 elif el[0].startswith('options'):
24 o.options = req_items.getlist('options[]')
26 if request.path.split('/')[1] == 'rest' :
28 elif request.path.split('/')[1] == 'table' :
29 return render_to_response('table-default.html', {'data' : o.get(), 'fields' : o.fields, 'id' : o.id, 'options' : o.options})
30 elif request.path.split('/')[1] == 'datatable' :