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
4e0f35e6
authored
Apr 29, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: support save_as with custom template name
parent
e5f5d4f4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
3 deletions
+43
-3
circle/dashboard/templates/dashboard/_vm-save.html
+21
-0
circle/dashboard/views.py
+22
-3
No files found.
circle/dashboard/templates/dashboard/_vm-save.html
0 → 100644
View file @
4e0f35e6
{% extends "dashboard/operate.html" %}
{% load i18n %}
{% load sizefieldtags %}
{% block question %}
<p>
{% blocktrans %}
Choose a name for the new template.
{% endblocktrans %}
</p>
<p
class=
"text-info"
>
{{op.name}}: {{op.description}}
</p>
{% endblock %}
{% block formfields %}
<div
class=
"form-group"
>
<label
for=
"input-name"
class=
"col-sm-4"
>
{% trans "Name of template" %}
</label>
<div
class=
"col-sm-8"
>
<input
type=
"text"
value=
"{{name}}"
name=
"name"
class=
"form-control"
/>
</div>
</div>
{% endblock %}
circle/dashboard/views.py
View file @
4e0f35e6
...
...
@@ -513,7 +513,7 @@ class VmMigrateView(VmOperationView):
template_name
=
'dashboard/_vm-migrate.html'
def
get_context_data
(
self
,
**
kwargs
):
ctx
=
super
(
Vm
Operation
View
,
self
)
.
get_context_data
(
**
kwargs
)
ctx
=
super
(
Vm
Migrate
View
,
self
)
.
get_context_data
(
**
kwargs
)
ctx
[
'nodes'
]
=
[
n
for
n
in
Node
.
objects
.
filter
(
enabled
=
True
)
if
n
.
state
==
"ONLINE"
]
return
ctx
...
...
@@ -528,6 +528,26 @@ class VmMigrateView(VmOperationView):
return
super
(
VmMigrateView
,
self
)
.
post
(
request
,
extra
,
*
args
,
**
kwargs
)
class
VmSaveView
(
VmOperationView
):
op
=
'save_as_template'
icon
=
'save'
template_name
=
'dashboard/_vm-save.html'
def
get_context_data
(
self
,
**
kwargs
):
ctx
=
super
(
VmSaveView
,
self
)
.
get_context_data
(
**
kwargs
)
ctx
[
'name'
]
=
self
.
get_op
()
.
_rename
(
self
.
object
.
name
)
return
ctx
def
post
(
self
,
request
,
extra
=
None
,
*
args
,
**
kwargs
):
if
extra
is
None
:
extra
=
{}
name
=
self
.
request
.
POST
.
get
(
"name"
)
if
name
:
extra
[
"name"
]
=
name
return
super
(
VmSaveView
,
self
)
.
post
(
request
,
extra
,
*
args
,
**
kwargs
)
vm_ops
=
{
'reset'
:
VmOperationView
.
factory
(
op
=
'reset'
,
icon
=
'bolt'
),
'deploy'
:
VmOperationView
.
factory
(
op
=
'deploy'
,
icon
=
'play'
),
...
...
@@ -535,8 +555,7 @@ vm_ops = {
'reboot'
:
VmOperationView
.
factory
(
op
=
'reboot'
,
icon
=
'refresh'
),
'shut_off'
:
VmOperationView
.
factory
(
op
=
'shut_off'
,
icon
=
'ban-circle'
),
'shutdown'
:
VmOperationView
.
factory
(
op
=
'shutdown'
,
icon
=
'off'
),
'save_as_template'
:
VmOperationView
.
factory
(
op
=
'save_as_template'
,
icon
=
'save'
),
'save_as_template'
:
VmSaveView
,
'destroy'
:
VmOperationView
.
factory
(
op
=
'destroy'
,
icon
=
'remove'
),
'sleep'
:
VmOperationView
.
factory
(
op
=
'sleep'
,
icon
=
'moon'
),
'wake_up'
:
VmOperationView
.
factory
(
op
=
'wake_up'
,
icon
=
'sun'
),
...
...
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