Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
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
from
django.contrib
import
messages
from
django.contrib.auth.views
import
redirect_to_login
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.utils.translation
import
ugettext_lazy
as
_
,
ugettext_noop
from
django.views.generic
import
DetailView
,
View
,
DeleteView
...
...
@@ -343,12 +345,9 @@ class AjaxOperationMixin(object):
store
.
used
=
True
else
:
store
=
[]
return
HttpResponse
(
json
.
dumps
({
'success'
:
True
,
return
JsonResponse
({
'success'
:
True
,
'with_reload'
:
self
.
with_reload
,
'messages'
:
[
unicode
(
m
)
for
m
in
store
]}),
content_type
=
"application=json"
)
'messages'
:
[
unicode
(
m
)
for
m
in
store
]})
else
:
return
resp
...
...
@@ -378,11 +377,8 @@ class FormOperationMixin(object):
resp
=
super
(
FormOperationMixin
,
self
)
.
post
(
request
,
extra
,
*
args
,
**
kwargs
)
if
request
.
is_ajax
():
return
HttpResponse
(
json
.
dumps
({
'success'
:
True
,
'with_reload'
:
self
.
with_reload
}),
content_type
=
"application=json"
)
return
JsonResponse
({
'success'
:
True
,
'with_reload'
:
self
.
with_reload
})
else
:
return
resp
else
:
...
...
circle/dashboard/views/vm.py
View file @
be51f177
...
...
@@ -28,7 +28,9 @@ from django.contrib.auth.decorators import login_required
from
django.core
import
signing
from
django.core.exceptions
import
PermissionDenied
,
SuspiciousOperation
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.template
import
RequestContext
from
django.template.loader
import
render_to_string
...
...
@@ -274,10 +276,7 @@ class VmDetailView(GraphMixin, CheckedDetailView):
message
=
u"Not success"
if
request
.
is_ajax
():
return
HttpResponse
(
json
.
dumps
({
'message'
:
message
}),
content_type
=
"application=json"
)
return
JsonResponse
({
'message'
:
message
})
else
:
return
redirect
(
reverse_lazy
(
"dashboard.views.detail"
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}))
...
...
@@ -563,11 +562,8 @@ class VmResourcesChangeView(VmOperationView):
if
request
.
is_ajax
():
# this is not too nice
store
=
messages
.
get_messages
(
request
)
store
.
used
=
True
return
HttpResponse
(
json
.
dumps
({
'success'
:
False
,
'messages'
:
[
unicode
(
m
)
for
m
in
store
]}),
content_type
=
"application=json"
)
return
JsonResponse
({
'success'
:
False
,
'messages'
:
[
unicode
(
m
)
for
m
in
store
]})
else
:
return
HttpResponseRedirect
(
instance
.
get_absolute_url
()
+
"#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