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
8d2c1946
Commit
8d2c1946
authored
Mar 07, 2016
by
Okhin
Browse files
Finding the last filtering part on activationid=''
parent
74fc6dfc
Changes
1
Hide whitespace changes
Inline
Side-by-side
bt/views.py
View file @
8d2c1946
...
...
@@ -194,13 +194,13 @@ class AddForm(FormView):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
AddForm
,
self
).
get_context_data
(
**
kwargs
)
reports
=
sorted
([(
i
[
'total'
],
i
[
'id'
])
for
i
in
Violation
.
objects
.
values
(
'id'
).
filter
(
activationid
=
''
).
exclude
(
state__in
=
[
'closed'
,
'ooscope'
,
'duplicate'
]).
exclude
(
old
=
True
).
annotate
(
total
=
Count
(
'confirmation'
))],
for
i
in
Violation
.
objects
.
values
(
'id'
).
exclude
(
state__in
=
[
'closed'
,
'ooscope'
,
'duplicate'
]).
exclude
(
old
=
True
).
annotate
(
total
=
Count
(
'confirmation'
))],
reverse
=
True
)
confirms
=
sorted
([(
i
[
'total'
],
i
[
'country'
])
for
i
in
Violation
.
objects
.
values
(
'country'
).
filter
(
activationid
=
''
).
exclude
(
state__in
=
[
'closed'
,
'ooscope'
,
'duplicate'
]).
exclude
(
old
=
True
).
annotate
(
total
=
Count
(
'confirmation'
))],
for
i
in
Violation
.
objects
.
values
(
'country'
).
exclude
(
state__in
=
[
'closed'
,
'ooscope'
,
'duplicate'
]).
exclude
(
old
=
True
).
annotate
(
total
=
Count
(
'confirmation'
))],
reverse
=
True
)
operators
=
sorted
([(
i
[
'total'
],
i
[
'operator_ref__name'
])
for
i
in
Violation
.
objects
.
values
(
'operator_ref__name'
).
filter
(
activationid
=
''
).
exclude
(
state__in
=
[
'closed'
,
'ooscope'
,
'duplicate'
]).
exclude
(
old
=
True
).
annotate
(
total
=
Count
(
'confirmation'
))],
for
i
in
Violation
.
objects
.
values
(
'operator_ref__name'
).
exclude
(
state__in
=
[
'closed'
,
'ooscope'
,
'duplicate'
]).
exclude
(
old
=
True
).
annotate
(
total
=
Count
(
'confirmation'
))],
reverse
=
True
)
context
[
'stats'
]
=
[
(
_
(
'Total confirmed reports'
),
len
([
i
for
i
,
z
in
reports
if
i
>
0
])),
...
...
@@ -224,7 +224,7 @@ class ViolationsList(ListView):
queryset
=
Violation
.
objects
.
filter
(
activationid
=
''
,
country
=
self
.
kwargs
[
'country'
]).
exclude
(
old
=
True
)
if
'all'
not
in
self
.
request
.
GET
:
queryset
=
queryset
.
filter
(
activationid
=
''
).
exclude
(
state__in
=
[
'duplicate'
,
'closed'
]).
exclude
(
old
=
False
)
queryset
=
queryset
.
exclude
(
state__in
=
[
'ooscope'
,
'duplicate'
,
'closed'
]).
exclude
(
old
=
False
)
return
queryset
def
get_context_data
(
self
,
**
kwargs
):
...
...
@@ -234,7 +234,7 @@ class ViolationsList(ListView):
context
[
'country'
]
=
self
.
kwargs
[
'country'
]
else
:
countries
=
sorted
([(
i
[
'total'
],
i
[
'country'
])
for
i
in
Violation
.
objects
.
values
(
'country'
).
exclude
(
state__in
=
[
'duplicate'
,
'closed'
]).
exclude
(
old
=
True
).
annotate
(
total
=
Count
(
'country'
))],
for
i
in
Violation
.
objects
.
values
(
'country'
).
exclude
(
state__in
=
[
'ooscope'
,
'duplicate'
,
'closed'
]).
exclude
(
old
=
True
).
annotate
(
total
=
Count
(
'country'
))],
reverse
=
True
)
countryweights
=
json
.
dumps
([{
'iso2'
:
y
,
'w'
:
x
}
for
x
,
y
in
countries
])
context
[
'countries'
]
=
countries
...
...
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