Fixing python-modernize issues.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
"""
|
||||
Base test case for the course API views.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from rest_framework.test import APITestCase
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
"""
|
||||
Tests for the course import API views
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from rest_framework import status
|
||||
from rest_framework.test import APITestCase
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
""" Course API URLs. """
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf.urls import url
|
||||
|
||||
from cms.djangoapps.contentstore.api.views import course_import, course_quality, course_validation
|
||||
|
||||
|
||||
app_name = 'contentstore'
|
||||
|
||||
urlpatterns = [
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
"""
|
||||
APIs related to Course Import.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import base64
|
||||
import logging
|
||||
import os
|
||||
|
||||
from path import Path as path
|
||||
from six import text_type
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from django.core.files import File
|
||||
from path import Path as path
|
||||
from rest_framework import status
|
||||
from rest_framework.exceptions import AuthenticationFailed
|
||||
from rest_framework.generics import GenericAPIView
|
||||
from rest_framework.response import Response
|
||||
from six import text_type
|
||||
from user_tasks.models import UserTaskStatus
|
||||
|
||||
from contentstore.storage import course_import_export_storage
|
||||
@@ -23,7 +23,6 @@ from openedx.core.lib.api.view_utils import DeveloperErrorViewMixin, view_auth_c
|
||||
|
||||
from .utils import course_author_access_required
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
# pylint: disable=missing-docstring
|
||||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
from scipy import stats
|
||||
import six
|
||||
from edxval.api import get_videos_for_course
|
||||
from rest_framework.generics import GenericAPIView
|
||||
from rest_framework.response import Response
|
||||
from scipy import stats
|
||||
|
||||
from contentstore.views.item import highlights_setting
|
||||
from edxval.api import get_videos_for_course
|
||||
from openedx.core.lib.cache_utils import request_cached
|
||||
from openedx.core.lib.api.view_utils import DeveloperErrorViewMixin, view_auth_classes
|
||||
from openedx.core.lib.cache_utils import request_cached
|
||||
from openedx.core.lib.graph_traversals import traverse_pre_order
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
from .utils import get_bool_param, course_author_access_required
|
||||
from .utils import course_author_access_required, get_bool_param
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -153,25 +157,25 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView):
|
||||
def _subsections_quality(self, course, request):
|
||||
subsection_unit_dict = self._get_subsections_and_units(course, request)
|
||||
num_block_types_per_subsection_dict = {}
|
||||
for subsection_key, unit_dict in subsection_unit_dict.iteritems():
|
||||
for subsection_key, unit_dict in six.iteritems(subsection_unit_dict):
|
||||
leaf_block_types_in_subsection = (
|
||||
unit_info['leaf_block_types']
|
||||
for unit_info in unit_dict.itervalues()
|
||||
for unit_info in six.itervalues(unit_dict)
|
||||
)
|
||||
num_block_types_per_subsection_dict[subsection_key] = len(set().union(*leaf_block_types_in_subsection))
|
||||
|
||||
return dict(
|
||||
total_visible=len(num_block_types_per_subsection_dict),
|
||||
num_with_one_block_type=list(num_block_types_per_subsection_dict.itervalues()).count(1),
|
||||
num_block_types=self._stats_dict(list(num_block_types_per_subsection_dict.itervalues())),
|
||||
num_with_one_block_type=list(six.itervalues(num_block_types_per_subsection_dict)).count(1),
|
||||
num_block_types=self._stats_dict(list(six.itervalues(num_block_types_per_subsection_dict))),
|
||||
)
|
||||
|
||||
def _units_quality(self, course, request):
|
||||
subsection_unit_dict = self._get_subsections_and_units(course, request)
|
||||
num_leaf_blocks_per_unit = [
|
||||
unit_info['num_leaf_blocks']
|
||||
for unit_dict in subsection_unit_dict.itervalues()
|
||||
for unit_info in unit_dict.itervalues()
|
||||
for unit_dict in six.itervalues(subsection_unit_dict)
|
||||
for unit_info in six.itervalues(unit_dict)
|
||||
]
|
||||
return dict(
|
||||
total_visible=len(num_leaf_blocks_per_unit),
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
# pylint: disable=missing-docstring
|
||||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
from rest_framework.generics import GenericAPIView
|
||||
from rest_framework.response import Response
|
||||
|
||||
import dateutil
|
||||
import six
|
||||
from pytz import UTC
|
||||
from rest_framework.generics import GenericAPIView
|
||||
from rest_framework.response import Response
|
||||
|
||||
from contentstore.course_info_model import get_course_updates
|
||||
from contentstore.views.certificates import CertificateManager
|
||||
@@ -12,8 +15,7 @@ from openedx.core.lib.api.view_utils import DeveloperErrorViewMixin, view_auth_c
|
||||
from xmodule.course_metadata_utils import DEFAULT_GRADING_POLICY
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
from .utils import get_bool_param, course_author_access_required
|
||||
|
||||
from .utils import course_author_access_required, get_bool_param
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -118,7 +120,7 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView):
|
||||
]
|
||||
assignments_with_dates_before_start = (
|
||||
[
|
||||
{'id': unicode(a.location), 'display_name': a.display_name}
|
||||
{'id': six.text_type(a.location), 'display_name': a.display_name}
|
||||
for a in assignments_with_dates
|
||||
if a.due < course.start
|
||||
]
|
||||
@@ -128,7 +130,7 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView):
|
||||
|
||||
assignments_with_dates_after_end = (
|
||||
[
|
||||
{'id': unicode(a.location), 'display_name': a.display_name}
|
||||
{'id': six.text_type(a.location), 'display_name': a.display_name}
|
||||
for a in assignments_with_dates
|
||||
if a.due > course.end
|
||||
]
|
||||
@@ -144,7 +146,7 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView):
|
||||
]
|
||||
assignments_with_dates_before_start = (
|
||||
[
|
||||
{'id': unicode(a.location), 'display_name': a.display_name}
|
||||
{'id': six.text_type(a.location), 'display_name': a.display_name}
|
||||
for a in assignments_with_dates
|
||||
if a.due < course.start
|
||||
]
|
||||
@@ -154,7 +156,7 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView):
|
||||
|
||||
assignments_with_dates_after_end = (
|
||||
[
|
||||
{'id': unicode(a.location), 'display_name': a.display_name}
|
||||
{'id': six.text_type(a.location), 'display_name': a.display_name}
|
||||
for a in assignments_with_dates
|
||||
if a.due > course.end
|
||||
]
|
||||
@@ -175,14 +177,14 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView):
|
||||
parent_unit = modulestore().get_item(ora.parent)
|
||||
parent_assignment = modulestore().get_item(parent_unit.parent)
|
||||
assignments_with_ora_dates_before_start.append({
|
||||
'id': unicode(parent_assignment.location),
|
||||
'id': six.text_type(parent_assignment.location),
|
||||
'display_name': parent_assignment.display_name
|
||||
})
|
||||
if course.end and self._has_date_after_end(ora, course.end):
|
||||
parent_unit = modulestore().get_item(ora.parent)
|
||||
parent_assignment = modulestore().get_item(parent_unit.parent)
|
||||
assignments_with_ora_dates_after_end.append({
|
||||
'id': unicode(parent_assignment.location),
|
||||
'id': six.text_type(parent_assignment.location),
|
||||
'display_name': parent_assignment.display_name
|
||||
})
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
"""
|
||||
Common utilities for Contentstore APIs.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from contextlib import contextmanager
|
||||
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from rest_framework import status
|
||||
from rest_framework.generics import GenericAPIView
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
from openedx.core.djangoapps.util.forms import to_bool
|
||||
from openedx.core.lib.api.view_utils import DeveloperErrorViewMixin, view_auth_classes
|
||||
|
||||
Reference in New Issue
Block a user