Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
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
Hide 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 @@
<h1>
Hosts
<small>
list of all hosts
</small></h1>
</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 %}
{% endblock %}
network/views.py
View file @
689327cf
...
...
@@ -34,6 +34,22 @@ class HostList(SingleTableView):
table_class
=
HostTable
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
):
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