Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
Respect My Net
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
piks3l
Respect My Net
Commits
066d1d85
Commit
066d1d85
authored
Feb 15, 2016
by
Okhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Soem work done on the ListViews #22
parent
33b7d8ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
13 deletions
+19
-13
bt/views.py
bt/views.py
+19
-12
nnmon/templates/list.html
nnmon/templates/list.html
+0
-1
No files found.
bt/views.py
View file @
066d1d85
...
@@ -221,12 +221,19 @@ class ViolationsList(ListView):
...
@@ -221,12 +221,19 @@ class ViolationsList(ListView):
def
get_queryset
(
self
):
def
get_queryset
(
self
):
queryset
=
Violation
.
objects
.
filter
(
activationid
=
''
)
queryset
=
Violation
.
objects
.
filter
(
activationid
=
''
)
if
'all'
not
in
self
.
request
.
GET
:
queryset
=
queryset
.
exclude
(
state__in
=
[
'duplicate'
,
'closed'
])
if
'country'
in
self
.
kwargs
:
queryset
=
queryset
.
filter
(
country
=
self
.
kwargs
[
'country'
])
if
'operator'
in
self
.
kwargs
:
if
'operator'
in
self
.
kwargs
:
queryset
=
queryset
.
filter
(
operator_ref__name
=
self
.
kwargs
[
'operator'
])
# If i Have operator I have a country
queryset
=
Violation
.
objects
.
filter
(
activationid
=
''
,
country
=
self
.
kwargs
[
'country'
],
operator_ref__name
=
self
.
kwargs
[
'operator'
])
elif
'country'
in
self
.
kwargs
:
queryset
=
Violation
.
objects
.
filter
(
activationid
=
''
,
country
=
self
.
kwargs
[
'country'
])
if
not
queryset
.
count
():
queryset
=
queryset
.
filter
(
activationid
=
''
,
operator_ref__name
=
self
.
kwargs
[
'country'
])
if
'all'
not
in
self
.
request
.
GET
:
queryset
=
queryset
.
objects
.
filter
(
activationid
=
''
).
exclude
(
state__in
=
[
'duplicate'
,
'closed'
])
return
queryset
return
queryset
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
...
@@ -234,13 +241,13 @@ class ViolationsList(ListView):
...
@@ -234,13 +241,13 @@ class ViolationsList(ListView):
if
'country'
in
self
.
kwargs
:
if
'country'
in
self
.
kwargs
:
context
[
'country'
]
=
self
.
kwargs
[
'country'
]
context
[
'country'
]
=
self
.
kwargs
[
'country'
]
else
:
countries
=
sorted
([(
i
[
'total'
],
i
[
'country'
])
countries
=
sorted
([(
i
[
'total'
],
i
[
'country'
])
for
i
in
Violation
.
objects
.
values
(
'country'
).
filter
(
activationid
=
''
).
exclude
(
state__in
=
[
'duplicate'
,
'closed'
]).
annotate
(
total
=
Count
(
'country'
))],
for
i
in
Violation
.
objects
.
values
(
'country'
).
filter
(
activationid
=
''
).
exclude
(
state__in
=
[
'duplicate'
,
'closed'
]).
annotate
(
total
=
Count
(
'country'
))],
reverse
=
True
)
reverse
=
True
)
countryweights
=
json
.
dumps
([{
'iso2'
:
y
,
'w'
:
x
}
for
x
,
y
in
countries
])
countryweights
=
json
.
dumps
([{
'iso2'
:
y
,
'w'
:
x
}
for
x
,
y
in
countries
])
context
[
'countries'
]
=
countries
context
[
'countries'
]
=
countries
context
[
'countryweights'
]
=
countryweights
context
[
'countryweights'
]
=
countryweights
return
context
return
context
class
ViolationView
(
DetailView
):
class
ViolationView
(
DetailView
):
...
...
nnmon/templates/list.html
View file @
066d1d85
...
@@ -122,5 +122,4 @@
...
@@ -122,5 +122,4 @@
{% endfor %}
{% endfor %}
</tbody>
</tbody>
</table>
</table>
</div>
{%endblock%}
{%endblock%}
Write
Preview
Markdown
is supported
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