Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
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
8d391e1f
authored
Nov 12, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: accept initial fields in HostCreate
parent
84a1d61c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletions
+16
-1
circle/network/views.py
+16
-1
No files found.
circle/network/views.py
View file @
8d391e1f
...
@@ -17,8 +17,9 @@
...
@@ -17,8 +17,9 @@
from
django.views.generic
import
(
TemplateView
,
UpdateView
,
DeleteView
,
from
django.views.generic
import
(
TemplateView
,
UpdateView
,
DeleteView
,
CreateView
)
CreateView
)
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
from
django.shortcuts
import
render
,
redirect
,
get_object_or_404
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
django_tables2
import
SingleTableView
from
django_tables2
import
SingleTableView
...
@@ -409,6 +410,20 @@ class HostCreate(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -409,6 +410,20 @@ class HostCreate(LoginRequiredMixin, SuperuserRequiredMixin,
form_class
=
HostForm
form_class
=
HostForm
success_message
=
_
(
u'Successfully created host
%(hostname)
s!'
)
success_message
=
_
(
u'Successfully created host
%(hostname)
s!'
)
def
get_initial
(
self
):
initial
=
super
(
HostCreate
,
self
)
.
get_initial
()
for
i
in
(
"vlan"
,
"mac"
,
"hostname"
):
if
i
in
self
.
request
.
GET
and
i
not
in
self
.
request
.
POST
:
initial
[
i
]
=
self
.
request
.
GET
[
i
]
if
"vlan"
in
initial
:
vlan
=
get_object_or_404
(
Vlan
.
objects
,
pk
=
initial
[
'vlan'
])
try
:
initial
.
update
(
vlan
.
get_new_address
())
except
ValidationError
as
e
:
messages
.
error
(
self
.
request
,
e
.
message
)
return
initial
class
HostDelete
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
DeleteView
):
class
HostDelete
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
DeleteView
):
model
=
Host
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