INCR-480: Make compatible with Python 3.x and fixed line over length limit (#20833)

This commit is contained in:
Amit
2019-06-20 23:20:49 +03:00
committed by Jeremy Bowman
parent 4fb5679987
commit df949d6de1
5 changed files with 20 additions and 6 deletions

View File

@@ -2,8 +2,9 @@
Defines common methods shared by Teams classes
"""
from django.conf import settings
from __future__ import absolute_import
from django.conf import settings
TEAM_DISCUSSION_CONTEXT = 'standalone'

View File

@@ -1,6 +1,8 @@
"""
Definition of the course team feature.
"""
from __future__ import absolute_import
from django.utils.translation import ugettext_noop
from courseware.tabs import EnrolledTab

View File

@@ -1,5 +1,7 @@
""" Search index used to load data into elasticsearch"""
from __future__ import absolute_import
import logging
from functools import wraps

View File

@@ -1,6 +1,9 @@
"""Defines serializers used by the Team API."""
from __future__ import absolute_import
from copy import deepcopy
import six
from django.conf import settings
from django.contrib.auth.models import User
from django.db.models import Count
@@ -18,13 +21,13 @@ class CountryField(serializers.Field):
Field to serialize a country code.
"""
COUNTRY_CODES = dict(countries).keys()
COUNTRY_CODES = list(dict(countries).keys())
def to_representation(self, obj):
"""
Represent the country as a 2-character unicode identifier.
"""
return unicode(obj)
return six.text_type(obj)
def to_internal_value(self, data):
"""

View File

@@ -1,7 +1,10 @@
"""HTTP endpoints for the Teams API."""
from __future__ import absolute_import
import logging
import six
from django.conf import settings
from django.contrib.auth.models import User
from django.db.models.signals import post_save
@@ -11,6 +14,7 @@ from django.shortcuts import get_object_or_404, render_to_response
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_noop
from django_countries import countries
from edx_rest_framework_extensions.paginators import DefaultPagination, paginate_search_results
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from rest_framework import permissions, status
@@ -24,7 +28,6 @@ from rest_framework_oauth.authentication import OAuth2Authentication
from courseware.courses import get_course_with_access, has_access
from lms.djangoapps.discussion.django_comment_client.utils import has_discussion_privileges
from lms.djangoapps.teams.models import CourseTeam, CourseTeamMembership
from edx_rest_framework_extensions.paginators import DefaultPagination, paginate_search_results
from openedx.core.lib.api.parsers import MergePatchParser
from openedx.core.lib.api.permissions import IsStaffOrReadOnly
from openedx.core.lib.api.view_utils import (
@@ -66,7 +69,10 @@ def team_post_save_callback(sender, instance, **kwargs): # pylint: disable=unus
if not kwargs['created']:
for field in changed_fields:
if field not in instance.FIELD_BLACKLIST:
truncated_fields = truncate_fields(unicode(changed_fields[field]), unicode(getattr(instance, field)))
truncated_fields = truncate_fields(
six.text_type(changed_fields[field]),
six.text_type(getattr(instance, field))
)
truncated_fields['team_id'] = instance.team_id
truncated_fields['field'] = field
@@ -499,7 +505,7 @@ class TeamsListView(ExpandableFieldViewMixin, GenericAPIView):
return Response(status=status.HTTP_403_FORBIDDEN)
data = request.data.copy()
data['course_id'] = unicode(course_key)
data['course_id'] = six.text_type(course_key)
serializer = CourseTeamCreationSerializer(data=data)
add_serializer_errors(serializer, data, field_errors)