diff --git a/lms/djangoapps/support/tests/test_refund.py b/lms/djangoapps/support/tests/test_refund.py index e2619c2025..e68d64b1d7 100644 --- a/lms/djangoapps/support/tests/test_refund.py +++ b/lms/djangoapps/support/tests/test_refund.py @@ -7,6 +7,8 @@ so we can easily deprecate it once the transition from shoppingcart to the E-Commerce service is complete. """ +from __future__ import absolute_import + import datetime import pytz diff --git a/lms/djangoapps/support/tests/test_views.py b/lms/djangoapps/support/tests/test_views.py index a4c67cf2e3..1ec44bd791 100644 --- a/lms/djangoapps/support/tests/test_views.py +++ b/lms/djangoapps/support/tests/test_views.py @@ -3,15 +3,18 @@ Tests for support views. """ +from __future__ import absolute_import + import itertools import json import re from datetime import datetime, timedelta import ddt +import six from django.contrib.auth.models import User -from django.urls import reverse from django.db.models import signals +from django.urls import reverse from pytz import UTC from common.test.utils import disable_signal @@ -194,10 +197,10 @@ class SupportViewCertificatesTests(SupportViewTestCase): def test_certificates_along_with_course_filter(self): # Check that an initial filter is passed to the JavaScript client. - url = reverse("support:certificates") + "?user=student@example.com&course_id=" + unicode(self.course.id) + url = reverse("support:certificates") + "?user=student@example.com&course_id=" + six.text_type(self.course.id) response = self.client.get(url) self.assertContains(response, "userFilter: 'student@example.com'") - self.assertContains(response, "courseFilter: '" + unicode(self.course.id) + "'") + self.assertContains(response, "courseFilter: '" + six.text_type(self.course.id) + "'") @ddt.ddt @@ -248,7 +251,7 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase 'mode': CourseMode.AUDIT, 'manual_enrollment': {}, 'user': self.student.username, - 'course_id': unicode(self.course.id), + 'course_id': six.text_type(self.course.id), 'is_active': True, 'verified_upgrade_deadline': None, }, data[0]) @@ -282,7 +285,7 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase kwargs={'username_or_email': getattr(self.student, search_string_type)} ) response = self.client.post(url, data={ - 'course_id': unicode(self.course.id), + 'course_id': six.text_type(self.course.id), 'old_mode': CourseMode.AUDIT, 'new_mode': CourseMode.VERIFIED, 'reason': 'Financial Assistance' @@ -318,7 +321,7 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase # `self` isn't available from within the DDT declaration, so # assign the course ID here if 'course_id' in data and data['course_id'] is None: - data['course_id'] = unicode(self.course.id) + data['course_id'] = six.text_type(self.course.id) response = self.client.post(self.url, data) self.assertEqual(response.status_code, 400) self.assertIsNotNone(re.match(error_message, response.content)) @@ -403,7 +406,7 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase kwargs={'username_or_email': getattr(self.student, search_string_type)} ) response = self.client.post(url, data={ - 'course_id': unicode(self.course.id), + 'course_id': six.text_type(self.course.id), 'old_mode': CourseMode.AUDIT, 'new_mode': new_mode, 'reason': 'Financial Assistance' diff --git a/lms/djangoapps/support/views/certificate.py b/lms/djangoapps/support/views/certificate.py index 246f528974..4bd7b78669 100644 --- a/lms/djangoapps/support/views/certificate.py +++ b/lms/djangoapps/support/views/certificate.py @@ -1,8 +1,9 @@ """ Certificate tool in the student support app. """ -import urllib +from __future__ import absolute_import +from six.moves.urllib.parse import unquote, quote_plus # pylint: disable=import-error from django.utils.decorators import method_decorator from django.views.generic import View @@ -25,14 +26,13 @@ class CertificatesSupportView(View): Most of the heavy lifting is performed client-side through API calls directly to the certificates app. - """ @method_decorator(require_support_permission) def get(self, request): """Render the certificates support view. """ context = { - "user_filter": urllib.unquote(urllib.quote_plus(request.GET.get("user", ""))), + "user_filter": unquote(quote_plus(request.GET.get("user", ""))), "course_filter": request.GET.get("course_id", "") } return render_to_response("support/certificates.html", context) diff --git a/lms/djangoapps/support/views/contact_us.py b/lms/djangoapps/support/views/contact_us.py index b1661d914b..1b2f07c36a 100644 --- a/lms/djangoapps/support/views/contact_us.py +++ b/lms/djangoapps/support/views/contact_us.py @@ -1,14 +1,16 @@ """ Signle support contact view """ +from __future__ import absolute_import + from django.conf import settings from django.http import Http404 from django.views.generic import View -from edxmako.shortcuts import render_to_response -from student.models import CourseEnrollment +from edxmako.shortcuts import render_to_response from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers from openedx.features.enterprise_support import api as enterprise_api +from student.models import CourseEnrollment class ContactUsView(View): diff --git a/lms/djangoapps/support/views/course_entitlements.py b/lms/djangoapps/support/views/course_entitlements.py index f6186bcc75..912e38f075 100644 --- a/lms/djangoapps/support/views/course_entitlements.py +++ b/lms/djangoapps/support/views/course_entitlements.py @@ -1,6 +1,8 @@ """ Support tool for changing and granting course entitlements """ +from __future__ import absolute_import + from django.utils.decorators import method_decorator from django.views.generic import View diff --git a/lms/djangoapps/support/views/enrollments.py b/lms/djangoapps/support/views/enrollments.py index 51b5de9ce4..a6f12c76cc 100644 --- a/lms/djangoapps/support/views/enrollments.py +++ b/lms/djangoapps/support/views/enrollments.py @@ -1,11 +1,14 @@ """ Support tool for changing course enrollments. """ +from __future__ import absolute_import + +import six from django.contrib.auth.models import User -from django.urls import reverse from django.db import transaction from django.db.models import Q from django.http import HttpResponseBadRequest +from django.urls import reverse from django.utils.decorators import method_decorator from django.views.generic import View from opaque_keys import InvalidKeyError @@ -101,7 +104,7 @@ class EnrollmentSupportListView(GenericAPIView): return HttpResponseBadRequest( u'Could not find enrollment for user {username} in course {course}.'.format( username=username_or_email, - course=unicode(course_key) + course=six.text_type(course_key) ) ) try: diff --git a/lms/djangoapps/support/views/feature_based_enrollments.py b/lms/djangoapps/support/views/feature_based_enrollments.py index 89c3ab5583..94d524bc35 100644 --- a/lms/djangoapps/support/views/feature_based_enrollments.py +++ b/lms/djangoapps/support/views/feature_based_enrollments.py @@ -1,16 +1,19 @@ """ Support tool for viewing course duration information """ +from __future__ import absolute_import + from django.core.exceptions import ObjectDoesNotExist from django.utils.decorators import method_decorator from django.views.generic import View -from edxmako.shortcuts import render_to_response -from lms.djangoapps.support.decorators import require_support_permission from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import CourseKey -from openedx.features.course_duration_limits.models import CourseDurationLimitConfig -from openedx.features.content_type_gating.models import ContentTypeGatingConfig + +from edxmako.shortcuts import render_to_response +from lms.djangoapps.support.decorators import require_support_permission from openedx.core.djangoapps.content.course_overviews.models import CourseOverview +from openedx.features.content_type_gating.models import ContentTypeGatingConfig +from openedx.features.course_duration_limits.models import CourseDurationLimitConfig class FeatureBasedEnrollmentsSupportView(View): diff --git a/lms/djangoapps/support/views/index.py b/lms/djangoapps/support/views/index.py index 5bd0ea07a9..1138922e1a 100644 --- a/lms/djangoapps/support/views/index.py +++ b/lms/djangoapps/support/views/index.py @@ -1,6 +1,8 @@ """ Index view for the support app. """ +from __future__ import absolute_import + from django.urls import reverse_lazy from django.utils.translation import ugettext_lazy as _ diff --git a/lms/djangoapps/support/views/manage_user.py b/lms/djangoapps/support/views/manage_user.py index f5ca57a480..1d4948b0d1 100644 --- a/lms/djangoapps/support/views/manage_user.py +++ b/lms/djangoapps/support/views/manage_user.py @@ -1,9 +1,11 @@ """ Support tool for disabling user accounts. """ +from __future__ import absolute_import + from django.contrib.auth import get_user_model -from django.urls import reverse from django.db.models import Q +from django.urls import reverse from django.utils.decorators import method_decorator from django.utils.translation import ugettext as _ from django.views.generic import View diff --git a/lms/djangoapps/support/views/refund.py b/lms/djangoapps/support/views/refund.py index 2617c1b6bc..5c8718a643 100644 --- a/lms/djangoapps/support/views/refund.py +++ b/lms/djangoapps/support/views/refund.py @@ -10,6 +10,8 @@ with an E-Commerce service that supports automatic refunds. Once that transition is complete, we can remove this view. """ +from __future__ import absolute_import + import logging from django import forms @@ -81,7 +83,7 @@ class RefundForm(forms.Form): # this is a two-step form: first look up the data, then issue the refund. # first time through, set the hidden "confirmed" field to true and then redisplay the form # second time through, do the unenrollment/refund. - data = dict(self.data.items()) + data = dict(list(self.data.items())) self.cleaned_data['confirmed'] = data['confirmed'] = 'true' self.data = data is_valid = False