Skip to content
GitLab
Menu
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
f1260f98
Commit
f1260f98
authored
Nov 21, 2011
by
Baptiste Jonglez
Browse files
[enh] rephrase statistics and exclude ooscope/closed/duplicate
parent
a1ef8482
Changes
2
Show whitespace changes
Inline
Side-by-side
bt/views.py
View file @
f1260f98
...
...
@@ -194,24 +194,24 @@ def index(request):
v_list
=
Violation
.
objects
.
filter
(
activationid
=
''
,
featuredcase__isnull
=
False
).
order_by
(
'id'
).
reverse
()[:
3
]
form
=
AddViolation
()
reports
=
sorted
([(
i
[
'total'
],
i
[
'id'
])
for
i
in
Violation
.
objects
.
values
(
'id'
).
filter
(
activationid
=
''
).
annotate
(
total
=
Count
(
'confirmation'
))],
reverse
=
True
)
countries
=
sorted
([(
i
[
'total'
],
i
[
'country'
])
for
i
in
Violation
.
objects
.
values
(
'country'
).
filter
(
activationid
=
''
).
annotate
(
total
=
Count
(
'country'
))],
for
i
in
Violation
.
objects
.
values
(
'id'
).
filter
(
activationid
=
''
).
exclude
(
state
=
[
'ooscope'
,
'closed'
,
'duplicate'
]).
annotate
(
total
=
Count
(
'confirmation'
))],
reverse
=
True
)
# countries=sorted([(i['total'],i['country'])
# for i in Violation.objects.values('country').filter(activationid='').annotate(total=Count('country'))],
# reverse=True)
confirms
=
sorted
([(
i
[
'total'
],
i
[
'country'
])
for
i
in
Violation
.
objects
.
values
(
'country'
).
filter
(
activationid
=
''
).
annotate
(
total
=
Count
(
'confirmation'
))],
for
i
in
Violation
.
objects
.
values
(
'country'
).
filter
(
activationid
=
''
).
exclude
(
state
=
[
'ooscope'
,
'closed'
,
'duplicate'
]).
annotate
(
total
=
Count
(
'confirmation'
))],
reverse
=
True
)
operators
=
sorted
([(
i
[
'total'
],
i
[
'operator'
])
for
i
in
Violation
.
objects
.
values
(
'operator'
).
filter
(
activationid
=
''
).
annotate
(
total
=
Count
(
'confirmation'
))],
for
i
in
Violation
.
objects
.
values
(
'operator'
).
filter
(
activationid
=
''
).
exclude
(
state
=
[
'ooscope'
,
'closed'
,
'duplicate'
]).
annotate
(
total
=
Count
(
'confirmation'
))],
reverse
=
True
)
return
render_to_response
(
'index.html'
,
{
'form'
:
form
,
'stats'
:
[
(
_
(
'Total
reports (confirmed)'
),
sum
([
i
for
i
,
z
in
countries
]
),
len
([
i
for
i
,
z
in
reports
if
i
>
1
])),
(
_
(
'Countries with
reports (confirmed)'
),
len
(
countries
),
len
([
i
for
i
,
z
in
confirms
if
i
>
1
])),
(
_
(
'Operators with
reports (confirmed)'
),
len
(
operators
),
len
([
x
for
x
in
operators
if
x
[
0
]
>
1
])),
'stats'
:
[
(
_
(
'Total
confirmed reports'
),
len
([
i
for
i
,
z
in
reports
if
i
>
1
])),
(
_
(
'Countries with
some confirmed reports'
),
len
([
i
for
i
,
z
in
confirms
if
i
>
1
])),
(
_
(
'Operators with
some confirmed reports'
),
len
([
i
for
i
,
z
in
operators
if
i
>
1
])),
],
'violations'
:
v_list
},
context_instance
=
RequestContext
(
request
))
...
...
templates/index.html
View file @
f1260f98
...
...
@@ -127,10 +127,11 @@ $(document).ready(function(){
<h2>
{% trans "Statistics" %}
</h2>
<div
id=
"stats_graph"
></div>
<ul
id=
"stats"
>
{% for t, n
, n1
in stats %}
<li
class=
"stat"
><dl><dt
class=
"inline"
>
{{t}}
</dt><dd
class=
"inline"
>
{{n}}({{n1}})
</dd></dl></li>
{% for t, n in stats %}
<li
class=
"stat"
><dl><dt
class=
"inline"
>
{{t}}
</dt><dd
class=
"inline"
>
<strong>
{{n}}
</strong>
</dd></dl></li>
{% endfor %}
</ul>
<h2>
{% trans "Featured Cases" %}
</h2>
<table
id=
"featured_cases"
>
<thead>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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