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
9bbbc3ad
authored
Jul 09, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: allow choosing lease for renew
parent
883ba7ec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
2 deletions
+42
-2
circle/dashboard/forms.py
+28
-0
circle/dashboard/views.py
+14
-2
No files found.
circle/dashboard/forms.py
View file @
9bbbc3ad
...
@@ -888,6 +888,34 @@ class LeaseForm(forms.ModelForm):
...
@@ -888,6 +888,34 @@ class LeaseForm(forms.ModelForm):
model
=
Lease
model
=
Lease
class
VmRenewForm
(
forms
.
Form
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
choices
=
kwargs
.
pop
(
'choices'
)
default
=
kwargs
.
pop
(
'default'
)
super
(
VmRenewForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
'lease'
]
=
forms
.
ModelChoiceField
(
queryset
=
choices
,
initial
=
default
,
required
=
True
,
label
=
_
(
'Length'
))
if
len
(
choices
)
<
2
:
self
.
fields
[
'lease'
]
.
widget
=
HiddenInput
()
def
clean_size
(
self
):
size_in_bytes
=
self
.
cleaned_data
.
get
(
"size"
)
if
not
size_in_bytes
.
isdigit
()
and
len
(
size_in_bytes
)
>
0
:
raise
forms
.
ValidationError
(
_
(
"Invalid format, you can use "
" GB or MB!"
))
return
size_in_bytes
@property
def
helper
(
self
):
helper
=
FormHelper
(
self
)
helper
.
form_tag
=
False
return
helper
class
VmCreateDiskForm
(
forms
.
Form
):
class
VmCreateDiskForm
(
forms
.
Form
):
name
=
forms
.
CharField
(
max_length
=
100
,
label
=
_
(
"Name"
))
name
=
forms
.
CharField
(
max_length
=
100
,
label
=
_
(
"Name"
))
size
=
forms
.
CharField
(
size
=
forms
.
CharField
(
...
...
circle/dashboard/views.py
View file @
9bbbc3ad
...
@@ -60,7 +60,7 @@ from .forms import (
...
@@ -60,7 +60,7 @@ from .forms import (
CircleAuthenticationForm
,
HostForm
,
LeaseForm
,
MyProfileForm
,
CircleAuthenticationForm
,
HostForm
,
LeaseForm
,
MyProfileForm
,
NodeForm
,
TemplateForm
,
TraitForm
,
VmCustomizeForm
,
GroupCreateForm
,
NodeForm
,
TemplateForm
,
TraitForm
,
VmCustomizeForm
,
GroupCreateForm
,
UserCreationForm
,
GroupProfileUpdateForm
,
UnsubscribeForm
,
UserCreationForm
,
GroupProfileUpdateForm
,
UnsubscribeForm
,
VmSaveForm
,
UserKeyForm
,
VmSaveForm
,
UserKeyForm
,
VmRenewForm
,
CirclePasswordChangeForm
,
VmCreateDiskForm
,
VmDownloadDiskForm
,
CirclePasswordChangeForm
,
VmCreateDiskForm
,
VmDownloadDiskForm
,
TraitsForm
,
RawDataForm
,
GroupPermissionForm
TraitsForm
,
RawDataForm
,
GroupPermissionForm
)
)
...
@@ -818,11 +818,23 @@ class TokenOperationView(OperationView):
...
@@ -818,11 +818,23 @@ class TokenOperationView(OperationView):
return
user
return
user
class
VmRenewView
(
TokenOperationView
,
VmOperationView
):
class
VmRenewView
(
FormOperationMixin
,
TokenOperationView
,
VmOperationView
):
op
=
'renew'
op
=
'renew'
icon
=
'calendar'
icon
=
'calendar'
effect
=
'info'
effect
=
'info'
show_in_toolbar
=
False
show_in_toolbar
=
False
form_class
=
VmRenewForm
def
get_form_kwargs
(
self
):
choices
=
Lease
.
get_objects_with_level
(
"user"
,
self
.
request
.
user
)
default
=
self
.
get_op
()
.
instance
.
lease
if
default
and
default
not
in
choices
:
choices
|=
Lease
.
objects
.
filter
(
pk
=
default
.
pk
)
val
=
super
(
VmRenewView
,
self
)
.
get_form_kwargs
()
val
.
update
({
'choices'
:
choices
,
'default'
:
default
})
return
val
vm_ops
=
OrderedDict
([
vm_ops
=
OrderedDict
([
...
...
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