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
435f4556
authored
Nov 13, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: add magic button to ipv6_template
parent
7afb202a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
4 deletions
+37
-4
circle/network/forms.py
+6
-2
circle/network/static/js/network.js
+8
-0
circle/network/views.py
+23
-2
No files found.
circle/network/forms.py
View file @
435f4556
...
...
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
django.forms
import
ModelForm
from
django.forms
import
ModelForm
,
widgets
from
django.core.urlresolvers
import
reverse_lazy
from
django.utils.translation
import
ugettext_lazy
as
_
...
...
@@ -254,7 +254,8 @@ class VlanForm(ModelForm):
Fieldset
(
_
(
'IPv6'
),
'network6'
,
'ipv6_template'
,
FieldWithButtons
(
'ipv6_template'
,
StrictButton
(
'<i class="fa fa-magic"></i>'
,
css_id
=
"ipv6-tpl-magic"
)),
'host_ipv6_prefixlen'
,
),
Fieldset
(
...
...
@@ -279,6 +280,9 @@ class VlanForm(ModelForm):
class
Meta
:
model
=
Vlan
widgets
=
{
'ipv6_template'
:
widgets
.
TextInput
,
}
class
VlanGroupForm
(
ModelForm
):
...
...
circle/network/static/js/network.js
View file @
435f4556
...
...
@@ -49,4 +49,12 @@ $("#ipv4-magic").click(function() {
}
}});
});
$
(
"#ipv6-tpl-magic"
).
click
(
function
()
{
$
.
ajax
({
url
:
window
.
location
,
data
:
{
network4
:
$
(
"[name=network4]"
).
val
(),
network6
:
$
(
"[name=network6]"
).
val
()},
success
:
function
(
data
)
{
$
(
"[name=ipv6_template]"
).
val
(
data
[
"ipv6_template"
]);
}});
});
});
circle/network/views.py
View file @
435f4556
...
...
@@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
netaddr
import
IPNetwork
from
django.views.generic
import
(
TemplateView
,
UpdateView
,
DeleteView
,
CreateView
)
from
django.core.exceptions
import
ValidationError
...
...
@@ -701,7 +702,27 @@ class VlanAclUpdateView(AclUpdateView):
model
=
Vlan
class
VlanDetail
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
class
VlanMagicMixin
(
object
):
def
_get_ajax
(
self
,
*
args
,
**
kwargs
):
GET
=
self
.
request
.
GET
result
=
{}
if
"network4"
in
GET
and
"network6"
in
GET
:
try
:
result
[
"ipv6_template"
]
=
Vlan
.
_magic_ipv6_template
(
IPNetwork
(
GET
[
'network4'
]),
IPNetwork
(
GET
[
'network6'
]))
except
:
result
[
"ipv6_template"
]
=
""
return
JsonResponse
({
k
:
unicode
(
result
[
k
]
or
""
)
for
k
in
result
})
def
get
(
self
,
*
args
,
**
kwargs
):
if
self
.
request
.
is_ajax
():
return
self
.
_get_ajax
(
*
args
,
**
kwargs
)
else
:
return
super
(
VlanMagicMixin
,
self
)
.
get
(
*
args
,
**
kwargs
)
class
VlanDetail
(
VlanMagicMixin
,
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SuccessMessageMixin
,
UpdateView
):
model
=
Vlan
template_name
=
"network/vlan-edit.html"
...
...
@@ -723,7 +744,7 @@ class VlanDetail(LoginRequiredMixin, SuperuserRequiredMixin,
success_url
=
reverse_lazy
(
'network.vlan_list'
)
class
VlanCreate
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
class
VlanCreate
(
VlanMagicMixin
,
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SuccessMessageMixin
,
InitialOwnerMixin
,
CreateView
):
model
=
Vlan
template_name
=
"network/vlan-create.html"
...
...
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