Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
ab4fd03d
Commit
ab4fd03d
authored
Jan 30, 2013
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Catch any and all save errors
parent
b8c1dba1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
9 deletions
+41
-9
cms/static/js/models/settings/course_details.js
+10
-2
cms/static/js/views/settings/main_settings_view.js
+31
-7
No files found.
cms/static/js/models/settings/course_details.js
View file @
ab4fd03d
...
...
@@ -68,10 +68,18 @@ CMS.Models.Settings.CourseDetails = Backbone.Model.extend({
save_videosource
:
function
(
newsource
)
{
// newsource either is <video youtube="speed:key, *"/> or just the "speed:key, *" string
// returns the videosource for the preview which iss the key whose speed is closest to 1
if
(
_
.
isEmpty
(
newsource
)
&&
!
_
.
isEmpty
(
this
.
get
(
'intro_video'
)))
this
.
save
({
'intro_video'
:
null
});
if
(
_
.
isEmpty
(
newsource
)
&&
!
_
.
isEmpty
(
this
.
get
(
'intro_video'
)))
this
.
save
({
'intro_video'
:
null
},
{
error
:
function
(
model
,
error
)
{
// this handler is for the client:server communication not the vlidation errors which handleValidationError catches
window
.
alert
(
"Error during save: "
+
error
.
responseText
);
}});
// TODO remove all whitespace w/in string
else
{
if
(
this
.
get
(
'intro_video'
)
!==
newsource
)
this
.
save
(
'intro_video'
,
newsource
);
if
(
this
.
get
(
'intro_video'
)
!==
newsource
)
this
.
save
(
'intro_video'
,
newsource
,
{
error
:
function
(
model
,
error
)
{
// this handler is for the client:server communication not the vlidation errors which handleValidationError catches
window
.
alert
(
"Error during save: "
+
error
.
responseText
);
}});
}
return
this
.
videosourceSample
();
...
...
cms/static/js/views/settings/main_settings_view.js
View file @
ab4fd03d
...
...
@@ -57,7 +57,7 @@ CMS.Views.ValidatingView = Backbone.View.extend({
this
.
clearValidationErrors
();
this
.
model
.
save
(
field
,
newVal
,
{
error
:
function
(
model
,
error
)
{
// this handler is for the client:server communication not the vlidation errors which handleValidationError catches
if
(
error
.
responseText
)
window
.
alert
(
"Error
: "
+
error
.
responseText
);
window
.
alert
(
"Error during save
: "
+
error
.
responseText
);
}});
return
true
;
}
...
...
@@ -230,7 +230,11 @@ CMS.Views.Settings.Details = CMS.Views.ValidatingView.extend({
time
=
0
;
}
var
newVal
=
new
Date
(
date
.
getTime
()
+
time
*
1000
);
if
(
cacheModel
.
get
(
fieldName
)
!=
newVal
)
cacheModel
.
save
(
fieldName
,
newVal
);
if
(
cacheModel
.
get
(
fieldName
)
!=
newVal
)
cacheModel
.
save
(
fieldName
,
newVal
,
{
error
:
function
(
model
,
error
)
{
// this handler is for the client:server communication not the vlidation errors which handleValidationError catches
window
.
alert
(
"Error during save: "
+
error
.
responseText
);
}});
}
};
...
...
@@ -279,7 +283,11 @@ CMS.Views.Settings.Details = CMS.Views.ValidatingView.extend({
},
removeSyllabus
:
function
()
{
if
(
this
.
model
.
has
(
'syllabus'
))
this
.
model
.
save
({
'syllabus'
:
null
});
if
(
this
.
model
.
has
(
'syllabus'
))
this
.
model
.
save
({
'syllabus'
:
null
},
{
error
:
function
(
model
,
error
)
{
// this handler is for the client:server communication not the vlidation errors which handleValidationError catches
window
.
alert
(
"Error during save: "
+
error
.
responseText
);
}});
},
assetSyllabus
:
function
()
{
...
...
@@ -312,7 +320,11 @@ CMS.Views.Settings.Details = CMS.Views.ValidatingView.extend({
mirror
.
save
();
cachethis
.
clearValidationErrors
();
var
newVal
=
mirror
.
getValue
();
if
(
cachethis
.
model
.
get
(
field
)
!=
newVal
)
cachethis
.
model
.
save
(
field
,
newVal
);
if
(
cachethis
.
model
.
get
(
field
)
!=
newVal
)
cachethis
.
model
.
save
(
field
,
newVal
,
{
error
:
function
(
model
,
error
)
{
// this handler is for the client:server communication not the vlidation errors which handleValidationError catches
window
.
alert
(
"Error during save: "
+
error
.
responseText
);
}});
}
});
}
...
...
@@ -407,7 +419,11 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
setGracePeriod
:
function
(
event
)
{
event
.
data
.
clearValidationErrors
();
var
newVal
=
event
.
data
.
model
.
dateToGracePeriod
(
$
(
event
.
currentTarget
).
timepicker
(
'getTime'
));
if
(
event
.
data
.
model
.
get
(
'grace_period'
)
!=
newVal
)
event
.
data
.
model
.
save
(
'grace_period'
,
newVal
);
if
(
event
.
data
.
model
.
get
(
'grace_period'
)
!=
newVal
)
event
.
data
.
model
.
save
(
'grace_period'
,
newVal
,
{
error
:
function
(
model
,
error
)
{
// this handler is for the client:server communication not the vlidation errors which handleValidationError catches
window
.
alert
(
"Error during save: "
+
error
.
responseText
);
}});
},
updateModel
:
function
(
event
)
{
if
(
!
this
.
selectorToField
[
event
.
currentTarget
.
id
])
return
;
...
...
@@ -543,7 +559,11 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
object
[
cutoff
[
'designation'
]]
=
cutoff
[
'cutoff'
]
/
100.0
;
return
object
;
},
{}));
{}),
{
error
:
function
(
model
,
error
)
{
// this handler is for the client:server communication not the vlidation errors which handleValidationError catches
window
.
alert
(
"Error during save: "
+
error
.
responseText
);
}});
},
addNewGrade
:
function
(
e
)
{
...
...
@@ -674,7 +694,11 @@ CMS.Views.Settings.GraderView = CMS.Views.ValidatingView.extend({
}
},
deleteModel
:
function
(
e
)
{
this
.
model
.
destroy
();
this
.
model
.
destroy
(
{
error
:
function
(
model
,
error
)
{
// this handler is for the client:server communication not the vlidation errors which handleValidationError catches
window
.
alert
(
"Error during save: "
+
error
.
responseText
);
}});
e
.
preventDefault
();
}
...
...
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