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
be51f177
authored
Mar 02, 2016
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: fix wrong content type for ajax requests
closes
#435
parent
dad93220
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
21 deletions
+13
-21
circle/dashboard/views/util.py
+7
-11
circle/dashboard/views/vm.py
+6
-10
No files found.
circle/dashboard/views/util.py
View file @
be51f177
...
@@ -30,7 +30,9 @@ from django.core.urlresolvers import reverse
...
@@ -30,7 +30,9 @@ from django.core.urlresolvers import reverse
from
django.contrib
import
messages
from
django.contrib
import
messages
from
django.contrib.auth.views
import
redirect_to_login
from
django.contrib.auth.views
import
redirect_to_login
from
django.db.models
import
Q
from
django.db.models
import
Q
from
django.http
import
HttpResponse
,
Http404
,
HttpResponseRedirect
from
django.http
import
(
HttpResponse
,
Http404
,
HttpResponseRedirect
,
JsonResponse
)
from
django.shortcuts
import
redirect
,
render
from
django.shortcuts
import
redirect
,
render
from
django.utils.translation
import
ugettext_lazy
as
_
,
ugettext_noop
from
django.utils.translation
import
ugettext_lazy
as
_
,
ugettext_noop
from
django.views.generic
import
DetailView
,
View
,
DeleteView
from
django.views.generic
import
DetailView
,
View
,
DeleteView
...
@@ -343,12 +345,9 @@ class AjaxOperationMixin(object):
...
@@ -343,12 +345,9 @@ class AjaxOperationMixin(object):
store
.
used
=
True
store
.
used
=
True
else
:
else
:
store
=
[]
store
=
[]
return
HttpResponse
(
return
JsonResponse
({
'success'
:
True
,
json
.
dumps
({
'success'
:
True
,
'with_reload'
:
self
.
with_reload
,
'with_reload'
:
self
.
with_reload
,
'messages'
:
[
unicode
(
m
)
for
m
in
store
]}),
'messages'
:
[
unicode
(
m
)
for
m
in
store
]})
content_type
=
"application=json"
)
else
:
else
:
return
resp
return
resp
...
@@ -378,11 +377,8 @@ class FormOperationMixin(object):
...
@@ -378,11 +377,8 @@ class FormOperationMixin(object):
resp
=
super
(
FormOperationMixin
,
self
)
.
post
(
resp
=
super
(
FormOperationMixin
,
self
)
.
post
(
request
,
extra
,
*
args
,
**
kwargs
)
request
,
extra
,
*
args
,
**
kwargs
)
if
request
.
is_ajax
():
if
request
.
is_ajax
():
return
HttpResponse
(
return
JsonResponse
({
'success'
:
True
,
json
.
dumps
({
'with_reload'
:
self
.
with_reload
})
'success'
:
True
,
'with_reload'
:
self
.
with_reload
}),
content_type
=
"application=json"
)
else
:
else
:
return
resp
return
resp
else
:
else
:
...
...
circle/dashboard/views/vm.py
View file @
be51f177
...
@@ -28,7 +28,9 @@ from django.contrib.auth.decorators import login_required
...
@@ -28,7 +28,9 @@ from django.contrib.auth.decorators import login_required
from
django.core
import
signing
from
django.core
import
signing
from
django.core.exceptions
import
PermissionDenied
,
SuspiciousOperation
from
django.core.exceptions
import
PermissionDenied
,
SuspiciousOperation
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
from
django.http
import
HttpResponse
,
Http404
,
HttpResponseRedirect
from
django.http
import
(
HttpResponse
,
Http404
,
HttpResponseRedirect
,
JsonResponse
)
from
django.shortcuts
import
redirect
,
get_object_or_404
from
django.shortcuts
import
redirect
,
get_object_or_404
from
django.template
import
RequestContext
from
django.template
import
RequestContext
from
django.template.loader
import
render_to_string
from
django.template.loader
import
render_to_string
...
@@ -274,10 +276,7 @@ class VmDetailView(GraphMixin, CheckedDetailView):
...
@@ -274,10 +276,7 @@ class VmDetailView(GraphMixin, CheckedDetailView):
message
=
u"Not success"
message
=
u"Not success"
if
request
.
is_ajax
():
if
request
.
is_ajax
():
return
HttpResponse
(
return
JsonResponse
({
'message'
:
message
})
json
.
dumps
({
'message'
:
message
}),
content_type
=
"application=json"
)
else
:
else
:
return
redirect
(
reverse_lazy
(
"dashboard.views.detail"
,
return
redirect
(
reverse_lazy
(
"dashboard.views.detail"
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}))
kwargs
=
{
'pk'
:
self
.
object
.
pk
}))
...
@@ -563,11 +562,8 @@ class VmResourcesChangeView(VmOperationView):
...
@@ -563,11 +562,8 @@ class VmResourcesChangeView(VmOperationView):
if
request
.
is_ajax
():
# this is not too nice
if
request
.
is_ajax
():
# this is not too nice
store
=
messages
.
get_messages
(
request
)
store
=
messages
.
get_messages
(
request
)
store
.
used
=
True
store
.
used
=
True
return
HttpResponse
(
return
JsonResponse
({
'success'
:
False
,
json
.
dumps
({
'success'
:
False
,
'messages'
:
[
unicode
(
m
)
for
m
in
store
]})
'messages'
:
[
unicode
(
m
)
for
m
in
store
]}),
content_type
=
"application=json"
)
else
:
else
:
return
HttpResponseRedirect
(
instance
.
get_absolute_url
()
+
return
HttpResponseRedirect
(
instance
.
get_absolute_url
()
+
"#resources"
)
"#resources"
)
...
...
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