Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
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
015de106
authored
Jan 26, 2015
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: firewall CRUD
parent
8916d530
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
222 additions
and
70 deletions
+222
-70
circle/firewall/models.py
+4
-0
circle/network/forms.py
+19
-2
circle/network/static/network/network.less
+17
-0
circle/network/tables.py
+11
-0
circle/network/templates/network/base.html
+0
-26
circle/network/templates/network/firewall-create.html
+18
-0
circle/network/templates/network/firewall-edit.html
+21
-0
circle/network/templates/network/firewall-list.html
+20
-0
circle/network/templates/network/menu.html
+12
-18
circle/network/urls.py
+43
-16
circle/network/views.py
+57
-8
No files found.
circle/firewall/models.py
View file @
015de106
...
@@ -970,6 +970,10 @@ class Firewall(models.Model):
...
@@ -970,6 +970,10 @@ class Firewall(models.Model):
logger
.
exception
(
"get_dhcp_clients failed"
)
logger
.
exception
(
"get_dhcp_clients failed"
)
return
{}
return
{}
@models.permalink
def
get_absolute_url
(
self
):
return
(
'network.firewall'
,
None
,
{
'pk'
:
self
.
pk
})
class
Domain
(
models
.
Model
):
class
Domain
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
40
,
validators
=
[
val_domain
],
name
=
models
.
CharField
(
max_length
=
40
,
validators
=
[
val_domain
],
...
...
circle/network/forms.py
View file @
015de106
...
@@ -23,8 +23,10 @@ from crispy_forms.helper import FormHelper
...
@@ -23,8 +23,10 @@ from crispy_forms.helper import FormHelper
from
crispy_forms.layout
import
Layout
,
Fieldset
,
Div
,
Submit
,
BaseInput
from
crispy_forms.layout
import
Layout
,
Fieldset
,
Div
,
Submit
,
BaseInput
from
crispy_forms.bootstrap
import
FormActions
,
FieldWithButtons
,
StrictButton
from
crispy_forms.bootstrap
import
FormActions
,
FieldWithButtons
,
StrictButton
from
firewall.models
import
(
Host
,
Vlan
,
Domain
,
Group
,
Record
,
BlacklistItem
,
from
firewall.models
import
(
Rule
,
VlanGroup
,
SwitchPort
)
Host
,
Vlan
,
Domain
,
Group
,
Record
,
BlacklistItem
,
Rule
,
VlanGroup
,
SwitchPort
,
Firewall
)
class
LinkButton
(
BaseInput
):
class
LinkButton
(
BaseInput
):
...
@@ -88,6 +90,21 @@ class DomainForm(ModelForm):
...
@@ -88,6 +90,21 @@ class DomainForm(ModelForm):
model
=
Domain
model
=
Domain
class
FirewallForm
(
ModelForm
):
helper
=
FormHelper
()
helper
.
layout
=
Layout
(
Div
(
Fieldset
(
''
,
'name'
,
)
),
FormActions
(
Submit
(
'submit'
,
_
(
"Save"
)),
LinkButton
(
'back'
,
_
(
"Back"
),
reverse_lazy
(
'network.firewall_list'
))
)
)
class
Meta
:
model
=
Firewall
class
GroupForm
(
ModelForm
):
class
GroupForm
(
ModelForm
):
helper
=
FormHelper
()
helper
=
FormHelper
()
helper
.
layout
=
Layout
(
helper
.
layout
=
Layout
(
...
...
circle/network/static/network/network.less
View file @
015de106
...
@@ -11,3 +11,20 @@
...
@@ -11,3 +11,20 @@
text-align: center;
text-align: center;
width: 60px;
width: 60px;
}
}
body {
padding-top: 40px;
}
/* note: this doesn't really work */
a i:hover {
text-decoration: none;
}
footer {
margin-top: 45px;
}
.messagelist {
margin-top: 25px;
}
circle/network/tables.py
View file @
015de106
...
@@ -233,3 +233,14 @@ class HostRecordsTable(Table):
...
@@ -233,3 +233,14 @@ class HostRecordsTable(Table):
fields
=
(
"type"
,
"fqdn"
)
fields
=
(
"type"
,
"fqdn"
)
order_by
=
(
"name"
,
)
order_by
=
(
"name"
,
)
empty_text
=
_
(
"No records."
)
empty_text
=
_
(
"No records."
)
class
FirewallTable
(
Table
):
pk
=
LinkColumn
(
'network.firewall'
,
args
=
[
A
(
'pk'
)],
verbose_name
=
"ID"
)
class
Meta
:
model
=
SwitchPort
attrs
=
{
'class'
:
'table table-striped'
}
fields
=
(
'pk'
,
'name'
,
)
order_by
=
'pk'
circle/network/templates/network/base.html
View file @
015de106
...
@@ -6,32 +6,6 @@
...
@@ -6,32 +6,6 @@
{% block title-site %}{% trans "Network" %} | CIRCLE{% endblock %}
{% block title-site %}{% trans "Network" %} | CIRCLE{% endblock %}
{% block extra_link %}
<link
href=
'//fonts.googleapis.com/css?family=Source+Sans+Pro:200,400&subset=latin,latin-ext'
rel=
'stylesheet'
type=
'text/css'
>
<link
href=
"{% static "
network
/
network
.
css
"
%}"
rel=
"stylesheet"
>
{% endblock %}
{% block extra_css %}
<style
type=
"text/css"
>
body
{
padding-top
:
40px
;
}
/* note: this doesn't really work */
a
i
:hover
{
text-decoration
:
none
;
}
footer
{
margin-top
:
45px
;
}
.messagelist
{
margin-top
:
25px
;
}
</style>
{% endblock %}
{% block navbar-brand %}
{% block navbar-brand %}
<a
class=
"navbar-brand"
href=
"{% url "
network
.
index
"
%}"
>
CIRCLE Network
</a>
<a
class=
"navbar-brand"
href=
"{% url "
network
.
index
"
%}"
>
CIRCLE Network
</a>
{% endblock %}
{% endblock %}
...
...
circle/network/templates/network/firewall-create.html
0 → 100644
View file @
015de106
{% extends "network/base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load crispy_forms_tags %}
{% block title-page %}{% trans "Create" %} | {% trans "firewall" %}{% endblock %}
{% block content %}
<div
class=
"page-header"
>
<h2>
{% trans "Create a new firewall" %}
</h2>
</div>
<div
class=
"row"
>
<div
class=
"col-sm-8"
>
{% crispy form %}
</div>
</div>
{% endblock %}
circle/network/templates/network/firewall-edit.html
0 → 100644
View file @
015de106
{% extends "network/base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load crispy_forms_tags %}
{% block title-page %}{{ switch_port_pk }} | {% trans "firewall" %}{% endblock %}
{% block content %}
<div
class=
"page-header"
>
<a
href=
"{% url "
network
.
firewall_delete
"
pk=
object.pk
%}"
class=
"btn btn-danger pull-right"
>
<i
class=
"fa fa-times-circle"
></i>
{% trans "Delete this firewall" %}
</a>
<h2>
{{ object.name }}
</h2>
</div>
<div
class=
"row"
>
<div
class=
"col-sm-5"
>
{% crispy form %}
</div>
</div>
{% endblock %}
circle/network/templates/network/firewall-list.html
0 → 100644
View file @
015de106
{% extends "network/base.html" %}
{% load render_table from django_tables2 %}
{% load i18n %}
{% load l10n %}
{% load staticfiles %}
{% block title-page %}{% trans "Firewalls" %}{% endblock %}
{% block content %}
<div
class=
"page-header"
>
<a
href=
"{% url "
network
.
firewall_create
"
%}"
class=
"btn btn-success pull-right"
>
<i
class=
"fa fa-plus-circle"
></i>
{% trans "Create a new firewall" %}
</a>
<h1>
{% trans "Firewalls" %}
</h1>
</div>
<div
class=
"table-responsive"
>
{% render_table table %}
</div>
{% endblock %}
circle/network/templates/network/menu.html
View file @
015de106
...
@@ -22,25 +22,19 @@
...
@@ -22,25 +22,19 @@
{% url "network.switch_port_list" as u %}
{% url "network.switch_port_list" as u %}
{% trans "Switch ports" as t %}
{% trans "Switch ports" as t %}
{% include "network/menu-item.html" with href=u text=t %}
{% include "network/menu-item.html" with href=u text=t %}
{% url "network.firewall_list" as u %}
{% trans "Firewalls" as t %}
{% include "network/menu-item.html" with href=u text=t %}
<li
class=
"dropdown{% if "
groups
"
in
request
.
path
%}
active
{%
endif
%}"
>
<li
class=
"dropdown{% if "
groups
"
in
request
.
path
%}
active
{%
endif
%}"
>
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
Groups
<b
class=
"caret"
></b></a>
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
Groups
<b
class=
"caret"
></b></a>
<ul
class=
"dropdown-menu"
>
<ul
class=
"dropdown-menu"
>
{% url "network.vlan_group_list" as u %}
{% url "network.vlan_group_list" as u %}
{% trans "Vlan groups" as t %}
{% trans "Vlan groups" as t %}
{% include "network/menu-item.html" with href=u text=t %}
{% include "network/menu-item.html" with href=u text=t %}
{% url "network.group_list" as u %}
{% url "network.group_list" as u %}
{% trans "Host groups" as t %}
{% trans "Host groups" as t %}
{% include "network/menu-item.html" with href=u text=t %}
{% include "network/menu-item.html" with href=u text=t %}
</ul>
</ul>
</li>
</li>
{#
<li><a
href=
"/vlans/"
>
{% trans "Vlans" %}
</a></li>
#}
{#
<li><a
href=
"/vlangroups/"
>
{% trans "Vlan groups" %}
</a></li>
#}
{#
<li><a
href=
"/hostgroups/"
>
{% trans "Host groups" %}
</a></li>
#}
{#
<li><a
href=
"/hosts/"
>
{% trans "Hosts" %}
</a></li>
#}
{#
<li><a
href=
"/firewalls/"
>
{% trans "Firewalls" %}
</a></li>
#}
{#
<li><a
href=
"/domains/"
>
{% trans "Domains" %}
</a></li>
#}
{#
<li><a
href=
"/records/"
>
{% trans "DNS records" %}
</a></li>
#}
{#
<li><a
href=
"/blacklist/"
>
{% trans "Blacklist" %}
</a></li>
#}
circle/network/urls.py
View file @
015de106
...
@@ -16,26 +16,27 @@
...
@@ -16,26 +16,27 @@
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
django.conf.urls
import
patterns
,
url
from
django.conf.urls
import
patterns
,
url
from
.views
import
(
IndexView
,
from
.views
import
(
HostList
,
HostDetail
,
HostCreate
,
HostDelete
,
IndexView
,
VlanList
,
VlanDetail
,
VlanDelete
,
VlanCrea
te
,
HostList
,
HostDetail
,
HostCreate
,
HostDele
te
,
DomainList
,
DomainDetail
,
DomainDelete
,
Domai
nCreate
,
VlanList
,
VlanDetail
,
VlanDelete
,
Vla
nCreate
,
GroupList
,
GroupDetail
,
GroupDelete
,
Group
Create
,
DomainList
,
DomainDetail
,
DomainDelete
,
Domain
Create
,
RecordList
,
RecordDetail
,
RecordCreate
,
RecordDele
te
,
GroupList
,
GroupDetail
,
GroupDelete
,
GroupCrea
te
,
BlacklistList
,
BlacklistDetail
,
Blacklist
Delete
,
RecordList
,
RecordDetail
,
RecordCreate
,
Record
Delete
,
BlacklistCreate
,
BlacklistList
,
BlacklistDetail
,
BlacklistDelete
,
BlacklistCreate
,
RuleList
,
RuleDetail
,
RuleDelete
,
RuleCreate
,
RuleList
,
RuleDetail
,
RuleDelete
,
RuleCreate
,
SwitchPortList
,
SwitchPortDetail
,
SwitchPortCrea
te
,
SwitchPortList
,
SwitchPortDetail
,
SwitchPortCreate
,
SwitchPortDele
te
,
SwitchPortDele
te
,
VlanGroupList
,
VlanGroupDetail
,
VlanGroupDelete
,
VlanGroupCrea
te
,
VlanGroupList
,
VlanGroupDetail
,
VlanGroup
Delete
,
FirewallList
,
FirewallDetail
,
FirewallCreate
,
Firewall
Delete
,
VlanGroupCreate
,
remove_host_group
,
add_host_group
,
remove_host_group
,
add_host_group
,
remove_switch_port_device
,
add_switch_port_device
,
remove_switch_port_device
,
add_switch_port_device
,
VlanAclUpdateView
VlanAclUpdateView
)
)
urlpatterns
=
patterns
(
urlpatterns
=
patterns
(
''
,
''
,
url
(
'^$'
,
IndexView
.
as_view
(),
name
=
'network.index'
),
url
(
'^$'
,
IndexView
.
as_view
(),
name
=
'network.index'
),
# blacklist
url
(
'^blacklist/$'
,
BlacklistList
.
as_view
(),
url
(
'^blacklist/$'
,
BlacklistList
.
as_view
(),
name
=
'network.blacklist_list'
),
name
=
'network.blacklist_list'
),
url
(
'^blacklist/create$'
,
BlacklistCreate
.
as_view
(),
url
(
'^blacklist/create$'
,
BlacklistCreate
.
as_view
(),
...
@@ -44,6 +45,8 @@ urlpatterns = patterns(
...
@@ -44,6 +45,8 @@ urlpatterns = patterns(
name
=
'network.blacklist'
),
name
=
'network.blacklist'
),
url
(
'^blacklist/delete/(?P<pk>
\
d+)/$'
,
BlacklistDelete
.
as_view
(),
url
(
'^blacklist/delete/(?P<pk>
\
d+)/$'
,
BlacklistDelete
.
as_view
(),
name
=
"network.blacklist_delete"
),
name
=
"network.blacklist_delete"
),
# domain
url
(
'^domains/$'
,
DomainList
.
as_view
(),
name
=
'network.domain_list'
),
url
(
'^domains/$'
,
DomainList
.
as_view
(),
name
=
'network.domain_list'
),
url
(
'^domains/create$'
,
DomainCreate
.
as_view
(),
url
(
'^domains/create$'
,
DomainCreate
.
as_view
(),
name
=
'network.domain_create'
),
name
=
'network.domain_create'
),
...
@@ -51,17 +54,33 @@ urlpatterns = patterns(
...
@@ -51,17 +54,33 @@ urlpatterns = patterns(
name
=
'network.domain'
),
name
=
'network.domain'
),
url
(
'^domains/delete/(?P<pk>
\
d+)/$'
,
DomainDelete
.
as_view
(),
url
(
'^domains/delete/(?P<pk>
\
d+)/$'
,
DomainDelete
.
as_view
(),
name
=
"network.domain_delete"
),
name
=
"network.domain_delete"
),
# firewall
url
(
'^firewalls/$'
,
FirewallList
.
as_view
(),
name
=
'network.firewall_list'
),
url
(
'^firewalls/create$'
,
FirewallCreate
.
as_view
(),
name
=
'network.firewall_create'
),
url
(
'^firewalls/(?P<pk>
\
d+)/$'
,
FirewallDetail
.
as_view
(),
name
=
'network.firewall'
),
url
(
'^firewalls/delete/(?P<pk>
\
d+)/$'
,
FirewallDelete
.
as_view
(),
name
=
"network.firewall_delete"
),
# group (host)
url
(
'^groups/$'
,
GroupList
.
as_view
(),
name
=
'network.group_list'
),
url
(
'^groups/$'
,
GroupList
.
as_view
(),
name
=
'network.group_list'
),
url
(
'^groups/create$'
,
GroupCreate
.
as_view
(),
url
(
'^groups/create$'
,
GroupCreate
.
as_view
(),
name
=
'network.group_create'
),
name
=
'network.group_create'
),
url
(
'^groups/(?P<pk>
\
d+)/$'
,
GroupDetail
.
as_view
(),
name
=
'network.group'
),
url
(
'^groups/(?P<pk>
\
d+)/$'
,
GroupDetail
.
as_view
(),
name
=
'network.group'
),
url
(
'^groups/delete/(?P<pk>
\
d+)/$'
,
GroupDelete
.
as_view
(),
url
(
'^groups/delete/(?P<pk>
\
d+)/$'
,
GroupDelete
.
as_view
(),
name
=
"network.group_delete"
),
name
=
"network.group_delete"
),
# host
url
(
'^hosts/$'
,
HostList
.
as_view
(),
name
=
'network.host_list'
),
url
(
'^hosts/$'
,
HostList
.
as_view
(),
name
=
'network.host_list'
),
url
(
'^hosts/create$'
,
HostCreate
.
as_view
(),
name
=
'network.host_create'
),
url
(
'^hosts/create$'
,
HostCreate
.
as_view
(),
name
=
'network.host_create'
),
url
(
'^hosts/(?P<pk>
\
d+)/$'
,
HostDetail
.
as_view
(),
name
=
'network.host'
),
url
(
'^hosts/(?P<pk>
\
d+)/$'
,
HostDetail
.
as_view
(),
name
=
'network.host'
),
url
(
'^hosts/delete/(?P<pk>
\
d+)/$'
,
HostDelete
.
as_view
(),
url
(
'^hosts/delete/(?P<pk>
\
d+)/$'
,
HostDelete
.
as_view
(),
name
=
"network.host_delete"
),
name
=
"network.host_delete"
),
# record
url
(
'^records/$'
,
RecordList
.
as_view
(),
name
=
'network.record_list'
),
url
(
'^records/$'
,
RecordList
.
as_view
(),
name
=
'network.record_list'
),
url
(
'^records/create$'
,
RecordCreate
.
as_view
(),
url
(
'^records/create$'
,
RecordCreate
.
as_view
(),
name
=
'network.record_create'
),
name
=
'network.record_create'
),
...
@@ -69,10 +88,14 @@ urlpatterns = patterns(
...
@@ -69,10 +88,14 @@ urlpatterns = patterns(
name
=
'network.record'
),
name
=
'network.record'
),
url
(
'^records/delete/(?P<pk>
\
d+)/$'
,
RecordDelete
.
as_view
(),
url
(
'^records/delete/(?P<pk>
\
d+)/$'
,
RecordDelete
.
as_view
(),
name
=
"network.record_delete"
),
name
=
"network.record_delete"
),
# rule
url
(
'^rules/$'
,
RuleList
.
as_view
(),
name
=
'network.rule_list'
),
url
(
'^rules/$'
,
RuleList
.
as_view
(),
name
=
'network.rule_list'
),
url
(
'^rules/create$'
,
RuleCreate
.
as_view
(),
name
=
'network.rule_create'
),
url
(
'^rules/create$'
,
RuleCreate
.
as_view
(),
name
=
'network.rule_create'
),
url
(
'^rules/(?P<pk>
\
d+)/$'
,
RuleDetail
.
as_view
(),
url
(
'^rules/(?P<pk>
\
d+)/$'
,
RuleDetail
.
as_view
(),
name
=
'network.rule'
),
name
=
'network.rule'
),
# switchport
url
(
'^switchports/$'
,
SwitchPortList
.
as_view
(),
url
(
'^switchports/$'
,
SwitchPortList
.
as_view
(),
name
=
'network.switch_port_list'
),
name
=
'network.switch_port_list'
),
url
(
'^switchports/create$'
,
SwitchPortCreate
.
as_view
(),
url
(
'^switchports/create$'
,
SwitchPortCreate
.
as_view
(),
...
@@ -81,6 +104,8 @@ urlpatterns = patterns(
...
@@ -81,6 +104,8 @@ urlpatterns = patterns(
name
=
'network.switch_port'
),
name
=
'network.switch_port'
),
url
(
'^switchports/delete/(?P<pk>
\
d+)/$'
,
SwitchPortDelete
.
as_view
(),
url
(
'^switchports/delete/(?P<pk>
\
d+)/$'
,
SwitchPortDelete
.
as_view
(),
name
=
"network.switch_port_delete"
),
name
=
"network.switch_port_delete"
),
# vlan
url
(
'^vlans/$'
,
VlanList
.
as_view
(),
name
=
'network.vlan_list'
),
url
(
'^vlans/$'
,
VlanList
.
as_view
(),
name
=
'network.vlan_list'
),
url
(
'^vlans/create$'
,
VlanCreate
.
as_view
(),
name
=
'network.vlan_create'
),
url
(
'^vlans/create$'
,
VlanCreate
.
as_view
(),
name
=
'network.vlan_create'
),
url
(
'^vlans/(?P<vid>
\
d+)/$'
,
VlanDetail
.
as_view
(),
name
=
'network.vlan'
),
url
(
'^vlans/(?P<vid>
\
d+)/$'
,
VlanDetail
.
as_view
(),
name
=
'network.vlan'
),
...
@@ -88,6 +113,8 @@ urlpatterns = patterns(
...
@@ -88,6 +113,8 @@ urlpatterns = patterns(
name
=
'network.vlan-acl'
),
name
=
'network.vlan-acl'
),
url
(
'^vlans/delete/(?P<vid>
\
d+)/$'
,
VlanDelete
.
as_view
(),
url
(
'^vlans/delete/(?P<vid>
\
d+)/$'
,
VlanDelete
.
as_view
(),
name
=
"network.vlan_delete"
),
name
=
"network.vlan_delete"
),
# vlangroup
url
(
'^vlangroups/$'
,
VlanGroupList
.
as_view
(),
url
(
'^vlangroups/$'
,
VlanGroupList
.
as_view
(),
name
=
'network.vlan_group_list'
),
name
=
'network.vlan_group_list'
),
url
(
'^vlangroups/create$'
,
VlanGroupCreate
.
as_view
(),
url
(
'^vlangroups/create$'
,
VlanGroupCreate
.
as_view
(),
...
...
circle/network/views.py
View file @
015de106
...
@@ -25,15 +25,20 @@ from django.http import HttpResponse, Http404
...
@@ -25,15 +25,20 @@ from django.http import HttpResponse, Http404
from
django_tables2
import
SingleTableView
from
django_tables2
import
SingleTableView
from
firewall.models
import
(
Host
,
Vlan
,
Domain
,
Group
,
Record
,
BlacklistItem
,
from
firewall.models
import
(
Rule
,
VlanGroup
,
SwitchPort
,
EthernetDevice
)
Host
,
Vlan
,
Domain
,
Group
,
Record
,
BlacklistItem
,
Rule
,
VlanGroup
,
SwitchPort
,
EthernetDevice
,
Firewall
)
from
vm.models
import
Interface
from
vm.models
import
Interface
from
.tables
import
(
HostTable
,
VlanTable
,
SmallHostTable
,
DomainTable
,
from
.tables
import
(
GroupTable
,
RecordTable
,
BlacklistItemTable
,
RuleTable
,
HostTable
,
VlanTable
,
SmallHostTable
,
DomainTable
,
GroupTable
,
VlanGroupTable
,
SmallRuleTable
,
SmallGroupRuleTable
,
RecordTable
,
BlacklistItemTable
,
RuleTable
,
VlanGroupTable
,
SmallRecordTable
,
SwitchPortTable
,
SmallDhcpTable
,
)
SmallRuleTable
,
SmallGroupRuleTable
,
SmallRecordTable
,
SwitchPortTable
,
from
.forms
import
(
HostForm
,
VlanForm
,
DomainForm
,
GroupForm
,
RecordForm
,
SmallDhcpTable
,
FirewallTable
BlacklistItemForm
,
RuleForm
,
VlanGroupForm
,
SwitchPortForm
)
)
from
.forms
import
(
HostForm
,
VlanForm
,
DomainForm
,
GroupForm
,
RecordForm
,
BlacklistItemForm
,
RuleForm
,
VlanGroupForm
,
SwitchPortForm
,
FirewallForm
)
from
django.contrib
import
messages
from
django.contrib
import
messages
from
django.contrib.messages.views
import
SuccessMessageMixin
from
django.contrib.messages.views
import
SuccessMessageMixin
...
@@ -284,6 +289,50 @@ class DomainDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
...
@@ -284,6 +289,50 @@ class DomainDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
return
context
return
context
class
FirewallList
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SingleTableView
):
model
=
Firewall
table_class
=
FirewallTable
template_name
=
"network/firewall-list.html"
table_pagination
=
False
class
FirewallDetail
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SuccessMessageMixin
,
UpdateView
):
model
=
Firewall
template_name
=
"network/firewall-edit.html"
form_class
=
FirewallForm
success_message
=
_
(
u'Succesfully modified firewall.'
)
def
get_success_url
(
self
):
if
'pk'
in
self
.
kwargs
:
return
reverse_lazy
(
'network.firewall'
,
kwargs
=
self
.
kwargs
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
FirewallDetail
,
self
)
.
get_context_data
(
**
kwargs
)
return
context
class
FirewallCreate
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SuccessMessageMixin
,
CreateView
):
model
=
Firewall
template_name
=
"network/firewall-create.html"
form_class
=
FirewallForm
success_message
=
_
(
u'Successfully created firewall.'
)
class
FirewallDelete
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
DeleteView
):
model
=
Firewall
template_name
=
"network/confirm/base_delete.html"
def
get_success_url
(
self
):
next
=
self
.
request
.
POST
.
get
(
'next'
)
if
next
:
return
next
else
:
return
reverse_lazy
(
'network.firewall_list'
)
class
GroupList
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SingleTableView
):
class
GroupList
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SingleTableView
):
model
=
Group
model
=
Group
table_class
=
GroupTable
table_class
=
GroupTable
...
...
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