Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c1a10731
authored
Jan 14, 2015
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: filter rules by type
parent
e0d836aa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
6 deletions
+40
-6
circle/network/templates/network/rule-list.html
+20
-3
circle/network/views.py
+20
-3
No files found.
circle/network/templates/network/rule-list.html
View file @
c1a10731
...
...
@@ -8,11 +8,28 @@
{% block content %}
<div
class=
"page-header"
>
<a
href=
"{% url "
network
.
rule_create
"
%}"
class=
"btn btn-success pull-right"
><i
class=
"fa fa-plus-circle"
></i>
{% trans "Create a new rule" %}
</a>
<h1>
{% trans "Rules" %}
<small>
{% trans "list of all rules" %}
</small></h1>
<a
href=
"{% url "
network
.
rule_create
"
%}"
class=
"btn btn-success pull-right"
>
<i
class=
"fa fa-plus-circle"
></i>
{% trans "Create a new rule" %}
</a>
<h1>
{% trans "Rules" %}
<small>
{% trans "list of all rules" %}
</small></h1>
</div>
<ul
class=
"nav nav-pills"
style=
"margin: 5px 0 20px 0;"
>
<li
class=
"disabled"
>
<a
href=
"#"
>
{% trans "Filter by types" %}
</a>
</li>
<li
{%
if
not
request
.
GET
.
type
%}
class=
"active"
{%
endif
%}
>
<a
href=
"{{ request.path }}"
>
{% trans "ALL" %}
</a>
</li>
{% for k, v in types.items %}
<li
{%
if
request
.
GET
.
type =
=
k
%}
class=
"active"
{%
endif
%}
>
<a
href=
"?type={{ k }}"
>
{{ v }}
</a>
</li>
{% endfor %}
</ul>
<div
class=
"table-responsive"
>
{% render_table table %}
{% render_table table %}
</div>
{% endblock %}
circle/network/views.py
View file @
c1a10731
...
...
@@ -15,6 +15,8 @@
# You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
collections
import
OrderedDict
from
netaddr
import
IPNetwork
from
django.views.generic
import
(
TemplateView
,
UpdateView
,
DeleteView
,
CreateView
)
...
...
@@ -597,10 +599,25 @@ class RuleList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
template_name
=
"network/rule-list.html"
table_pagination
=
False
def
get_context_data
(
self
,
**
kwargs
):
self
.
types
=
OrderedDict
([
(
'vlan'
,
_
(
"Vlan"
)),
(
'vlangroup'
,
_
(
"Vlan group"
)),
(
'host'
,
_
(
"Host"
)),
(
'hostgroup'
,
_
(
"Host group"
)),
(
'firewall'
,
_
(
"Firewall"
))
])
context
=
super
(
RuleList
,
self
)
.
get_context_data
(
**
kwargs
)
context
[
'types'
]
=
self
.
types
return
context
def
get_table_data
(
self
):
return
Rule
.
objects
.
select_related
(
'host'
,
'hostgroup'
,
'vlan'
,
'vlangroup'
,
'firewall'
,
'foreign_network'
,
'owner'
)
rules
=
Rule
.
objects
.
select_related
(
'host'
,
'hostgroup'
,
'vlan'
,
'vlangroup'
,
'firewall'
,
'foreign_network'
,
'owner'
)
rule_type
=
self
.
request
.
GET
.
get
(
"type"
)
if
rule_type
and
rule_type
in
self
.
types
.
keys
():
rules
=
rules
.
filter
(
**
{
'
%
s__isnull'
%
rule_type
:
False
})
return
rules
class
RuleDetail
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
...
...
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