forked from 0x2620/pandora
make new api work
This commit is contained in:
parent
f2944b1b75
commit
c0b3bdd29c
4 changed files with 12 additions and 6 deletions
|
@ -3,6 +3,7 @@
|
||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from urllib2 import unquote
|
from urllib2 import unquote
|
||||||
|
import json
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
|
@ -30,10 +31,14 @@ class MovieManager(Manager):
|
||||||
also checks for lists.
|
also checks for lists.
|
||||||
range and order must be applied later
|
range and order must be applied later
|
||||||
'''
|
'''
|
||||||
|
'''
|
||||||
q = ''
|
q = ''
|
||||||
for i in request.META['QUERY_STRING'].split('&'):
|
for i in request.META['QUERY_STRING'].split('&'):
|
||||||
if i.startswith('q='):
|
if i.startswith('q='):
|
||||||
q = i[2:]
|
q = i[2:]
|
||||||
|
'''
|
||||||
|
q = json.loads(request.POST['data'])['q']
|
||||||
|
print q
|
||||||
op = ','
|
op = ','
|
||||||
if '|' in q:
|
if '|' in q:
|
||||||
op = '|'
|
op = '|'
|
||||||
|
|
|
@ -39,7 +39,8 @@ def api(request):
|
||||||
response = f(request)
|
response = f(request)
|
||||||
else:
|
else:
|
||||||
response = {'status': 404, 'statusText': 'Unknown function %s' % function}
|
response = {'status': 404, 'statusText': 'Unknown function %s' % function}
|
||||||
return render_to_json_response(response)
|
response = render_to_json_response(response)
|
||||||
|
return response
|
||||||
|
|
||||||
def api_hello(request):
|
def api_hello(request):
|
||||||
'''
|
'''
|
||||||
|
@ -162,7 +163,7 @@ def _order_query(qs, s, prefix='sort__'):
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
def _parse_query(request):
|
def _parse_query(request):
|
||||||
get = request.GET
|
get = json.loads(request.POST['data'])
|
||||||
query = {}
|
query = {}
|
||||||
query['i'] = 0
|
query['i'] = 0
|
||||||
query['o'] = 100
|
query['o'] = 100
|
||||||
|
@ -320,7 +321,7 @@ POST update
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
#@login_required_json
|
#@login_required_json
|
||||||
def api_update(request, archive):
|
def api_update(request):
|
||||||
print "update request"
|
print "update request"
|
||||||
data = json.loads(request.POST['data'])
|
data = json.loads(request.POST['data'])
|
||||||
archive = data['archive']
|
archive = data['archive']
|
||||||
|
|
|
@ -10,7 +10,7 @@ admin.autodiscover()
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
# Example:
|
# Example:
|
||||||
(r'^ajax_filtered_fields/', include('ajax_filtered_fields.urls')),
|
(r'^ajax_filtered_fields/', include('ajax_filtered_fields.urls')),
|
||||||
(r'^api/', include('backend.views.api')),
|
(r'^api/', 'backend.views.api'),
|
||||||
(r'^$', 'app.views.index'),
|
(r'^$', 'app.views.index'),
|
||||||
|
|
||||||
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
|
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
|
||||||
|
|
Loading…
Reference in a new issue