Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
Respect My Net
Commits
01f91674
Commit
01f91674
authored
Oct 19, 2011
by
stef
Browse files
[enh] added filters for list by country + operator
parent
96ded2fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
bt/views.py
View file @
01f91674
...
...
@@ -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
},
context_instance
=
RequestContext
(
request
))
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
)
else
:
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
))
...
...
urls.py
View file @
01f91674
...
...
@@ -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
),
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment