Commit 3a1e7b29 authored by stef's avatar stef
Browse files

[enh] added filters for list by country + operator

parent b7c12856
......@@ -9,7 +9,7 @@ from django.core.exceptions import ObjectDoesNotExist
from django.contrib import messages
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from models import Violation, Attachment, Comment, Confirmation
from models import Violation, Attachment, Comment, Confirmation, COUNTRIES
from tempfile import mkstemp
from datetime import datetime
import hashlib, os, re, json, smtplib
......@@ -198,6 +198,15 @@ def index(request):
'violations': v_list },
def filter_violations(request, country, operator=None):
if country not in map(itemgetter(0),COUNTRIES):
raise Http404
if not operator:
violations = Violation.objects.filter(activationid='', country=country)
violations = Violation.objects.filter(activationid='', country=country, operator=operator)
return render_to_response('list.html', {"violations": violations},context_instance=RequestContext(request))
def list_violations(request):
violations = Violation.objects.filter(activationid='')
return render_to_response('list.html', {"violations": violations},context_instance=RequestContext(request))
......@@ -11,6 +11,7 @@ admin.autodiscover()
urlpatterns = patterns('',
(r'^$', bt.index),
(r'^list/$', bt.list_violations),
(r'^list/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$', bt.filter_violations),
(r'^ajax/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$', bt.ajax),
(r'^add/$', bt.add),
(r'^view/(?P<id>[0-9]*)$', bt.view),
Supports Markdown
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