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
piks3l
Respect My Net
Commits
234ee2dd
Commit
234ee2dd
authored
Oct 29, 2011
by
stef
Browse files
[enh] added map of countries
parent
7dca041a
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
bt/views.py
View file @
234ee2dd
...
...
@@ -9,6 +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
django.db.models
import
Count
from
models
import
Violation
,
Attachment
,
Comment
,
Confirmation
,
COUNTRIES
from
tempfile
import
mkstemp
from
datetime
import
datetime
...
...
@@ -209,7 +210,18 @@ def filter_violations(request, country, operator=None):
def
list_violations
(
request
):
violations
=
Violation
.
objects
.
filter
(
activationid
=
''
)
return
render_to_response
(
'list.html'
,
{
"violations"
:
violations
},
context_instance
=
RequestContext
(
request
))
countries
=
sorted
([(
i
[
'total'
],
i
[
'country'
])
for
i
in
Violation
.
objects
.
values
(
'country'
).
filter
(
activationid
=
''
).
annotate
(
total
=
Count
(
'country'
))],
reverse
=
True
)
countries
=
json
.
dumps
(
dict
([(
c
.
lower
(),
"#ff%x00"
%
(
3
*
int
(
64
*
(
float
(
w
)
/
countries
[
0
][
0
]))
+
63
))
for
w
,
c
in
countries
]))
#confirms=sorted([(i['total'],i['country'])
# for i in Violation.objects.values('country').filter(activationid='').annotate(total=Count('confirmation'))],
# reverse=True)
return
render_to_response
(
'list.html'
,
{
"violations"
:
violations
,
"countries"
:
countries
,},
#"confirms": confirms,},
context_instance
=
RequestContext
(
request
))
def
view
(
request
,
id
):
v
=
get_object_or_404
(
Violation
,
pk
=
id
)
...
...
templates/list.html
View file @
234ee2dd
This diff is collapsed.
Click to expand it.
urls.py
View file @
234ee2dd
...
...
@@ -11,7 +11,7 @@ admin.autodiscover()
urlpatterns
=
patterns
(
''
,
(
r
'^$'
,
bt
.
index
),
(
r
'^list/$'
,
bt
.
list_violations
),
(
r
'^list/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$'
,
bt
.
filter_violations
),
url
(
r
'^list/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$'
,
bt
.
filter_violations
,
name
=
"filter"
),
(
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