From dba8a51f591f79aa3fad6ef0b4b90aff68682aa9 Mon Sep 17 00:00:00 2001 From: Awais Jibran Date: Tue, 12 Jul 2016 11:55:00 +0500 Subject: [PATCH] Adding logging if course_id is not found in enrolled course modes. --- common/djangoapps/student/views.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/common/djangoapps/student/views.py b/common/djangoapps/student/views.py index 186203f95d..86d32dfc83 100644 --- a/common/djangoapps/student/views.py +++ b/common/djangoapps/student/views.py @@ -826,6 +826,21 @@ def _allow_donation(course_modes, course_id, enrollment): True if the course is allowing donations. """ + if course_id not in course_modes: + flat_unexpired_modes = { + unicode(course_id): [mode for mode in modes] + for course_id, modes in course_modes.iteritems() + } + flat_all_modes = { + unicode(course_id): [mode.slug for mode in modes] + for course_id, modes in CourseMode.all_modes_for_courses([course_id]).iteritems() + } + log.error( + u'Can not find `%s` in course modes.`%s`. All modes: `%s`', + course_id, + flat_unexpired_modes, + flat_all_modes + ) donations_enabled = DonationConfiguration.current().enabled return ( donations_enabled and