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
cb715174
authored
Jul 27, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: handle ops that return None
parent
f059aa28
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
circle/dashboard/views.py
+12
-6
No files found.
circle/dashboard/views.py
View file @
cb715174
...
@@ -69,6 +69,7 @@ from .tables import (
...
@@ -69,6 +69,7 @@ from .tables import (
NodeListTable
,
NodeVmListTable
,
TemplateListTable
,
LeaseListTable
,
NodeListTable
,
NodeVmListTable
,
TemplateListTable
,
LeaseListTable
,
GroupListTable
,
UserKeyListTable
GroupListTable
,
UserKeyListTable
)
)
from
common.models
import
HumanReadableObject
from
vm.models
import
(
from
vm.models
import
(
Instance
,
instance_activity
,
InstanceActivity
,
InstanceTemplate
,
Interface
,
Instance
,
instance_activity
,
InstanceActivity
,
InstanceTemplate
,
Interface
,
InterfaceTemplate
,
Lease
,
Node
,
NodeActivity
,
Trait
,
InterfaceTemplate
,
Lease
,
Node
,
NodeActivity
,
Trait
,
...
@@ -567,14 +568,16 @@ class OperationView(RedirectToLoginMixin, DetailView):
...
@@ -567,14 +568,16 @@ class OperationView(RedirectToLoginMixin, DetailView):
self
.
check_auth
()
self
.
check_auth
()
return
super
(
OperationView
,
self
)
.
get
(
request
,
*
args
,
**
kwargs
)
return
super
(
OperationView
,
self
)
.
get
(
request
,
*
args
,
**
kwargs
)
def
get_response_data
(
self
,
result
,
extra
=
None
,
**
kwargs
):
def
get_response_data
(
self
,
result
,
done
,
extra
=
None
,
**
kwargs
):
"""Return serializable data to return to agents requesting json
"""Return serializable data to return to agents requesting json
response to POST"""
response to POST"""
if
extra
is
None
:
if
extra
is
None
:
extra
=
{}
extra
=
{}
extra
[
"success"
]
=
not
isinstance
(
result
,
Exception
)
extra
[
"success"
]
=
not
isinstance
(
result
,
Exception
)
extra
[
"done"
]
=
result
is
not
None
extra
[
"done"
]
=
done
if
isinstance
(
result
,
HumanReadableObject
):
extra
[
"message"
]
=
result
.
get_user_text
()
return
extra
return
extra
def
post
(
self
,
request
,
extra
=
None
,
*
args
,
**
kwargs
):
def
post
(
self
,
request
,
extra
=
None
,
*
args
,
**
kwargs
):
...
@@ -583,6 +586,7 @@ class OperationView(RedirectToLoginMixin, DetailView):
...
@@ -583,6 +586,7 @@ class OperationView(RedirectToLoginMixin, DetailView):
if
extra
is
None
:
if
extra
is
None
:
extra
=
{}
extra
=
{}
result
=
None
result
=
None
done
=
False
try
:
try
:
task
=
self
.
get_op
()
.
async
(
user
=
request
.
user
,
**
extra
)
task
=
self
.
get_op
()
.
async
(
user
=
request
.
user
,
**
extra
)
except
Exception
as
e
:
except
Exception
as
e
:
...
@@ -603,12 +607,14 @@ class OperationView(RedirectToLoginMixin, DetailView):
...
@@ -603,12 +607,14 @@ class OperationView(RedirectToLoginMixin, DetailView):
logger
.
debug
(
"Operation failed."
,
exc_info
=
True
)
logger
.
debug
(
"Operation failed."
,
exc_info
=
True
)
result
=
e
result
=
e
else
:
else
:
done
=
True
messages
.
success
(
request
,
_
(
'Operation succeeded.'
))
messages
.
success
(
request
,
_
(
'Operation succeeded.'
))
if
result
is
None
:
if
result
is
None
and
not
done
:
messages
.
success
(
request
,
_
(
'Operation is started.'
))
messages
.
success
(
request
,
_
(
'Operation is started.'
))
if
"/json"
in
request
.
META
.
get
(
"HTTP_ACCEPT"
,
""
):
if
"/json"
in
request
.
META
.
get
(
"HTTP_ACCEPT"
,
""
):
data
=
self
.
get_response_data
(
result
,
post_extra
=
extra
,
**
kwargs
)
data
=
self
.
get_response_data
(
result
,
done
,
post_extra
=
extra
,
**
kwargs
)
return
HttpResponse
(
json
.
dumps
(
data
),
return
HttpResponse
(
json
.
dumps
(
data
),
content_type
=
"application/json"
)
content_type
=
"application/json"
)
else
:
else
:
...
@@ -862,8 +868,8 @@ class VmRenewView(FormOperationMixin, TokenOperationView, VmOperationView):
...
@@ -862,8 +868,8 @@ class VmRenewView(FormOperationMixin, TokenOperationView, VmOperationView):
val
.
update
({
'choices'
:
choices
,
'default'
:
default
})
val
.
update
({
'choices'
:
choices
,
'default'
:
default
})
return
val
return
val
def
get_response_data
(
self
,
result
,
extra
=
None
,
**
kwargs
):
def
get_response_data
(
self
,
result
,
done
,
extra
=
None
,
**
kwargs
):
extra
=
super
(
VmRenewView
,
self
)
.
get_response_data
(
result
,
extra
=
super
(
VmRenewView
,
self
)
.
get_response_data
(
result
,
done
,
extra
,
**
kwargs
)
extra
,
**
kwargs
)
extra
[
"new_suspend_time"
]
=
unicode
(
self
.
get_op
()
.
extra
[
"new_suspend_time"
]
=
unicode
(
self
.
get_op
()
.
instance
.
time_of_suspend
)
instance
.
time_of_suspend
)
...
...
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