Commit 000d1fcf authored by Guyzmo's avatar Guyzmo

[ENH] commented old AJAX access and added new API route

parent 2ec5766e
......@@ -188,11 +188,12 @@ def add(request):
'violations': v_list },
context_instance=RequestContext(request))
def ajax(request, country=None, operator=None):
if not operator:
return HttpResponse(json.dumps(sorted(list(set([x.operator for x in Violation.objects.filter(country=country,activationid='')])))))
else:
return HttpResponse(json.dumps(sorted(list(set([x.contract for x in Violation.objects.filter(country=country,activationid='',operator=operator)])))))
# XXX obsoleted by API
#def ajax(request, country=None, operator=None):
# if not operator:
# return HttpResponse(json.dumps(sorted(list(set([x.operator for x in Violation.objects.filter(country=country,activationid='')])))))
# else:
# return HttpResponse(json.dumps(sorted(list(set([x.contract for x in Violation.objects.filter(country=country,activationid='',operator=operator)])))))
def index(request):
v_list = Violation.objects.filter(activationid='',featuredcase__isnull=False).order_by('id').reverse()[:3]
......
......@@ -5,6 +5,10 @@ from django.contrib import admin
from bt import views as bt
from bt.feeds import RssSiteNewsFeed, AtomSiteNewsFeed
from bt.api import APIResource
api_resource = APIResource()
admin.autodiscover()
......@@ -12,7 +16,8 @@ urlpatterns = patterns('',
(r'^$', bt.index),
(r'^list/$', bt.list_violations),
url(r'^list/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$', bt.filter_violations, name="filter"),
(r'^ajax/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$', bt.ajax),
#(r'^ajax/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$', bt.ajax),
(r'^api/', include(api_resource.urls)),
(r'^add/$', bt.add),
(r'^view/(?P<id>[0-9]*)$', bt.view),
(r'^attach/(?P<id>[0-9]*)$', bt.get_attach),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment