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/prog2
Commit
eff32210
authored
Dec 17, 2017
by
Barnabás Czémán
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ADD search & pagination
parent
3f1b8167
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
245 additions
and
75 deletions
+245
-75
circle/network/templates/network/blacklist-list.html
+14
-0
circle/network/templates/network/domain-list.html
+14
-0
circle/network/templates/network/firewall-list.html
+14
-0
circle/network/templates/network/group-list.html
+17
-1
circle/network/templates/network/record-list.html
+17
-2
circle/network/templates/network/vlan-group-list.html
+17
-1
circle/network/templates/network/vlan-list.html
+14
-0
circle/network/views.py
+138
-71
No files found.
circle/network/templates/network/blacklist-list.html
View file @
eff32210
...
@@ -12,6 +12,20 @@
...
@@ -12,6 +12,20 @@
<h1>
{% trans "Blacklist" %}
<small></small></h1>
<h1>
{% trans "Blacklist" %}
<small></small></h1>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-3"
>
<form
action=
""
method=
"GET"
id=
"network-blacklist-list-form"
>
<div
class=
"input-group"
>
<input
type=
"text"
id=
"network-blacklist-list-input"
name=
"s"
class=
"form-control"
value=
"{{ request.GET.s }}"
placeholder=
"{% trans "
Search
..."
%}"
/>
<span
class=
"input-group-btn"
>
<button
class=
"btn btn-primary"
><i
class=
"fa fa-search"
></i></button>
</span>
</div>
</form>
</div>
</div>
<div
class=
"table-responsive"
>
<div
class=
"table-responsive"
>
{% render_table table %}
{% render_table table %}
</div>
</div>
...
...
circle/network/templates/network/domain-list.html
View file @
eff32210
...
@@ -12,6 +12,20 @@
...
@@ -12,6 +12,20 @@
<h1>
{% trans "Domains" %}
</h1>
<h1>
{% trans "Domains" %}
</h1>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-3"
>
<form
action=
""
method=
"GET"
id=
"network-domain-list-form"
>
<div
class=
"input-group"
>
<input
type=
"text"
id=
"network-domain-list-input"
name=
"s"
class=
"form-control"
value=
"{{ request.GET.s }}"
placeholder=
"{% trans "
Search
..."
%}"
/>
<span
class=
"input-group-btn"
>
<button
class=
"btn btn-primary"
><i
class=
"fa fa-search"
></i></button>
</span>
</div>
</form>
</div>
</div>
<div
class=
"table-responsive"
>
<div
class=
"table-responsive"
>
{% render_table table %}
{% render_table table %}
</div>
</div>
...
...
circle/network/templates/network/firewall-list.html
View file @
eff32210
...
@@ -14,6 +14,20 @@
...
@@ -14,6 +14,20 @@
<h1>
{% trans "Firewalls" %}
</h1>
<h1>
{% trans "Firewalls" %}
</h1>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-3"
>
<form
action=
""
method=
"GET"
id=
"network-firewall-list-form"
>
<div
class=
"input-group"
>
<input
type=
"text"
id=
"network-firewall-list-input"
name=
"s"
class=
"form-control"
value=
"{{ request.GET.s }}"
placeholder=
"{% trans "
Search
..."
%}"
/>
<span
class=
"input-group-btn"
>
<button
class=
"btn btn-primary"
><i
class=
"fa fa-search"
></i></button>
</span>
</div>
</form>
</div>
</div>
<div
class=
"table-responsive"
>
<div
class=
"table-responsive"
>
{% render_table table %}
{% render_table table %}
</div>
</div>
...
...
circle/network/templates/network/group-list.html
View file @
eff32210
...
@@ -12,5 +12,21 @@
...
@@ -12,5 +12,21 @@
<h1>
{% trans "Host groups" %}
</h1>
<h1>
{% trans "Host groups" %}
</h1>
</div>
</div>
{% render_table table %}
<div
class=
"row"
>
<div
class=
"col-md-3"
>
<form
action=
""
method=
"GET"
id=
"network-group-list-form"
>
<div
class=
"input-group"
>
<input
type=
"text"
id=
"network-group-list-input"
name=
"s"
class=
"form-control"
value=
"{{ request.GET.s }}"
placeholder=
"{% trans "
Search
..."
%}"
/>
<span
class=
"input-group-btn"
>
<button
class=
"btn btn-primary"
><i
class=
"fa fa-search"
></i></button>
</span>
</div>
</form>
</div>
</div>
<div
class=
"table-responsive"
>
{% render_table table %}
</div>
{% endblock %}
{% endblock %}
circle/network/templates/network/record-list.html
View file @
eff32210
...
@@ -17,13 +17,28 @@
...
@@ -17,13 +17,28 @@
</h1>
</h1>
</div>
</div>
<ul
class=
"nav nav-pills"
style=
"margin: 5px 0 20px 0;"
>
<div
class=
"row"
>
<div
class=
"col-md-9"
>
<ul
class=
"nav nav-pills"
style=
"margin: 5px 0 20px 0;"
>
<li
class=
"disabled"
><a
href=
"#"
>
{% trans "Filter by type" %}
</a></li>
<li
class=
"disabled"
><a
href=
"#"
>
{% trans "Filter by type" %}
</a></li>
<li
{%
if
not
request
.
GET
.
type
%}
class=
"active"
{%
endif
%}
><a
href=
"{{ request.path }}"
>
{% trans "ALL" %}
</a></li>
<li
{%
if
not
request
.
GET
.
type
%}
class=
"active"
{%
endif
%}
><a
href=
"{{ request.path }}"
>
{% trans "ALL" %}
</a></li>
{% for type in types %}
{% for type in types %}
<li
{%
if
request
.
GET
.
type =
=
type
.
0
%}
class=
"active"
{%
endif
%}
><a
href=
"?type={{ type.0 }}"
>
{{ type.0 }}
</a></li>
<li
{%
if
request
.
GET
.
type =
=
type
.
0
%}
class=
"active"
{%
endif
%}
><a
href=
"?type={{ type.0 }}"
>
{{ type.0 }}
</a></li>
{% endfor %}
{% endfor %}
</ul>
</ul>
</div>
<div
class=
"col-md-3"
>
<form
action=
""
method=
"GET"
id=
"network-record-list-form"
>
<div
class=
"input-group"
>
<input
type=
"text"
id=
"network-record-list-input"
name=
"s"
class=
"form-control"
value=
"{{ request.GET.s }}"
placeholder=
"{% trans "
Search
..."
%}"
/>
<span
class=
"input-group-btn"
>
<button
class=
"btn btn-primary"
><i
class=
"fa fa-search"
></i></button>
</span>
</div>
</form>
</div>
</div>
<div
class=
"table-responsive"
>
<div
class=
"table-responsive"
>
{% render_table table %}
{% render_table table %}
...
...
circle/network/templates/network/vlan-group-list.html
View file @
eff32210
...
@@ -12,5 +12,21 @@
...
@@ -12,5 +12,21 @@
<h1>
{% trans "Vlan groups" %}
</h1>
<h1>
{% trans "Vlan groups" %}
</h1>
</div>
</div>
{% render_table table %}
<div
class=
"row"
>
<div
class=
"col-md-3"
>
<form
action=
""
method=
"GET"
id=
"network-blacklist-list-form"
>
<div
class=
"input-group"
>
<input
type=
"text"
id=
"network-blacklist-list-input"
name=
"s"
class=
"form-control"
value=
"{{ request.GET.s }}"
placeholder=
"{% trans "
Search
..."
%}"
/>
<span
class=
"input-group-btn"
>
<button
class=
"btn btn-primary"
><i
class=
"fa fa-search"
></i></button>
</span>
</div>
</form>
</div>
</div>
<div
class=
"table-responsive"
>
{% render_table table %}
</div>
{% endblock %}
{% endblock %}
circle/network/templates/network/vlan-list.html
View file @
eff32210
...
@@ -12,6 +12,20 @@
...
@@ -12,6 +12,20 @@
<h1>
Vlans
<small>
{% trans "list of all vlans" %}
</small></h1>
<h1>
Vlans
<small>
{% trans "list of all vlans" %}
</small></h1>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-3"
>
<form
action=
""
method=
"GET"
id=
"network-vlan-list-form"
>
<div
class=
"input-group"
>
<input
type=
"text"
id=
"network-vlan-list-input"
name=
"s"
class=
"form-control"
value=
"{{ request.GET.s }}"
placeholder=
"{% trans "
Search
..."
%}"
/>
<span
class=
"input-group-btn"
>
<button
class=
"btn btn-primary"
><i
class=
"fa fa-search"
></i></button>
</span>
</div>
</form>
</div>
</div>
<div
class=
"table-responsive"
>
<div
class=
"table-responsive"
>
{% render_table table %}
{% render_table table %}
</div>
</div>
...
...
circle/network/views.py
View file @
eff32210
...
@@ -23,7 +23,7 @@ from django.views.generic import (TemplateView, UpdateView, DeleteView,
...
@@ -23,7 +23,7 @@ from django.views.generic import (TemplateView, UpdateView, DeleteView,
from
django.core.exceptions
import
ValidationError
from
django.core.exceptions
import
ValidationError
from
django.core.urlresolvers
import
reverse_lazy
from
django.core.urlresolvers
import
reverse_lazy
from
django.shortcuts
import
render
,
redirect
,
get_object_or_404
from
django.shortcuts
import
render
,
redirect
,
get_object_or_404
from
django.http
import
Http
Response
,
Http
404
from
django.http
import
Http404
from
django.db.models
import
Q
from
django.db.models
import
Q
from
django_tables2
import
SingleTableView
from
django_tables2
import
SingleTableView
...
@@ -38,10 +38,7 @@ from .tables import (
...
@@ -38,10 +38,7 @@ from .tables import (
SmallRuleTable
,
SmallGroupRuleTable
,
SmallRecordTable
,
SwitchPortTable
,
SmallRuleTable
,
SmallGroupRuleTable
,
SmallRecordTable
,
SwitchPortTable
,
SmallDhcpTable
,
FirewallTable
,
FirewallRuleTable
,
SmallDhcpTable
,
FirewallTable
,
FirewallRuleTable
,
)
)
from
.forms
import
(
from
.
import
forms
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
...
@@ -54,22 +51,7 @@ from itertools import chain
...
@@ -54,22 +51,7 @@ from itertools import chain
from
dashboard.views
import
AclUpdateView
from
dashboard.views
import
AclUpdateView
from
dashboard.forms
import
AclUserOrGroupAddForm
from
dashboard.forms
import
AclUserOrGroupAddForm
try
:
from
django.http
import
JsonResponse
from
django.http
import
JsonResponse
except
ImportError
:
from
django.utils
import
simplejson
class
JsonResponse
(
HttpResponse
):
"""JSON response for Django < 1.7
https://gist.github.com/philippeowagner/3179eb475fe1795d6515
"""
def
__init__
(
self
,
content
,
mimetype
=
'application/json'
,
status
=
None
,
content_type
=
None
):
super
(
JsonResponse
,
self
)
.
__init__
(
content
=
simplejson
.
dumps
(
content
),
mimetype
=
mimetype
,
status
=
status
,
content_type
=
content_type
)
class
MagicMixin
(
object
):
class
MagicMixin
(
object
):
...
@@ -129,14 +111,24 @@ class BlacklistList(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -129,14 +111,24 @@ class BlacklistList(LoginRequiredMixin, SuperuserRequiredMixin,
model
=
BlacklistItem
model
=
BlacklistItem
table_class
=
BlacklistItemTable
table_class
=
BlacklistItemTable
template_name
=
"network/blacklist-list.html"
template_name
=
"network/blacklist-list.html"
table_pagination
=
False
table_pagination
=
{
'per_page'
:
25
}
def
get_table_data
(
self
):
data
=
self
.
model
.
objects
.
all
()
search
=
self
.
request
.
GET
.
get
(
"s"
)
if
search
:
data
=
data
.
filter
(
Q
(
host__hostname__icontains
=
search
)
|
Q
(
ipv4__icontains
=
search
)
|
Q
(
reason__icontains
=
search
))
return
data
class
BlacklistDetail
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
class
BlacklistDetail
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SuccessMessageMixin
,
UpdateView
):
SuccessMessageMixin
,
UpdateView
):
model
=
BlacklistItem
model
=
BlacklistItem
template_name
=
"network/blacklist-edit.html"
template_name
=
"network/blacklist-edit.html"
form_class
=
BlacklistItemForm
form_class
=
forms
.
BlacklistItemForm
success_message
=
_
(
u'Successfully modified blacklist item
%(ipv4)
s.'
)
success_message
=
_
(
u'Successfully modified blacklist item
%(ipv4)
s.'
)
def
get_success_url
(
self
):
def
get_success_url
(
self
):
...
@@ -153,7 +145,7 @@ class BlacklistCreate(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -153,7 +145,7 @@ class BlacklistCreate(LoginRequiredMixin, SuperuserRequiredMixin,
SuccessMessageMixin
,
CreateView
):
SuccessMessageMixin
,
CreateView
):
model
=
BlacklistItem
model
=
BlacklistItem
template_name
=
"network/blacklist-create.html"
template_name
=
"network/blacklist-create.html"
form_class
=
BlacklistItemForm
form_class
=
forms
.
BlacklistItemForm
success_message
=
_
(
u'Successfully created blacklist item
%(ipv4)
s'
)
success_message
=
_
(
u'Successfully created blacklist item
%(ipv4)
s'
)
...
@@ -181,14 +173,23 @@ class DomainList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
...
@@ -181,14 +173,23 @@ class DomainList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
model
=
Domain
model
=
Domain
table_class
=
DomainTable
table_class
=
DomainTable
template_name
=
"network/domain-list.html"
template_name
=
"network/domain-list.html"
table_pagination
=
False
table_pagination
=
{
'per_page'
:
25
}
def
get_table_data
(
self
):
data
=
self
.
model
.
objects
.
all
()
search
=
self
.
request
.
GET
.
get
(
"s"
)
if
search
:
data
=
self
.
model
.
objects
.
filter
(
Q
(
name__icontains
=
search
))
return
data
class
DomainDetail
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
class
DomainDetail
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SuccessMessageMixin
,
UpdateView
):
SuccessMessageMixin
,
UpdateView
):
model
=
Domain
model
=
Domain
template_name
=
"network/domain-edit.html"
template_name
=
"network/domain-edit.html"
form_class
=
DomainForm
form_class
=
forms
.
DomainForm
success_message
=
_
(
u'Successfully modified domain
%(name)
s.'
)
success_message
=
_
(
u'Successfully modified domain
%(name)
s.'
)
def
get_success_url
(
self
):
def
get_success_url
(
self
):
...
@@ -215,7 +216,7 @@ class DomainCreate(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -215,7 +216,7 @@ class DomainCreate(LoginRequiredMixin, SuperuserRequiredMixin,
SuccessMessageMixin
,
InitialOwnerMixin
,
CreateView
):
SuccessMessageMixin
,
InitialOwnerMixin
,
CreateView
):
model
=
Domain
model
=
Domain
template_name
=
"network/domain-create.html"
template_name
=
"network/domain-create.html"
form_class
=
DomainForm
form_class
=
forms
.
DomainForm
success_message
=
_
(
u'Successfully created domain
%(name)
s.'
)
success_message
=
_
(
u'Successfully created domain
%(name)
s.'
)
...
@@ -293,14 +294,24 @@ class FirewallList(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -293,14 +294,24 @@ class FirewallList(LoginRequiredMixin, SuperuserRequiredMixin,
model
=
Firewall
model
=
Firewall
table_class
=
FirewallTable
table_class
=
FirewallTable
template_name
=
"network/firewall-list.html"
template_name
=
"network/firewall-list.html"
table_pagination
=
False
table_pagination
=
{
'per_page'
:
25
}
def
get_table_data
(
self
):
data
=
self
.
model
.
objects
.
all
()
search
=
self
.
request
.
GET
.
get
(
"s"
)
if
search
:
data
=
data
.
filter
(
Q
(
name__icontains
=
search
))
return
data
class
FirewallDetail
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
class
FirewallDetail
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SuccessMessageMixin
,
UpdateView
):
SuccessMessageMixin
,
UpdateView
):
model
=
Firewall
model
=
Firewall
template_name
=
"network/firewall-edit.html"
template_name
=
"network/firewall-edit.html"
form_class
=
FirewallForm
form_class
=
forms
.
FirewallForm
success_message
=
_
(
u'Succesfully modified firewall.'
)
success_message
=
_
(
u'Succesfully modified firewall.'
)
def
get_success_url
(
self
):
def
get_success_url
(
self
):
...
@@ -319,7 +330,7 @@ class FirewallCreate(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -319,7 +330,7 @@ class FirewallCreate(LoginRequiredMixin, SuperuserRequiredMixin,
SuccessMessageMixin
,
CreateView
):
SuccessMessageMixin
,
CreateView
):
model
=
Firewall
model
=
Firewall
template_name
=
"network/firewall-create.html"
template_name
=
"network/firewall-create.html"
form_class
=
FirewallForm
form_class
=
forms
.
FirewallForm
success_message
=
_
(
u'Successfully created firewall.'
)
success_message
=
_
(
u'Successfully created firewall.'
)
...
@@ -339,14 +350,24 @@ class GroupList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
...
@@ -339,14 +350,24 @@ class GroupList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
model
=
Group
model
=
Group
table_class
=
GroupTable
table_class
=
GroupTable
template_name
=
"network/group-list.html"
template_name
=
"network/group-list.html"
table_pagination
=
False
table_pagination
=
{
'per_page'
:
25
}
def
get_table_data
(
self
):
data
=
self
.
model
.
objects
.
all
()
search
=
self
.
request
.
GET
.
get
(
"s"
)
if
search
:
data
=
data
.
filter
(
Q
(
name__icontains
=
search
)
|
Q
(
description__icontains
=
search
))
return
data
class
GroupCreate
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
class
GroupCreate
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SuccessMessageMixin
,
InitialOwnerMixin
,
CreateView
):
SuccessMessageMixin
,
InitialOwnerMixin
,
CreateView
):
model
=
Group
model
=
Group
template_name
=
"network/group-create.html"
template_name
=
"network/group-create.html"
form_class
=
GroupForm
form_class
=
forms
.
GroupForm
success_message
=
_
(
u'Successfully created host group
%(name)
s.'
)
success_message
=
_
(
u'Successfully created host group
%(name)
s.'
)
...
@@ -354,7 +375,7 @@ class GroupDetail(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -354,7 +375,7 @@ class GroupDetail(LoginRequiredMixin, SuperuserRequiredMixin,
SuccessMessageMixin
,
UpdateView
):
SuccessMessageMixin
,
UpdateView
):
model
=
Group
model
=
Group
template_name
=
"network/group-edit.html"
template_name
=
"network/group-edit.html"
form_class
=
GroupForm
form_class
=
forms
.
GroupForm
success_message
=
_
(
u'Successfully modified host group
%(name)
s.'
)
success_message
=
_
(
u'Successfully modified host group
%(name)
s.'
)
def
get_success_url
(
self
):
def
get_success_url
(
self
):
...
@@ -412,7 +433,9 @@ class HostList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
...
@@ -412,7 +433,9 @@ class HostList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
model
=
Host
model
=
Host
table_class
=
HostTable
table_class
=
HostTable
template_name
=
"network/host-list.html"
template_name
=
"network/host-list.html"
table_pagination
=
False
table_pagination
=
{
'per_page'
:
25
}
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
HostList
,
self
)
.
get_context_data
(
**
kwargs
)
context
=
super
(
HostList
,
self
)
.
get_context_data
(
**
kwargs
)
...
@@ -423,9 +446,9 @@ class HostList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
...
@@ -423,9 +446,9 @@ class HostList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
def
get_table_data
(
self
):
def
get_table_data
(
self
):
vlan_id
=
self
.
request
.
GET
.
get
(
'vlan'
)
vlan_id
=
self
.
request
.
GET
.
get
(
'vlan'
)
if
vlan_id
:
if
vlan_id
:
data
=
Host
.
objects
.
filter
(
vlan
=
vlan_id
)
.
select_related
()
data
=
self
.
model
.
objects
.
filter
(
vlan
=
vlan_id
)
.
select_related
()
else
:
else
:
data
=
Host
.
objects
.
select_related
()
data
=
self
.
model
.
objects
.
select_related
()
search
=
self
.
request
.
GET
.
get
(
"s"
)
search
=
self
.
request
.
GET
.
get
(
"s"
)
if
search
:
if
search
:
...
@@ -438,7 +461,7 @@ class HostDetail(HostMagicMixin, LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -438,7 +461,7 @@ class HostDetail(HostMagicMixin, LoginRequiredMixin, SuperuserRequiredMixin,
SuccessMessageMixin
,
UpdateView
):
SuccessMessageMixin
,
UpdateView
):
model
=
Host
model
=
Host
template_name
=
"network/host-edit.html"
template_name
=
"network/host-edit.html"
form_class
=
HostForm
form_class
=
forms
.
HostForm
success_message
=
_
(
u'Successfully modified host
%(hostname)
s.'
)
success_message
=
_
(
u'Successfully modified host
%(hostname)
s.'
)
def
_get_ajax
(
self
,
*
args
,
**
kwargs
):
def
_get_ajax
(
self
,
*
args
,
**
kwargs
):
...
@@ -511,7 +534,7 @@ class HostCreate(HostMagicMixin, LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -511,7 +534,7 @@ class HostCreate(HostMagicMixin, LoginRequiredMixin, SuperuserRequiredMixin,
SuccessMessageMixin
,
InitialOwnerMixin
,
CreateView
):
SuccessMessageMixin
,
InitialOwnerMixin
,
CreateView
):
model
=
Host
model
=
Host
template_name
=
"network/host-create.html"
template_name
=
"network/host-create.html"
form_class
=
HostForm
form_class
=
forms
.
HostForm
success_message
=
_
(
u'Successfully created host
%(hostname)
s.'
)
success_message
=
_
(
u'Successfully created host
%(hostname)
s.'
)
def
get_initial
(
self
):
def
get_initial
(
self
):
...
@@ -572,7 +595,9 @@ class RecordList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
...
@@ -572,7 +595,9 @@ class RecordList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
model
=
Record
model
=
Record
table_class
=
RecordTable
table_class
=
RecordTable
template_name
=
"network/record-list.html"
template_name
=
"network/record-list.html"
table_pagination
=
False
table_pagination
=
{
'per_page'
:
25
}
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
RecordList
,
self
)
.
get_context_data
(
**
kwargs
)
context
=
super
(
RecordList
,
self
)
.
get_context_data
(
**
kwargs
)
...
@@ -585,6 +610,11 @@ class RecordList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
...
@@ -585,6 +610,11 @@ class RecordList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
data
=
Record
.
objects
.
filter
(
type
=
type_id
)
.
select_related
()
data
=
Record
.
objects
.
filter
(
type
=
type_id
)
.
select_related
()
else
:
else
:
data
=
Record
.
objects
.
select_related
()
data
=
Record
.
objects
.
select_related
()
search
=
self
.
request
.
GET
.
get
(
"s"
)
if
search
:
data
=
data
.
filter
(
Q
(
host__hostname__icontains
=
search
)
|
Q
(
domain__name__icontains
=
search
))
return
data
return
data
...
@@ -592,7 +622,7 @@ class RecordDetail(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -592,7 +622,7 @@ class RecordDetail(LoginRequiredMixin, SuperuserRequiredMixin,
SuccessMessageMixin
,
UpdateView
):
SuccessMessageMixin
,
UpdateView
):
model
=
Record
model
=
Record
template_name
=
"network/record-edit.html"
template_name
=
"network/record-edit.html"
form_class
=
RecordForm
form_class
=
forms
.
RecordForm
# TODO fqdn
# TODO fqdn
success_message
=
_
(
u'Successfully modified record.'
)
success_message
=
_
(
u'Successfully modified record.'
)
...
@@ -611,7 +641,7 @@ class RecordCreate(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -611,7 +641,7 @@ class RecordCreate(LoginRequiredMixin, SuperuserRequiredMixin,
SuccessMessageMixin
,
InitialOwnerMixin
,
CreateView
):
SuccessMessageMixin
,
InitialOwnerMixin
,
CreateView
):
model
=
Record
model
=
Record
template_name
=
"network/record-create.html"
template_name
=
"network/record-create.html"
form_class
=
RecordForm
form_class
=
forms
.
RecordForm
# TODO fqdn
# TODO fqdn
success_message
=
_
(
u'Successfully created record.'
)
success_message
=
_
(
u'Successfully created record.'
)
...
@@ -651,7 +681,9 @@ class RuleList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
...
@@ -651,7 +681,9 @@ class RuleList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
model
=
Rule
model
=
Rule
table_class
=
RuleTable
table_class
=
RuleTable
template_name
=
"network/rule-list.html"
template_name
=
"network/rule-list.html"
table_pagination
=
False
table_pagination
=
{
'per_page'
:
25
}
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
self
.
types
=
OrderedDict
([
self
.
types
=
OrderedDict
([
...
@@ -664,8 +696,8 @@ class RuleList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
...
@@ -664,8 +696,8 @@ class RuleList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
return
context
return
context
def
get_table_data
(
self
):
def
get_table_data
(
self
):
rules
=
Rule
.
objects
.
select_related
(
'host'
,
'hostgroup'
,
'vlan'
,
rules
=
Rule
.
objects
.
select_related
(
'vlangroup'
,
'firewall'
,
'host'
,
'hostgroup'
,
'vlan'
,
'vlangroup'
,
'firewall'
,
'foreign_network'
,
'owner'
)
'foreign_network'
,
'owner'
)
rule_type
=
self
.
request
.
GET
.
get
(
"type"
)
rule_type
=
self
.
request
.
GET
.
get
(
"type"
)
...
@@ -678,7 +710,7 @@ class RuleDetail(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -678,7 +710,7 @@ class RuleDetail(LoginRequiredMixin, SuperuserRequiredMixin,
SuccessMessageMixin
,
UpdateView
):
SuccessMessageMixin
,
UpdateView
):
model
=
Rule
model
=
Rule
template_name
=
"network/rule-edit.html"
template_name
=
"network/rule-edit.html"
form_class
=
RuleForm
form_class
=
forms
.
RuleForm
success_message
=
_
(
u'Successfully modified rule.'
)
success_message
=
_
(
u'Successfully modified rule.'
)
def
get_success_url
(
self
):
def
get_success_url
(
self
):
...
@@ -698,7 +730,7 @@ class RuleCreate(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -698,7 +730,7 @@ class RuleCreate(LoginRequiredMixin, SuperuserRequiredMixin,
SuccessMessageMixin
,
InitialOwnerMixin
,
CreateView
):
SuccessMessageMixin
,
InitialOwnerMixin
,
CreateView
):
model
=
Rule
model
=
Rule
template_name
=
"network/rule-create.html"
template_name
=
"network/rule-create.html"
form_class
=
RuleForm
form_class
=
forms
.
RuleForm
success_message
=
_
(
u'Successfully created rule.'
)
success_message
=
_
(
u'Successfully created rule.'
)
def
get_initial
(
self
):
def
get_initial
(
self
):
...
@@ -727,14 +759,16 @@ class SwitchPortList(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -727,14 +759,16 @@ class SwitchPortList(LoginRequiredMixin, SuperuserRequiredMixin,
model
=
SwitchPort
model
=
SwitchPort
table_class
=
SwitchPortTable
table_class
=
SwitchPortTable
template_name
=
"network/switch-port-list.html"
template_name
=
"network/switch-port-list.html"
table_pagination
=
False
table_pagination
=
{
'per_page'
:
25
}
class
SwitchPortDetail
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
class
SwitchPortDetail
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SuccessMessageMixin
,
UpdateView
):
SuccessMessageMixin
,
UpdateView
):
model
=
SwitchPort
model
=
SwitchPort
template_name
=
"network/switch-port-edit.html"
template_name
=
"network/switch-port-edit.html"
form_class
=
SwitchPortForm
form_class
=
forms
.
SwitchPortForm
success_message
=
_
(
u'Succesfully modified switch port.'
)
success_message
=
_
(
u'Succesfully modified switch port.'
)
def
get_success_url
(
self
):
def
get_success_url
(
self
):
...
@@ -753,7 +787,7 @@ class SwitchPortCreate(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -753,7 +787,7 @@ class SwitchPortCreate(LoginRequiredMixin, SuperuserRequiredMixin,
SuccessMessageMixin
,
CreateView
):
SuccessMessageMixin
,
CreateView
):
model
=
SwitchPort
model
=
SwitchPort
template_name
=
"network/switch-port-create.html"
template_name
=
"network/switch-port-create.html"
form_class
=
SwitchPortForm
form_class
=
forms
.
SwitchPortForm
success_message
=
_
(
u'Successfully created switch port.'
)
success_message
=
_
(
u'Successfully created switch port.'
)
...
@@ -773,7 +807,17 @@ class VlanList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
...
@@ -773,7 +807,17 @@ class VlanList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
model
=
Vlan
model
=
Vlan
table_class
=
VlanTable
table_class
=
VlanTable
template_name
=
"network/vlan-list.html"
template_name
=
"network/vlan-list.html"
table_pagination
=
False
table_pagination
=
{
'per_page'
:
25
}
def
get_table_data
(
self
):
search
=
self
.
request
.
GET
.
get
(
"s"
)
data
=
self
.
model
.
objects
.
all
()
if
search
:
data
=
self
.
model
.
objects
.
filter
(
Q
(
name__icontains
=
search
))
return
data
class
VlanAclUpdateView
(
AclUpdateView
):
class
VlanAclUpdateView
(
AclUpdateView
):
...
@@ -798,7 +842,7 @@ class VlanDetail(VlanMagicMixin, LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -798,7 +842,7 @@ class VlanDetail(VlanMagicMixin, LoginRequiredMixin, SuperuserRequiredMixin,
SuccessMessageMixin
,
UpdateView
):
SuccessMessageMixin
,
UpdateView
):
model
=
Vlan
model
=
Vlan
template_name
=
"network/vlan-edit.html"
template_name
=
"network/vlan-edit.html"
form_class
=
VlanForm
form_class
=
forms
.
VlanForm
slug_field
=
'vid'
slug_field
=
'vid'
slug_url_kwarg
=
'vid'
slug_url_kwarg
=
'vid'
success_message
=
_
(
u'Succesfully modified vlan
%(name)
s.'
)
success_message
=
_
(
u'Succesfully modified vlan
%(name)
s.'
)
...
@@ -820,7 +864,7 @@ class VlanCreate(VlanMagicMixin, LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -820,7 +864,7 @@ class VlanCreate(VlanMagicMixin, LoginRequiredMixin, SuperuserRequiredMixin,
SuccessMessageMixin
,
InitialOwnerMixin
,
CreateView
):
SuccessMessageMixin
,
InitialOwnerMixin
,
CreateView
):
model
=
Vlan
model
=
Vlan
template_name
=
"network/vlan-create.html"
template_name
=
"network/vlan-create.html"
form_class
=
VlanForm
form_class
=
forms
.
VlanForm
success_message
=
_
(
u'Successfully created vlan
%(name)
s.'
)
success_message
=
_
(
u'Successfully created vlan
%(name)
s.'
)
...
@@ -871,6 +915,7 @@ class VlanDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
...
@@ -871,6 +915,7 @@ class VlanDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
context
[
'deps'
]
=
deps
context
[
'deps'
]
=
deps
context
[
'confirmation'
]
=
True
context
[
'confirmation'
]
=
True
return
context
return
context
...
@@ -879,14 +924,24 @@ class VlanGroupList(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -879,14 +924,24 @@ class VlanGroupList(LoginRequiredMixin, SuperuserRequiredMixin,
model
=
VlanGroup
model
=
VlanGroup
table_class
=
VlanGroupTable
table_class
=
VlanGroupTable
template_name
=
"network/vlan-group-list.html"
template_name
=
"network/vlan-group-list.html"
table_pagination
=
False
table_pagination
=
{
'per_page'
:
25
}
def
get_table_data
(
self
):
data
=
self
.
model
.
objects
.
all
()
search
=
self
.
request
.
GET
.
get
(
"s"
)
if
search
:
data
=
data
.
filter
(
Q
(
name__icontains
=
search
)
|
Q
(
description__icontains
=
search
))
return
data
class
VlanGroupDetail
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
class
VlanGroupDetail
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SuccessMessageMixin
,
UpdateView
):
SuccessMessageMixin
,
UpdateView
):
model
=
VlanGroup
model
=
VlanGroup
template_name
=
"network/vlan-group-edit.html"
template_name
=
"network/vlan-group-edit.html"
form_class
=
VlanGroupForm
form_class
=
forms
.
VlanGroupForm
success_url
=
reverse_lazy
(
'network.vlan_group_list'
)
success_url
=
reverse_lazy
(
'network.vlan_group_list'
)
success_message
=
_
(
u'Successfully modified vlan group
%(name)
s.'
)
success_message
=
_
(
u'Successfully modified vlan group
%(name)
s.'
)
...
@@ -900,7 +955,7 @@ class VlanGroupCreate(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -900,7 +955,7 @@ class VlanGroupCreate(LoginRequiredMixin, SuperuserRequiredMixin,
SuccessMessageMixin
,
InitialOwnerMixin
,
CreateView
):
SuccessMessageMixin
,
InitialOwnerMixin
,
CreateView
):
model
=
VlanGroup
model
=
VlanGroup
template_name
=
"network/vlan-group-create.html"
template_name
=
"network/vlan-group-create.html"
form_class
=
VlanGroupForm
form_class
=
forms
.
VlanGroupForm
success_message
=
_
(
u'Successfully created vlan group
%(name)
s.'
)
success_message
=
_
(
u'Successfully created vlan group
%(name)
s.'
)
...
@@ -922,22 +977,26 @@ def remove_host_group(request, **kwargs):
...
@@ -922,22 +977,26 @@ def remove_host_group(request, **kwargs):
# for get we show the confirmation page
# for get we show the confirmation page
if
request
.
method
==
"GET"
:
if
request
.
method
==
"GET"
:
return
render
(
request
,
return
render
(
request
,
'network/confirm/remove_host_group.html'
,
'network/confirm/remove_host_group.html'
,
{
{
'group'
:
group
.
name
,
'group'
:
group
.
name
,
'host'
:
host
.
hostname
'host'
:
host
.
hostname
})
}
)
# for post we actually remove the group from the host
# for post we actually remove the group from the host
elif
request
.
method
==
"POST"
:
elif
request
.
method
==
"POST"
:
host
.
groups
.
remove
(
group
)
host
.
groups
.
remove
(
group
)
if
not
request
.
is_ajax
():
if
not
request
.
is_ajax
():
messages
.
success
(
request
,
_
(
u"Successfully removed
%(host)
s from "
messages
.
success
(
"
%(group)
s group."
%
{
request
,
_
(
u"Successfully removed
%(host)
s from
%(group)
s group."
%
{
'host'
:
host
,
'host'
:
host
,
'group'
:
group
'group'
:
group
}))
})
)
return
redirect
(
reverse_lazy
(
'network.host'
,
return
redirect
(
reverse_lazy
(
'network.host'
,
kwargs
=
{
'pk'
:
kwargs
[
'pk'
]}))
kwargs
=
{
'pk'
:
kwargs
[
'pk'
]}))
...
@@ -949,11 +1008,13 @@ def add_host_group(request, **kwargs):
...
@@ -949,11 +1008,13 @@ def add_host_group(request, **kwargs):
group
=
Group
.
objects
.
get
(
pk
=
group_pk
)
group
=
Group
.
objects
.
get
(
pk
=
group_pk
)
host
.
groups
.
add
(
group
)
host
.
groups
.
add
(
group
)
if
not
request
.
is_ajax
():
if
not
request
.
is_ajax
():
messages
.
success
(
request
,
_
(
u"Successfully added
%(host)
s to group"
messages
.
success
(
"
%(group)
s."
%
{
request
,
_
(
u"Successfully added
%(host)
s to group
%(group)
s."
%
{
'host'
:
host
,
'host'
:
host
,
'group'
:
group
'group'
:
group
}))
})
)
return
redirect
(
reverse_lazy
(
'network.host'
,
kwargs
=
kwargs
))
return
redirect
(
reverse_lazy
(
'network.host'
,
kwargs
=
kwargs
))
...
@@ -968,10 +1029,12 @@ def remove_switch_port_device(request, **kwargs):
...
@@ -968,10 +1029,12 @@ def remove_switch_port_device(request, **kwargs):
elif
request
.
method
==
"POST"
:
elif
request
.
method
==
"POST"
:
device
.
delete
()
device
.
delete
()
if
not
request
.
is_ajax
():
if
not
request
.
is_ajax
():
messages
.
success
(
request
,
_
(
u"Successfully deleted ethernet device"
messages
.
success
(
"
%(name)
s."
%
{
request
,
_
(
u"Successfully deleted ethernet device
%(name)
s."
%
{
'name'
:
device
.
name
,
'name'
:
device
.
name
,
}))
})
)
return
redirect
(
reverse_lazy
(
'network.switch_port'
,
return
redirect
(
reverse_lazy
(
'network.switch_port'
,
kwargs
=
{
'pk'
:
kwargs
[
'pk'
]}))
kwargs
=
{
'pk'
:
kwargs
[
'pk'
]}))
...
@@ -986,16 +1049,20 @@ def add_switch_port_device(request, **kwargs):
...
@@ -986,16 +1049,20 @@ def add_switch_port_device(request, **kwargs):
new_device
=
EthernetDevice
(
name
=
device_name
,
switch_port
=
switch_port
)
new_device
=
EthernetDevice
(
name
=
device_name
,
switch_port
=
switch_port
)
new_device
.
save
()
new_device
.
save
()
if
not
request
.
is_ajax
():
if
not
request
.
is_ajax
():
messages
.
success
(
request
,
_
(
u"Successfully added
%(name)
s to this"
messages
.
success
(
" switch port"
%
{
request
,
_
(
u"Successfully added
%(name)
s to this switch port"
%
{
'name'
:
device_name
,
'name'
:
device_name
,
}))
})
)
return
redirect
(
reverse_lazy
(
'network.switch_port'
,
kwargs
=
kwargs
))
return
redirect
(
reverse_lazy
(
'network.switch_port'
,
kwargs
=
kwargs
))
elif
not
len
(
device_name
)
>
0
:
elif
not
len
(
device_name
)
>
0
:
messages
.
error
(
request
,
_
(
"Ethernet device name cannot be empty."
))
messages
.
error
(
request
,
_
(
"Ethernet device name cannot be empty."
))
return
redirect
(
reverse_lazy
(
'network.switch_port'
,
kwargs
=
kwargs
))
return
redirect
(
reverse_lazy
(
'network.switch_port'
,
kwargs
=
kwargs
))
elif
EthernetDevice
.
objects
.
get
(
name
=
device_name
)
is
not
None
:
elif
EthernetDevice
.
objects
.
get
(
name
=
device_name
)
is
not
None
:
messages
.
error
(
request
,
_
(
"There is already an ethernet device with"
messages
.
error
(
" that name."
))
request
,
_
(
"There is already an ethernet device with that name."
)
)
return
redirect
(
reverse_lazy
(
'network.switch_port'
,
kwargs
=
kwargs
))
return
redirect
(
reverse_lazy
(
'network.switch_port'
,
kwargs
=
kwargs
))
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