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
03862384
authored
Jun 18, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: handle wrong inputs for vmforms
parent
99df6972
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
2 deletions
+49
-2
circle/dashboard/static/dashboard/vm-common.js
+36
-0
circle/dashboard/templates/dashboard/operate.html
+5
-1
circle/dashboard/views.py
+8
-1
No files found.
circle/dashboard/static/dashboard/vm-common.js
View file @
03862384
...
@@ -30,4 +30,40 @@ $(function() {
...
@@ -30,4 +30,40 @@ $(function() {
});
});
return
false
;
return
false
;
});
});
/* if the operation fails show the modal again */
$
(
"body"
).
on
(
"click"
,
"#op-form-send"
,
function
()
{
var
url
=
$
(
this
).
closest
(
"form"
).
prop
(
"action"
);
$
.
ajax
({
url
:
url
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
type
:
'POST'
,
data
:
$
(
this
).
closest
(
'form'
).
serialize
(),
success
:
function
(
data
,
textStatus
,
xhr
)
{
var
r
=
$
(
'#confirmation-modal'
);
r
.
next
(
'div'
).
remove
();
r
.
remove
();
if
(
data
.
redirect
)
{
$
(
'a[href="#activity"]'
).
trigger
(
"click"
);
}
else
{
$
(
'body'
).
append
(
data
);
$
(
'#confirmation-modal'
).
modal
(
'show'
);
$
(
'#confirmation-modal'
).
on
(
'hidden.bs.modal'
,
function
()
{
$
(
'#confirmation-modal'
).
remove
();
});
}
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
var
r
=
$
(
'#create-modal'
);
r
.
next
(
'div'
).
remove
();
r
.
remove
();
if
(
xhr
.
status
==
500
)
{
addMessage
(
"500 Internal Server Error"
,
"danger"
);
}
else
{
addMessage
(
xhr
.
status
+
" Unknown Error"
,
"danger"
);
}
}
});
return
false
;
});
});
});
circle/dashboard/templates/dashboard/operate.html
View file @
03862384
...
@@ -19,6 +19,10 @@ Do you want to do the following operation on {{obj}}:
...
@@ -19,6 +19,10 @@ Do you want to do the following operation on {{obj}}:
<div
class=
"pull-right"
>
<div
class=
"pull-right"
>
<a
class=
"btn btn-default"
href=
"{{object.get_absolute_url}}"
<a
class=
"btn btn-default"
href=
"{{object.get_absolute_url}}"
data-dismiss=
"modal"
>
{% trans "Cancel" %}
</a>
data-dismiss=
"modal"
>
{% trans "Cancel" %}
</a>
<button
class=
"btn btn-danger"
type=
"submit"
>
{% if op.icon %}
<i
class=
"icon-{{op.icon}}"
></i>
{% endif %}{{ op|capfirst }}
</button>
<button
class=
"btn btn-danger"
type=
"submit"
{%
if
form
%}
id=
"op-form-send"
{%
endif
%}
>
{% if op.icon %}
<i
class=
"icon-{{op.icon}}"
></i>
{% endif %}{{ op|capfirst }}
</button>
</div>
</div>
</form>
</form>
circle/dashboard/views.py
View file @
03862384
...
@@ -592,8 +592,15 @@ class FormOperationMixin(object):
...
@@ -592,8 +592,15 @@ class FormOperationMixin(object):
form
=
self
.
form_class
(
self
.
request
.
POST
)
form
=
self
.
form_class
(
self
.
request
.
POST
)
if
form
.
is_valid
():
if
form
.
is_valid
():
extra
.
update
(
form
.
cleaned_data
)
extra
.
update
(
form
.
cleaned_data
)
re
turn
super
(
FormOperationMixin
,
self
)
.
post
(
re
sp
=
super
(
FormOperationMixin
,
self
)
.
post
(
request
,
extra
,
*
args
,
**
kwargs
)
request
,
extra
,
*
args
,
**
kwargs
)
if
request
.
is_ajax
():
return
HttpResponse
(
json
.
dumps
({
'redirect'
:
resp
.
url
}),
content_type
=
"application=json"
)
else
:
return
resp
else
:
else
:
return
self
.
get
(
request
)
return
self
.
get
(
request
)
...
...
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