From afd682e22450e2339420fd5463d7d8acf8c82253 Mon Sep 17 00:00:00 2001 From: Clinton Blackburn Date: Fri, 6 Nov 2015 01:49:22 -0500 Subject: [PATCH 1/6] Fixed admin issues - Using raw ID field for user fields for enrollment and user profile admin - Including user data in enrollment admin queryset --- common/djangoapps/student/admin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/djangoapps/student/admin.py b/common/djangoapps/student/admin.py index 153cdd4139..0f2ad68d27 100644 --- a/common/djangoapps/student/admin.py +++ b/common/djangoapps/student/admin.py @@ -136,8 +136,12 @@ class CourseEnrollmentAdmin(admin.ModelAdmin): """ Admin interface for the CourseEnrollment model. """ list_display = ('id', 'course_id', 'mode', 'user', 'is_active',) list_filter = ('mode', 'is_active',) + raw_id_fields = ('user',) search_fields = ('course_id', 'mode', 'user__username',) + def queryset(self, request): + return super(CourseEnrollmentAdmin, self).queryset(request).select_related('user') + class Meta(object): model = CourseEnrollment @@ -145,6 +149,7 @@ class CourseEnrollmentAdmin(admin.ModelAdmin): class UserProfileAdmin(admin.ModelAdmin): """ Admin interface for UserProfile model. """ list_display = ('user', 'name',) + raw_id_fields = ('user',) search_fields = ('user__username', 'user__first_name', 'user__last_name', 'user__email', 'name',) def get_readonly_fields(self, request, obj=None): From 4216eaf5c33e4fb21d36b3f6f0111fe870696500 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Thu, 5 Nov 2015 21:34:55 -0500 Subject: [PATCH 2/6] change 'routing' for some reports which go to potentially backlogged queues --- lms/djangoapps/instructor_task/tasks.py | 8 ++++---- lms/djangoapps/instructor_task/tasks_helper.py | 12 +++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lms/djangoapps/instructor_task/tasks.py b/lms/djangoapps/instructor_task/tasks.py index 37f4b89aac..2ef4aedb60 100644 --- a/lms/djangoapps/instructor_task/tasks.py +++ b/lms/djangoapps/instructor_task/tasks.py @@ -204,7 +204,7 @@ def calculate_students_features_csv(entry_id, xmodule_instance_args): return run_main_task(entry_id, task_fn, action_name) -@task(base=BaseInstructorTask, routing_key=settings.GRADES_DOWNLOAD_ROUTING_KEY) # pylint: disable=not-callable +@task(base=BaseInstructorTask) # pylint: disable=not-callable def enrollment_report_features_csv(entry_id, xmodule_instance_args): """ Compute student profile information for a course and upload the @@ -216,7 +216,7 @@ def enrollment_report_features_csv(entry_id, xmodule_instance_args): return run_main_task(entry_id, task_fn, action_name) -@task(base=BaseInstructorTask, routing_key=settings.GRADES_DOWNLOAD_ROUTING_KEY) # pylint: disable=not-callable +@task(base=BaseInstructorTask) # pylint: disable=not-callable def exec_summary_report_csv(entry_id, xmodule_instance_args): """ Compute executive summary report for a course and upload the @@ -228,7 +228,7 @@ def exec_summary_report_csv(entry_id, xmodule_instance_args): return run_main_task(entry_id, task_fn, action_name) -@task(base=BaseInstructorTask, routing_key=settings.GRADES_DOWNLOAD_ROUTING_KEY) # pylint: disable=not-callable +@task(base=BaseInstructorTask) # pylint: disable=not-callable def course_survey_report_csv(entry_id, xmodule_instance_args): """ Compute the survey report for a course and upload the @@ -240,7 +240,7 @@ def course_survey_report_csv(entry_id, xmodule_instance_args): return run_main_task(entry_id, task_fn, action_name) -@task(base=BaseInstructorTask, routing_key=settings.GRADES_DOWNLOAD_ROUTING_KEY) # pylint: disable=not-callable +@task(base=BaseInstructorTask) # pylint: disable=not-callable def proctored_exam_results_csv(entry_id, xmodule_instance_args): """ Compute proctored exam results report for a course and upload the diff --git a/lms/djangoapps/instructor_task/tasks_helper.py b/lms/djangoapps/instructor_task/tasks_helper.py index c823abd22e..3f095c6691 100644 --- a/lms/djangoapps/instructor_task/tasks_helper.py +++ b/lms/djangoapps/instructor_task/tasks_helper.py @@ -1327,12 +1327,15 @@ def upload_course_survey_report(_xmodule_instance_args, _entry_id, course_id, _t survey_fields.sort() user_survey_answers = OrderedDict() - survey_answers_for_course = SurveyAnswer.objects.filter(course_key=course_id) + survey_answers_for_course = SurveyAnswer.objects.filter(course_key=course_id).select_related('user') for survey_field_record in survey_answers_for_course: user_id = survey_field_record.user.id if user_id not in user_survey_answers.keys(): - user_survey_answers[user_id] = {} + user_survey_answers[user_id] = { + 'username': survey_field_record.user.username, + 'email': survey_field_record.user.email + } user_survey_answers[user_id][survey_field_record.field_name] = survey_field_record.field_value @@ -1343,9 +1346,8 @@ def upload_course_survey_report(_xmodule_instance_args, _entry_id, course_id, _t for user_id in user_survey_answers.keys(): row = [] row.append(user_id) - user_obj = User.objects.get(id=user_id) - row.append(user_obj.username) - row.append(user_obj.email) + row.append(user_survey_answers[user_id].get('username', '')) + row.append(user_survey_answers[user_id].get('email', '')) for survey_field in survey_fields: row.append(user_survey_answers[user_id].get(survey_field, '')) csv_rows.append(row) From 13508c76814088d01262afb37b378d1e3cc50241 Mon Sep 17 00:00:00 2001 From: asadiqbal Date: Fri, 6 Nov 2015 12:14:00 +0500 Subject: [PATCH 3/6] SOL-1379 --- cms/static/js/certificates/models/signatory.js | 17 ----------------- .../spec/views/certificate_details_spec.js | 18 ------------------ .../spec/views/certificate_editor_spec.js | 4 ++-- 3 files changed, 2 insertions(+), 37 deletions(-) diff --git a/cms/static/js/certificates/models/signatory.js b/cms/static/js/certificates/models/signatory.js index d16bdaaa4e..d668b6b683 100644 --- a/cms/static/js/certificates/models/signatory.js +++ b/cms/static/js/certificates/models/signatory.js @@ -31,23 +31,6 @@ function(_, str, Backbone, BackboneRelational, gettext) { return response; }, - validate: function(attrs) { - var errors = null; - if(_.has(attrs, 'title')){ - var title = attrs.title; - var lines = title.split(/\r\n|\r|\n/); - if (lines.length > 2) { - errors = _.extend({ - 'title': gettext('Signatory title should span over maximum of 2 lines.') - }, errors); - } - } - if (errors !== null){ - return errors; - } - - }, - setOriginalAttributes: function() { // Remember the current state of this model (enables edit->cancel use cases) this._originalAttributes = this.parse(this.toJSON()); diff --git a/cms/static/js/certificates/spec/views/certificate_details_spec.js b/cms/static/js/certificates/spec/views/certificate_details_spec.js index a03748f9f4..daec1ec873 100644 --- a/cms/static/js/certificates/spec/views/certificate_details_spec.js +++ b/cms/static/js/certificates/spec/views/certificate_details_spec.js @@ -244,24 +244,6 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails this.view.$(SELECTORS.signatory_organization_value) ).toContainText('New Signatory Test Organization'); }); - it('should not allow invalid data when saving changes made during in-line signatory editing', function() { - this.view.$(SELECTORS.edit_signatory).click(); - - setValuesToInputs(this.view, { - inputSignatoryName: 'New Signatory Test Name' - }); - - setValuesToInputs(this.view, { - inputSignatoryTitle: 'Signatory Title \non three \nlines' - }); - - setValuesToInputs(this.view, { - inputSignatoryOrganization: 'New Signatory Test Organization' - }); - - this.view.$(SELECTORS.signatory_panel_save).click(); - expect(this.view.$(SELECTORS.inputSignatoryTitle).parent()).toHaveClass('error'); - }); }); }); }); diff --git a/cms/static/js/certificates/spec/views/certificate_editor_spec.js b/cms/static/js/certificates/spec/views/certificate_editor_spec.js index 43ac124b5e..3893986b8c 100644 --- a/cms/static/js/certificates/spec/views/certificate_editor_spec.js +++ b/cms/static/js/certificates/spec/views/certificate_editor_spec.js @@ -246,7 +246,7 @@ function(_, Course, CertificateModel, SignatoryModel, CertificatesCollection, Ce expect(this.view.$('.certificate-edit-error')).not.toHaveClass('is-shown'); }); - it('signatories should not save when title span on more than 2 lines', function() { + it('signatories should save when title span on more than 2 lines', function() { this.view.$(SELECTORS.addSignatoryButton).click(); setValuesToInputs(this.view, { inputCertificateName: 'New Certificate Name' @@ -265,7 +265,7 @@ function(_, Course, CertificateModel, SignatoryModel, CertificatesCollection, Ce }); this.view.$(SELECTORS.saveCertificateButton).click(); - expect(this.view.$('.certificate-edit-error')).toHaveClass('is-shown'); + expect(this.view.$('.certificate-edit-error')).not.toHaveClass('is-shown'); }); it('user can delete those signatories already saved', function() { From 7a1469633f7ef379625a69c055142b97337be3f3 Mon Sep 17 00:00:00 2001 From: Andy Armstrong Date: Thu, 5 Nov 2015 23:07:46 -0500 Subject: [PATCH 4/6] Fix optimizing of draggabilly and json2 --- cms/static/cms/js/require-config.js | 4 ---- cms/static/coffee/spec/main.coffee | 4 ---- cms/static/js/utils/drag_and_drop.js | 4 ++-- cms/static/js_test.yml | 1 - common/static/js/vendor/draggabilly.pkgd.js | 9 ++++++++- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/cms/static/cms/js/require-config.js b/cms/static/cms/js/require-config.js index 3167c3136f..8139da6206 100644 --- a/cms/static/cms/js/require-config.js +++ b/cms/static/cms/js/require-config.js @@ -17,7 +17,6 @@ require.config({ paths: { "domReady": "js/vendor/domReady", "gettext": "/i18n", - "json2": "js/vendor/json2", "mustache": "js/vendor/mustache", "codemirror": "js/vendor/codemirror-compressed", "codemirror/stex": "js/vendor/CodeMirror/stex", @@ -96,9 +95,6 @@ require.config({ ] }, shim: { - "json2": { - exports: "JSON" - }, "gettext": { exports: "gettext" }, diff --git a/cms/static/coffee/spec/main.coffee b/cms/static/coffee/spec/main.coffee index f567289d27..a2a5cb3083 100644 --- a/cms/static/coffee/spec/main.coffee +++ b/cms/static/coffee/spec/main.coffee @@ -23,7 +23,6 @@ requirejs.config({ "jquery.simulate": "xmodule_js/common_static/js/vendor/jquery.simulate", "datepair": "xmodule_js/common_static/js/vendor/timepicker/datepair", "date": "xmodule_js/common_static/js/vendor/date", - "json2": "xmodule_js/common_static/js/vendor/json2", "moment": "xmodule_js/common_static/js/vendor/moment.min", "moment-with-locales": "xmodule_js/common_static/js/vendor/moment-with-locales.min", "text": "xmodule_js/common_static/js/vendor/requirejs/text", @@ -59,9 +58,6 @@ requirejs.config({ "js/spec/test_utils": "js/spec/test_utils", } shim: { - "json2": { - exports: "JSON" - }, "gettext": { exports: "gettext" }, diff --git a/cms/static/js/utils/drag_and_drop.js b/cms/static/js/utils/drag_and_drop.js index 436ca7d4ff..6228a32019 100644 --- a/cms/static/js/utils/drag_and_drop.js +++ b/cms/static/js/utils/drag_and_drop.js @@ -1,6 +1,6 @@ -define(["jquery", "jquery.ui", "underscore", "json2", "gettext", "draggabilly", +define(["jquery", "jquery.ui", "underscore", "gettext", "draggabilly", "js/utils/module", "common/js/components/views/feedback_notification"], - function ($, ui, _, JSON, gettext, Draggabilly, ModuleUtils, NotificationView) { + function ($, ui, _, gettext, Draggabilly, ModuleUtils, NotificationView) { 'use strict'; var contentDragger = { diff --git a/cms/static/js_test.yml b/cms/static/js_test.yml index b28c63aaf2..37e229f4eb 100644 --- a/cms/static/js_test.yml +++ b/cms/static/js_test.yml @@ -59,7 +59,6 @@ lib_paths: - xmodule_js/common_static/js/vendor/draggabilly.pkgd.js - xmodule_js/common_static/js/vendor/date.js - xmodule_js/common_static/js/vendor/domReady.js - - xmodule_js/common_static/js/vendor/json2.js - xmodule_js/common_static/js/vendor/URI.min.js - xmodule_js/common_static/js/vendor/jquery.smooth-scroll.min.js - xmodule_js/common_static/coffee/src/jquery.immediateDescendents.js diff --git a/common/static/js/vendor/draggabilly.pkgd.js b/common/static/js/vendor/draggabilly.pkgd.js index 9289408151..a266c7790d 100644 --- a/common/static/js/vendor/draggabilly.pkgd.js +++ b/common/static/js/vendor/draggabilly.pkgd.js @@ -1748,7 +1748,14 @@ return Unidragger; if ( typeof define == 'function' && define.amd ) { // AMD - define( [ + // Note: fixed by andy-armstrong to include a name for the definition + // so that this works when optimized using r.js. This is only an issue + // in Studio, as the LMS uses a namespaced version of RequireJS so + // this clause isn't reached. + // See http://requirejs.org/docs/errors.html#mismatch + define( + 'draggabilly', + [ 'classie/classie', 'get-style-property/get-style-property', 'get-size/get-size', From bc87ec15a94767aabb6f5631e509a935400dbd00 Mon Sep 17 00:00:00 2001 From: Adam Palay Date: Fri, 6 Nov 2015 11:33:52 -0500 Subject: [PATCH 5/6] Revert "add test for disabling check button while clicking save" This reverts commit bc6caea6a682781e350e49cc00dc568e639dde13. --- .../xmodule/js/spec/capa/display_spec.coffee | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/spec/capa/display_spec.coffee b/common/lib/xmodule/xmodule/js/spec/capa/display_spec.coffee index 5a3ed28ec7..690c748cde 100644 --- a/common/lib/xmodule/xmodule/js/spec/capa/display_spec.coffee +++ b/common/lib/xmodule/xmodule/js/spec/capa/display_spec.coffee @@ -538,19 +538,6 @@ describe 'Problem', -> runs -> expect(window.SR.readElts).toHaveBeenCalled() - it 'disables check button while posting', -> - runs -> - spyOn($, 'postWithPrefix').andCallFake (url, answers, callback) -> callback(success: 'OK') - spyOn @problem, 'enableCheckButton' - @problem.save() - expect(@problem.enableCheckButton).toHaveBeenCalledWith false - waitsFor (-> - return jQuery.active == 0 - ), "jQuery requests finished", 1000 - - runs -> - expect(@problem.enableCheckButton).toHaveBeenCalledWith true - describe 'refreshMath', -> beforeEach -> @problem = new Problem($('.xblock-student_view')) From 33d9185d5d73dc9fc93490f5f56fc2cfee17722c Mon Sep 17 00:00:00 2001 From: Adam Palay Date: Fri, 6 Nov 2015 11:34:33 -0500 Subject: [PATCH 6/6] Revert "Disable submit button on save click" This reverts commit 99cca0573049a50f37cb9e0e7174693c3f16943a. --- common/lib/xmodule/xmodule/js/src/capa/display.coffee | 2 -- 1 file changed, 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/src/capa/display.coffee b/common/lib/xmodule/xmodule/js/src/capa/display.coffee index 36fdad083d..b2130efff9 100644 --- a/common/lib/xmodule/xmodule/js/src/capa/display.coffee +++ b/common/lib/xmodule/xmodule/js/src/capa/display.coffee @@ -412,13 +412,11 @@ class @Problem @save_internal() save_internal: => - @enableCheckButton false Logger.log 'problem_save', @answers $.postWithPrefix "#{@url}/problem_save", @answers, (response) => saveMessage = response.msg @gentle_alert saveMessage @updateProgress response - @enableCheckButton true refreshMath: (event, element) => element = event.target unless element