Commit f29819ca by Chris Dodge Committed by Brian Talbot

add some field specific error messages regarding uniqueness

parent 2c61ad45
...@@ -121,13 +121,21 @@ def create_new_course(request): ...@@ -121,13 +121,21 @@ def create_new_course(request):
return JsonResponse( return JsonResponse(
{ {
'ErrMsg': _('There is already a course defined with the same organization, course number, and course run. Please change at least one field to be unique.'), 'ErrMsg': _('There is already a course defined with the same organization, course number, and course run. Please change at least one field to be unique.'),
'OrgErrMsg': _('Either of organization or course number must be unique.'),
'CourseErrMsg': _('Either of organization or course number must be unique.'),
} }
) )
course_search_location = ['i4x', dest_location.org, dest_location.course, 'course', None] course_search_location = ['i4x', dest_location.org, dest_location.course, 'course', None]
courses = modulestore().get_items(course_search_location) courses = modulestore().get_items(course_search_location)
if len(courses) > 0: if len(courses) > 0:
return JsonResponse({'ErrMsg': _('There is already a course defined with the same organization and course number. Please change at least one field to be unique.')}) return JsonResponse(
{
'ErrMsg': _('There is already a course defined with the same organization and course number. Please change at least one field to be unique.'),
'OrgErrMsg': _('Either of organization or course number must be unique.'),
'CourseErrMsg': _('Either of organization or course number must be unique.'),
}
)
# instantiate the CourseDescriptor and then persist it # instantiate the CourseDescriptor and then persist it
# note: no system to pass # note: no system to pass
......
...@@ -677,7 +677,9 @@ function saveNewCourse(e) { ...@@ -677,7 +677,9 @@ function saveNewCourse(e) {
if (data.id !== undefined) { if (data.id !== undefined) {
window.location = '/' + data.id.replace(/.*:\/\//, ''); window.location = '/' + data.id.replace(/.*:\/\//, '');
} else if (data.ErrMsg !== undefined) { } else if (data.ErrMsg !== undefined) {
setNewCourseErrMsgs(data.ErrMsg, null, null, null, null); orgErrMsg = (data.OrgErrMsg !== undefined) ? data.OrgErrMsg : null;
courseErrMsg = (data.CourseErrMsg !== undefined) ? data.CourseErrMsg : null;
setNewCourseErrMsgs(data.ErrMsg, null, orgErrMsg, courseErrMsg, null);
} }
} }
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment