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
Commit
883ba7ec
authored
Jul 09, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add FormOperationMixin.get_form_kwargs method
this allows sending custom parameters to form constructors
parent
62a43cb3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
circle/dashboard/views.py
+15
-3
No files found.
circle/dashboard/views.py
View file @
883ba7ec
...
@@ -632,18 +632,22 @@ class FormOperationMixin(object):
...
@@ -632,18 +632,22 @@ class FormOperationMixin(object):
form_class
=
None
form_class
=
None
def
get_form_kwargs
(
self
):
return
{}
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
ctx
=
super
(
FormOperationMixin
,
self
)
.
get_context_data
(
**
kwargs
)
ctx
=
super
(
FormOperationMixin
,
self
)
.
get_context_data
(
**
kwargs
)
if
self
.
request
.
method
==
'POST'
:
if
self
.
request
.
method
==
'POST'
:
ctx
[
'form'
]
=
self
.
form_class
(
self
.
request
.
POST
)
ctx
[
'form'
]
=
self
.
form_class
(
self
.
request
.
POST
,
**
self
.
get_form_kwargs
())
else
:
else
:
ctx
[
'form'
]
=
self
.
form_class
()
ctx
[
'form'
]
=
self
.
form_class
(
**
self
.
get_form_kwargs
()
)
return
ctx
return
ctx
def
post
(
self
,
request
,
extra
=
None
,
*
args
,
**
kwargs
):
def
post
(
self
,
request
,
extra
=
None
,
*
args
,
**
kwargs
):
if
extra
is
None
:
if
extra
is
None
:
extra
=
{}
extra
=
{}
form
=
self
.
form_class
(
self
.
request
.
POST
)
form
=
self
.
form_class
(
self
.
request
.
POST
,
**
self
.
get_form_kwargs
()
)
if
form
.
is_valid
():
if
form
.
is_valid
():
extra
.
update
(
form
.
cleaned_data
)
extra
.
update
(
form
.
cleaned_data
)
resp
=
super
(
FormOperationMixin
,
self
)
.
post
(
resp
=
super
(
FormOperationMixin
,
self
)
.
post
(
...
@@ -659,6 +663,14 @@ class FormOperationMixin(object):
...
@@ -659,6 +663,14 @@ class FormOperationMixin(object):
return
self
.
get
(
request
)
return
self
.
get
(
request
)
class
RequestFormOperationMixin
(
FormOperationMixin
):
def
get_form_kwargs
(
self
):
val
=
super
(
FormOperationMixin
,
self
)
.
get_form_kwargs
()
val
.
update
({
'request'
:
self
.
request
})
return
val
class
VmCreateDiskView
(
FormOperationMixin
,
VmOperationView
):
class
VmCreateDiskView
(
FormOperationMixin
,
VmOperationView
):
op
=
'create_disk'
op
=
'create_disk'
...
...
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