Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
689327cf
authored
Jul 24, 2013
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: filter hosts by vlan
parent
e743c410
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
network/templates/network/host-list.html
+8
-0
network/views.py
+16
-0
No files found.
network/templates/network/host-list.html
View file @
689327cf
...
@@ -9,5 +9,13 @@
...
@@ -9,5 +9,13 @@
<h1>
Hosts
<small>
list of all hosts
</small></h1>
<h1>
Hosts
<small>
list of all hosts
</small></h1>
</div>
</div>
<ul
class=
"nav nav-pills"
>
<li
class=
"disabled"
><a
href=
"#"
>
Filter by vlans
</a></li>
<li
{%
if
not
request
.
GET
.
vlan
%}
class=
"active"
{%
endif
%}
><a
href=
"{{ request.path }}"
>
ALL
</a></li>
{% for vlan in vlans %}
<li
{%
if
request
.
GET
.
vlan
|
add:
"
0
"
==
vlan
.
id
%}
class=
"active"
{%
endif
%}
><a
href=
"?vlan={{ vlan.id }}"
>
{{ vlan.name }}
</a></li>
{% endfor %}
</ul>
{% render_table table %}
{% render_table table %}
{% endblock %}
{% endblock %}
network/views.py
View file @
689327cf
...
@@ -34,6 +34,22 @@ class HostList(SingleTableView):
...
@@ -34,6 +34,22 @@ class HostList(SingleTableView):
table_class
=
HostTable
table_class
=
HostTable
template_name
=
"network/host-list.html"
template_name
=
"network/host-list.html"
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
HostList
,
self
)
.
get_context_data
(
**
kwargs
)
q
=
Vlan
.
objects
.
all
()
.
order_by
(
"name"
)
context
[
'vlans'
]
=
q
return
context
def
get_table_data
(
self
):
vlan_id
=
self
.
request
.
GET
.
get
(
'vlan'
)
print
vlan_id
if
vlan_id
:
data
=
Host
.
objects
.
filter
(
vlan
=
vlan_id
)
.
all
()
else
:
data
=
Host
.
objects
.
all
()
return
data
class
HostDetail
(
UpdateView
):
class
HostDetail
(
UpdateView
):
model
=
Host
model
=
Host
...
...
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