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): ...@@ -188,11 +188,12 @@ def add(request):
'violations': v_list }, 'violations': v_list },
context_instance=RequestContext(request)) context_instance=RequestContext(request))
def ajax(request, country=None, operator=None): # XXX obsoleted by API
if not operator: #def ajax(request, country=None, operator=None):
return HttpResponse(json.dumps(sorted(list(set([x.operator for x in Violation.objects.filter(country=country,activationid='')]))))) # if not operator:
else: # return HttpResponse(json.dumps(sorted(list(set([x.operator for x in Violation.objects.filter(country=country,activationid='')])))))
return HttpResponse(json.dumps(sorted(list(set([x.contract for x in Violation.objects.filter(country=country,activationid='',operator=operator)]))))) # else:
# return HttpResponse(json.dumps(sorted(list(set([x.contract for x in Violation.objects.filter(country=country,activationid='',operator=operator)])))))
def index(request): def index(request):
v_list = Violation.objects.filter(activationid='',featuredcase__isnull=False).order_by('id').reverse()[:3] v_list = Violation.objects.filter(activationid='',featuredcase__isnull=False).order_by('id').reverse()[:3]
......
...@@ -5,6 +5,10 @@ from django.contrib import admin ...@@ -5,6 +5,10 @@ from django.contrib import admin
from bt import views as bt from bt import views as bt
from bt.feeds import RssSiteNewsFeed, AtomSiteNewsFeed from bt.feeds import RssSiteNewsFeed, AtomSiteNewsFeed
from bt.api import APIResource
api_resource = APIResource()
admin.autodiscover() admin.autodiscover()
...@@ -12,7 +16,8 @@ urlpatterns = patterns('', ...@@ -12,7 +16,8 @@ urlpatterns = patterns('',
(r'^$', bt.index), (r'^$', bt.index),
(r'^list/$', bt.list_violations), (r'^list/$', bt.list_violations),
url(r'^list/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$', bt.filter_violations, name="filter"), 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'^add/$', bt.add),
(r'^view/(?P<id>[0-9]*)$', bt.view), (r'^view/(?P<id>[0-9]*)$', bt.view),
(r'^attach/(?P<id>[0-9]*)$', bt.get_attach), (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