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
0fecf77a
authored
May 06, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: remove template clone functionality
parent
17eb9faa
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
2 additions
and
128 deletions
+2
-128
circle/dashboard/forms.py
+0
-52
circle/dashboard/templates/dashboard/template-clone.html
+0
-39
circle/dashboard/templates/dashboard/template-list/column-template-actions.html
+0
-3
circle/dashboard/urls.py
+1
-3
circle/dashboard/views.py
+1
-31
No files found.
circle/dashboard/forms.py
View file @
0fecf77a
...
@@ -30,8 +30,6 @@ from crispy_forms.layout import (
...
@@ -30,8 +30,6 @@ from crispy_forms.layout import (
Layout
,
Div
,
BaseInput
,
Field
,
HTML
,
Submit
,
Fieldset
,
TEMPLATE_PACK
,
Layout
,
Div
,
BaseInput
,
Field
,
HTML
,
Submit
,
Fieldset
,
TEMPLATE_PACK
,
)
)
from
crispy_forms.bootstrap
import
UneditableField
as
UF
from
django.shortcuts
import
get_object_or_404
from
django.shortcuts
import
get_object_or_404
from
crispy_forms.utils
import
render_field
from
crispy_forms.utils
import
render_field
from
django
import
forms
from
django
import
forms
...
@@ -640,56 +638,6 @@ class TemplateForm(forms.ModelForm):
...
@@ -640,56 +638,6 @@ class TemplateForm(forms.ModelForm):
}
}
class
TemplateCloneForm
(
forms
.
ModelForm
):
uneditable_fields
=
[
'num_cores'
,
'priority'
,
'ram_size'
,
'max_ram_size'
,
'arch'
,
'access_method'
,
'boot_menu'
,
'raw_data'
,
'description'
,
'system'
,
'lease'
,
'tags'
]
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
clone_from
=
kwargs
.
pop
(
"clone_from"
)
self
.
user
=
kwargs
.
pop
(
"user"
)
super
(
TemplateCloneForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
data
=
self
.
data
.
copy
()
template
=
get_object_or_404
(
InstanceTemplate
,
pk
=
self
.
clone_from
)
for
f
in
self
.
uneditable_fields
:
self
.
initial
[
f
]
=
getattr
(
template
,
f
)
value
=
getattr
(
template
,
f
)
if
hasattr
(
value
,
"pk"
):
value
=
value
.
pk
data
.
update
({
'
%
s'
%
f
:
value
})
data
.
update
({
'owner'
:
self
.
user
.
pk
})
self
.
data
=
data
def
save
(
self
,
*
args
,
**
kwargs
):
pass
@property
def
helper
(
self
):
helper
=
FormHelper
()
ufs
=
[
UF
(
uf
)
for
uf
in
self
.
uneditable_fields
]
helper
.
layout
=
Layout
(
Fieldset
(
_
(
"Modify these"
),
Field
(
"name"
),
),
Fieldset
(
_
(
"You can't modify these ..."
),
*
ufs
)
)
helper
.
add_input
(
Submit
(
'submit'
,
_
(
'Clone template'
)))
return
helper
class
Meta
:
model
=
InstanceTemplate
exclude
=
(
'state'
,
'disks'
,
)
class
LeaseForm
(
forms
.
ModelForm
):
class
LeaseForm
(
forms
.
ModelForm
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
...
circle/dashboard/templates/dashboard/template-clone.html
deleted
100644 → 0
View file @
17eb9faa
{% extends "dashboard/base.html" %}
{% load i18n %}
{% load sizefieldtags %}
{% load crispy_forms_tags %}
{% block title-page %}{% trans "Clone template" %}{% endblock %}
{% block content %}
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<a
class=
"pull-right btn btn-default btn-xs"
href=
"{% url "
dashboard
.
views
.
template-list
"
%}"
>
{% trans "Back" %}
</a>
<h3
class=
"no-margin"
><i
class=
"icon-puzzle-piece"
></i>
{% trans "Clone template" %}
</h3>
</div>
<div
class=
"panel-body"
>
{% with form=form %}
{% include "display-form-errors.html" %}
{% endwith %}
{% crispy form %}
</div>
</div>
</div>
</div>
<!-- .row -->
<style>
fieldset
{
margin-top
:
40px
;
}
fieldset
legend
{
font-weight
:
bold
;
}
</style>
{% endblock %}
{% block extra_js %}
{% endblock %}
circle/dashboard/templates/dashboard/template-list/column-template-actions.html
View file @
0fecf77a
{% load i18n %}
{% load i18n %}
<a
href=
"{% url "
dashboard
.
views
.
template-clone
"
pk=
record.pk
%}"
id=
"template-list-clone-button"
class=
"btn btn-default btn-xs"
title=
"{% trans "
Clone
"
%}"
>
<i
class=
"icon-copy"
></i>
</a>
<a
href=
"{% url "
dashboard
.
views
.
template-detail
"
pk=
record.pk%}"
id=
"template-list-edit-button"
class=
"btn btn-default btn-xs"
title=
"{% trans "
Edit
"
%}"
>
<a
href=
"{% url "
dashboard
.
views
.
template-detail
"
pk=
record.pk%}"
id=
"template-list-edit-button"
class=
"btn btn-default btn-xs"
title=
"{% trans "
Edit
"
%}"
>
<i
class=
"icon-edit"
></i>
<i
class=
"icon-edit"
></i>
</a>
</a>
...
...
circle/dashboard/urls.py
View file @
0fecf77a
...
@@ -30,7 +30,7 @@ from .views import (
...
@@ -30,7 +30,7 @@ from .views import (
TransferOwnershipView
,
vm_activity
,
VmCreate
,
VmDelete
,
VmDetailView
,
TransferOwnershipView
,
vm_activity
,
VmCreate
,
VmDelete
,
VmDetailView
,
VmDetailVncTokenView
,
VmGraphView
,
VmList
,
VmMassDelete
,
VmMigrateView
,
VmDetailVncTokenView
,
VmGraphView
,
VmList
,
VmMassDelete
,
VmMigrateView
,
VmRenewView
,
DiskRemoveView
,
get_disk_download_status
,
InterfaceDeleteView
,
VmRenewView
,
DiskRemoveView
,
get_disk_download_status
,
InterfaceDeleteView
,
TemplateChoose
,
TemplateClone
,
TemplateChoose
,
)
)
urlpatterns
=
patterns
(
urlpatterns
=
patterns
(
...
@@ -55,8 +55,6 @@ urlpatterns = patterns(
...
@@ -55,8 +55,6 @@ urlpatterns = patterns(
name
=
"dashboard.views.template-list"
),
name
=
"dashboard.views.template-list"
),
url
(
r"^template/delete/(?P<pk>\d+)/$"
,
TemplateDelete
.
as_view
(),
url
(
r"^template/delete/(?P<pk>\d+)/$"
,
TemplateDelete
.
as_view
(),
name
=
"dashboard.views.template-delete"
),
name
=
"dashboard.views.template-delete"
),
url
(
r"^template/clone/(?P<pk>\d+)/$"
,
TemplateClone
.
as_view
(),
name
=
"dashboard.views.template-clone"
),
url
(
r'^vm/(?P<pk>\d+)/op/'
,
include
(
'dashboard.vm.urls'
)),
url
(
r'^vm/(?P<pk>\d+)/op/'
,
include
(
'dashboard.vm.urls'
)),
url
(
r'^vm/(?P<pk>\d+)/remove_port/(?P<rule>\d+)/$'
,
PortDelete
.
as_view
(),
url
(
r'^vm/(?P<pk>\d+)/remove_port/(?P<rule>\d+)/$'
,
PortDelete
.
as_view
(),
...
...
circle/dashboard/views.py
View file @
0fecf77a
...
@@ -52,7 +52,7 @@ from braces.views._access import AccessMixin
...
@@ -52,7 +52,7 @@ from braces.views._access import AccessMixin
from
.forms
import
(
from
.forms
import
(
CircleAuthenticationForm
,
DiskAddForm
,
HostForm
,
LeaseForm
,
MyProfileForm
,
CircleAuthenticationForm
,
DiskAddForm
,
HostForm
,
LeaseForm
,
MyProfileForm
,
NodeForm
,
TemplateForm
,
TraitForm
,
VmCustomizeForm
,
TemplateCloneForm
,
NodeForm
,
TemplateForm
,
TraitForm
,
VmCustomizeForm
,
CirclePasswordChangeForm
CirclePasswordChangeForm
)
)
from
.tables
import
(
NodeListTable
,
NodeVmListTable
,
from
.tables
import
(
NodeListTable
,
NodeVmListTable
,
...
@@ -865,36 +865,6 @@ class TemplateChoose(TemplateView):
...
@@ -865,36 +865,6 @@ class TemplateChoose(TemplateView):
return
redirect
(
instance
.
get_absolute_url
())
return
redirect
(
instance
.
get_absolute_url
())
class
TemplateClone
(
CreateView
):
template_name
=
"dashboard/template-clone.html"
form_class
=
TemplateCloneForm
model
=
InstanceTemplate
def
get_form_kwargs
(
self
):
kwargs
=
super
(
TemplateClone
,
self
)
.
get_form_kwargs
()
kwargs
[
'clone_from'
]
=
self
.
kwargs
[
'pk'
]
kwargs
[
'user'
]
=
self
.
request
.
user
return
kwargs
def
get
(
self
,
*
args
,
**
kwargs
):
if
not
self
.
request
.
user
.
has_perm
(
'vm.create_template'
):
raise
PermissionDenied
()
return
super
(
TemplateClone
,
self
)
.
get
(
*
args
,
**
kwargs
)
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
if
not
self
.
request
.
user
.
has_perm
(
'vm.create_template'
):
raise
PermissionDenied
()
form
=
self
.
form_class
(
request
.
POST
,
clone_from
=
kwargs
[
'pk'
],
user
=
request
.
user
)
if
not
form
.
is_valid
():
return
self
.
get
(
request
,
form
,
*
args
,
**
kwargs
)
else
:
# clone template
return
redirect
(
"/"
)
# temp
class
TemplateCreate
(
SuccessMessageMixin
,
CreateView
):
class
TemplateCreate
(
SuccessMessageMixin
,
CreateView
):
model
=
InstanceTemplate
model
=
InstanceTemplate
form_class
=
TemplateForm
form_class
=
TemplateForm
...
...
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