From 8a9e81fdda941c6e994443ade16b40b2960dcfeb Mon Sep 17 00:00:00 2001 From: Amir Qayyum Khan Date: Mon, 8 Feb 2016 17:37:00 +0500 Subject: [PATCH] Added validation to ccx create form, If ccxcon url is set then app will ask user to create ccx from ccxcon app --- lms/djangoapps/ccx/tests/test_views.py | 24 ++++++++++++++++++++ lms/djangoapps/ccx/utils.py | 23 +++++++++++++++++++ lms/djangoapps/ccx/views.py | 9 ++++++++ lms/templates/ccx/coach_dashboard.html | 31 ++++++++++++++++++++++---- 4 files changed, 83 insertions(+), 4 deletions(-) diff --git a/lms/djangoapps/ccx/tests/test_views.py b/lms/djangoapps/ccx/tests/test_views.py index dfa1deaff0..44b9bc64e2 100644 --- a/lms/djangoapps/ccx/tests/test_views.py +++ b/lms/djangoapps/ccx/tests/test_views.py @@ -17,6 +17,7 @@ from courseware.tests.helpers import LoginEnrollmentTestCase from courseware.tabs import get_course_tab_list from django.conf import settings from django.core.urlresolvers import reverse, resolve +from django.utils.translation import ugettext as _ from django.utils.timezone import UTC from django.test.utils import override_settings from django.test import RequestFactory @@ -264,6 +265,29 @@ class TestCoachDashboard(CcxTestCase, LoginEnrollmentTestCase): '
% endif
- +

+ - -
- +
+ +
+
+
+ +
%endif @@ -155,4 +160,22 @@ from django.core.urlresolvers import reverse $('#ccx_std_list_messages')[0].focus(); } }); + function validateForm(form) { + var newCCXName = $(form).find('#ccx_name').val(); + var $errorMessage = $('#ccx-create-message'); + var hasCcxConnector = ${has_ccx_connector}; + + if (!newCCXName && !hasCcxConnector) { + $errorMessage.text("${_('Please enter a valid CCX name.')}"); + $errorMessage.show(); + return false; + } else if (hasCcxConnector) { + $errorMessage.html('${use_ccx_con_error_message}'); + $errorMessage.show(); + return false; + } + + $errorMessage.hide(); + return true; + }