INCR-466: Updates on Python 3.x and fix line over length limit (#20915)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
"""
|
||||
CCX API URLs.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.conf.urls import include, url
|
||||
|
||||
app_name = 'ccx_api'
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
""" CCX API v0 Paginators. """
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from edx_rest_framework_extensions.paginators import DefaultPagination
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
""" CCX API v0 Serializers. """
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import six
|
||||
from ccx_keys.locator import CCXLocator
|
||||
from rest_framework import serializers
|
||||
|
||||
@@ -43,7 +46,7 @@ class CCXCourseSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
Getter for the CCX Course ID
|
||||
"""
|
||||
return unicode(CCXLocator.from_course_locator(obj.course.id, obj.id))
|
||||
return six.text_type(CCXLocator.from_course_locator(obj.course.id, obj.id))
|
||||
|
||||
@staticmethod
|
||||
def get_course_modules(obj):
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
""" API v0 views. """
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import datetime
|
||||
import json
|
||||
import logging
|
||||
|
||||
import pytz
|
||||
import six
|
||||
from ccx_keys.locator import CCXLocator
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import transaction
|
||||
@@ -21,11 +24,7 @@ from rest_framework.response import Response
|
||||
from courseware import courses
|
||||
from lms.djangoapps.ccx.models import CcxFieldOverride, CustomCourseForEdX
|
||||
from lms.djangoapps.ccx.overrides import override_field_for_ccx
|
||||
from lms.djangoapps.ccx.utils import (
|
||||
add_master_course_staff_to_ccx,
|
||||
assign_staff_role_to_ccx,
|
||||
is_email
|
||||
)
|
||||
from lms.djangoapps.ccx.utils import add_master_course_staff_to_ccx, assign_staff_role_to_ccx, is_email
|
||||
from lms.djangoapps.instructor.enrollment import enroll_email, get_email_params
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
from openedx.core.lib.api import authentication, permissions
|
||||
@@ -492,7 +491,10 @@ class CCXListView(GenericAPIView):
|
||||
make_user_coach(coach, master_course_key)
|
||||
|
||||
# pull the ccx course key
|
||||
ccx_course_key = CCXLocator.from_course_locator(master_course_object.id, unicode(ccx_course_object.id))
|
||||
ccx_course_key = CCXLocator.from_course_locator(
|
||||
master_course_object.id,
|
||||
six.text_type(ccx_course_object.id)
|
||||
)
|
||||
# enroll the coach in the newly created ccx
|
||||
email_params = get_email_params(
|
||||
master_course_object,
|
||||
@@ -693,7 +695,7 @@ class CCXDetailView(GenericAPIView):
|
||||
)
|
||||
|
||||
master_course_id = request.data.get('master_course_id')
|
||||
if master_course_id is not None and unicode(ccx_course_object.course_id) != master_course_id:
|
||||
if master_course_id is not None and six.text_type(ccx_course_object.course_id) != master_course_id:
|
||||
return Response(
|
||||
status=status.HTTP_403_FORBIDDEN,
|
||||
data={
|
||||
@@ -711,7 +713,7 @@ class CCXDetailView(GenericAPIView):
|
||||
)
|
||||
|
||||
# get the master course key and master course object
|
||||
master_course_object, master_course_key, _, _ = get_valid_course(unicode(ccx_course_object.course_id))
|
||||
master_course_object, master_course_key, _, _ = get_valid_course(six.text_type(ccx_course_object.course_id))
|
||||
|
||||
with transaction.atomic():
|
||||
# update the display name
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
"""
|
||||
Models for the custom course feature
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import json
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
import six
|
||||
from ccx_keys.locator import CCXLocator
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
@@ -102,7 +103,7 @@ class CustomCourseForEdX(models.Model):
|
||||
Returns:
|
||||
The CCXLocator corresponding to this CCX.
|
||||
"""
|
||||
return CCXLocator.from_course_locator(self.course_id, unicode(self.id))
|
||||
return CCXLocator.from_course_locator(self.course_id, six.text_type(self.id))
|
||||
|
||||
|
||||
class CcxFieldOverride(models.Model):
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
Asynchronous tasks for the CCX app.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
|
||||
import six
|
||||
from ccx_keys.locator import CCXLocator
|
||||
from django.dispatch import receiver
|
||||
from opaque_keys import InvalidKeyError
|
||||
@@ -22,7 +25,7 @@ def course_published_handler(sender, course_key, **kwargs): # pylint: disable=u
|
||||
Consume signals that indicate course published. If course already a CCX, do nothing.
|
||||
"""
|
||||
if not isinstance(course_key, CCXLocator):
|
||||
send_ccx_course_published.delay(unicode(course_key))
|
||||
send_ccx_course_published.delay(six.text_type(course_key))
|
||||
|
||||
|
||||
@CELERY_APP.task
|
||||
@@ -33,7 +36,7 @@ def send_ccx_course_published(course_key):
|
||||
course_key = CourseLocator.from_string(course_key)
|
||||
for ccx in CustomCourseForEdX.objects.filter(course_id=course_key):
|
||||
try:
|
||||
ccx_key = CCXLocator.from_course_locator(course_key, unicode(ccx.id))
|
||||
ccx_key = CCXLocator.from_course_locator(course_key, six.text_type(ccx.id))
|
||||
except InvalidKeyError:
|
||||
log.info(u'Attempt to publish course with deprecated id. Course: %s. CCX: %s', course_key, ccx.id)
|
||||
continue
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
"""
|
||||
URLs for the CCX Feature.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.conf.urls import url
|
||||
|
||||
import ccx.views
|
||||
|
||||
@@ -3,6 +3,8 @@ CCX Enrollment operations for use by Coach APIs.
|
||||
|
||||
Does not include any access control, be sure to check access before calling.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
from contextlib import contextmanager
|
||||
@@ -11,9 +13,10 @@ from smtplib import SMTPException
|
||||
import pytz
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.urls import reverse
|
||||
from django.core.validators import validate_email
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import ugettext as _
|
||||
from six.moves import map
|
||||
|
||||
from courseware.courses import get_course_by_id
|
||||
from lms.djangoapps.ccx.custom_exception import CCXUserValidationException
|
||||
@@ -27,7 +30,6 @@ from openedx.core.djangoapps.content.course_overviews.models import CourseOvervi
|
||||
from student.models import CourseEnrollment, CourseEnrollmentException
|
||||
from student.roles import CourseCcxCoachRole, CourseInstructorRole, CourseStaffRole
|
||||
|
||||
|
||||
log = logging.getLogger("edx.ccx")
|
||||
|
||||
|
||||
@@ -143,8 +145,8 @@ def parse_date(datestring):
|
||||
"""
|
||||
if datestring:
|
||||
date, time = datestring.split(' ')
|
||||
year, month, day = map(int, date.split('-'))
|
||||
hour, minute = map(int, time.split(':'))
|
||||
year, month, day = list(map(int, date.split('-')))
|
||||
hour, minute = list(map(int, time.split(':')))
|
||||
if validate_date(year, month, day, hour, minute):
|
||||
return datetime.datetime(
|
||||
year, month, day, hour, minute, tzinfo=pytz.UTC)
|
||||
|
||||
Reference in New Issue
Block a user