Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
4d19cb51
authored
Jul 24, 2014
by
Őry Máté
Committed by
Bach Dániel
Jul 26, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: provide json response for Operation.post
parent
b96a124a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
circle/dashboard/views.py
+19
-0
No files found.
circle/dashboard/views.py
View file @
4d19cb51
...
@@ -490,6 +490,7 @@ class OperationView(RedirectToLoginMixin, DetailView):
...
@@ -490,6 +490,7 @@ class OperationView(RedirectToLoginMixin, DetailView):
template_name
=
'dashboard/operate.html'
template_name
=
'dashboard/operate.html'
show_in_toolbar
=
True
show_in_toolbar
=
True
effect
=
None
effect
=
None
wait_for_result
=
None
@property
@property
def
name
(
self
):
def
name
(
self
):
...
@@ -551,18 +552,36 @@ class OperationView(RedirectToLoginMixin, DetailView):
...
@@ -551,18 +552,36 @@ 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
):
"""Return serializable data to return to agents requesting json
response to POST"""
if
extra
is
None
:
extra
=
{}
extra
[
"success"
]
=
not
isinstance
(
result
,
Exception
)
extra
[
"done"
]
=
result
is
not
None
return
extra
def
post
(
self
,
request
,
extra
=
None
,
*
args
,
**
kwargs
):
def
post
(
self
,
request
,
extra
=
None
,
*
args
,
**
kwargs
):
self
.
check_auth
()
self
.
check_auth
()
self
.
object
=
self
.
get_object
()
self
.
object
=
self
.
get_object
()
if
extra
is
None
:
if
extra
is
None
:
extra
=
{}
extra
=
{}
result
=
None
try
:
try
:
self
.
get_op
()
.
async
(
user
=
request
.
user
,
**
extra
)
self
.
get_op
()
.
async
(
user
=
request
.
user
,
**
extra
)
except
Exception
as
e
:
except
Exception
as
e
:
messages
.
error
(
request
,
_
(
'Could not start operation.'
))
messages
.
error
(
request
,
_
(
'Could not start operation.'
))
logger
.
exception
(
e
)
logger
.
exception
(
e
)
result
=
e
else
:
else
:
messages
.
success
(
request
,
_
(
'Operation is started.'
))
messages
.
success
(
request
,
_
(
'Operation is started.'
))
if
"/json"
in
request
.
META
.
get
(
"HTTP_ACCEPT"
,
""
):
data
=
self
.
get_response_data
(
result
,
post_extra
=
extra
,
**
kwargs
)
return
HttpResponse
(
json
.
dumps
(
data
),
content_type
=
"application/json"
)
else
:
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
@classmethod
@classmethod
...
...
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