Merge pull request #15191 from edx/andya/use-isort
Add isort to edx-platform
This commit is contained in:
4
.isort.cfg
Normal file
4
.isort.cfg
Normal file
@@ -0,0 +1,4 @@
|
||||
[settings]
|
||||
indent=' '
|
||||
line_length=120
|
||||
multi_line_output=3
|
||||
@@ -4,41 +4,66 @@ Courseware views functions
|
||||
import json
|
||||
import logging
|
||||
import urllib
|
||||
import waffle
|
||||
from collections import OrderedDict, namedtuple
|
||||
from datetime import datetime
|
||||
|
||||
import analytics
|
||||
import waffle
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.contrib.auth.models import AnonymousUser, User
|
||||
from django.core.context_processors import csrf
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db import transaction
|
||||
from django.db.models import Q
|
||||
from django.http import (
|
||||
Http404,
|
||||
HttpResponse,
|
||||
HttpResponseBadRequest,
|
||||
HttpResponseForbidden,
|
||||
QueryDict,
|
||||
)
|
||||
from django.http import Http404, HttpResponse, HttpResponseBadRequest, HttpResponseForbidden, QueryDict
|
||||
from django.shortcuts import redirect
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.utils.timezone import UTC
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.views.decorators.cache import cache_control
|
||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
from django.views.decorators.http import require_GET, require_POST, require_http_methods
|
||||
from django.views.decorators.http import require_GET, require_http_methods, require_POST
|
||||
from django.views.generic import View
|
||||
from eventtracking import tracker
|
||||
from ipware.ip import get_ip
|
||||
from markupsafe import escape
|
||||
from opaque_keys import InvalidKeyError
|
||||
from opaque_keys.edx.keys import CourseKey, UsageKey
|
||||
from rest_framework import status
|
||||
from web_fragments.fragment import Fragment
|
||||
|
||||
import shoppingcart
|
||||
import survey.utils
|
||||
import survey.views
|
||||
from certificates import api as certs_api
|
||||
from certificates.models import CertificateStatuses
|
||||
from commerce.utils import EcommerceService
|
||||
from course_modes.models import CourseMode
|
||||
from courseware.access import has_access, has_ccx_coach_role
|
||||
from courseware.access_response import StartDateError
|
||||
from courseware.access_utils import in_preview_mode, is_course_open_for_learner
|
||||
from courseware.courses import (
|
||||
get_course,
|
||||
get_course_by_id,
|
||||
get_course_overview_with_access,
|
||||
get_course_with_access,
|
||||
get_courses,
|
||||
get_current_child,
|
||||
get_permission_for_course_about,
|
||||
get_studio_url,
|
||||
sort_by_announcement,
|
||||
sort_by_start_date
|
||||
)
|
||||
from courseware.date_summary import VerifiedUpgradeDeadlineDate
|
||||
from courseware.masquerade import setup_masquerade
|
||||
from courseware.model_data import FieldDataCache
|
||||
from courseware.models import BaseStudentModuleHistory, StudentModule
|
||||
from courseware.url_helpers import get_redirect_url
|
||||
from courseware.user_state_client import DjangoXBlockUserStateClient
|
||||
from edxmako.shortcuts import marketing_link, render_to_response, render_to_string
|
||||
from enrollment.api import add_enrollment
|
||||
from eventtracking import tracker
|
||||
from lms.djangoapps.ccx.custom_exception import CCXLocatorValidationException
|
||||
from lms.djangoapps.ccx.utils import prep_course_for_grading
|
||||
from lms.djangoapps.courseware.exceptions import CourseAccessRedirect, Redirect
|
||||
@@ -46,75 +71,42 @@ from lms.djangoapps.grades.new.course_grade_factory import CourseGradeFactory
|
||||
from lms.djangoapps.instructor.enrollment import uses_shib
|
||||
from lms.djangoapps.instructor.views.api import require_global_staff
|
||||
from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification
|
||||
|
||||
import shoppingcart
|
||||
import survey.utils
|
||||
import survey.views
|
||||
from certificates import api as certs_api
|
||||
from certificates.models import CertificateStatuses
|
||||
from openedx.core.djangoapps.models.course_details import CourseDetails
|
||||
from openedx.core.djangoapps.plugin_api.views import EdxFragmentView
|
||||
from commerce.utils import EcommerceService
|
||||
from enrollment.api import add_enrollment
|
||||
from course_modes.models import CourseMode
|
||||
from courseware.access import has_access, has_ccx_coach_role
|
||||
from courseware.access_response import StartDateError
|
||||
from courseware.access_utils import in_preview_mode, is_course_open_for_learner
|
||||
from courseware.courses import (
|
||||
get_courses,
|
||||
get_course,
|
||||
get_course_by_id,
|
||||
get_course_overview_with_access,
|
||||
get_course_with_access,
|
||||
get_current_child,
|
||||
get_permission_for_course_about,
|
||||
get_studio_url,
|
||||
sort_by_announcement,
|
||||
sort_by_start_date,
|
||||
)
|
||||
from courseware.date_summary import VerifiedUpgradeDeadlineDate
|
||||
from courseware.masquerade import setup_masquerade
|
||||
from courseware.model_data import FieldDataCache
|
||||
from courseware.models import StudentModule, BaseStudentModuleHistory
|
||||
from courseware.url_helpers import get_redirect_url
|
||||
from courseware.user_state_client import DjangoXBlockUserStateClient
|
||||
from edxmako.shortcuts import render_to_response, render_to_string, marketing_link
|
||||
from openedx.core.djangoapps.catalog.utils import get_programs, get_programs_with_type
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
from openedx.core.djangoapps.coursetalk.helpers import inject_coursetalk_keys_into_context
|
||||
from openedx.core.djangoapps.credit.api import (
|
||||
get_credit_requirement_status,
|
||||
is_user_eligible_for_credit,
|
||||
is_credit_course
|
||||
is_credit_course,
|
||||
is_user_eligible_for_credit
|
||||
)
|
||||
from openedx.core.djangoapps.programs.utils import ProgramMarketingDataExtender
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration
|
||||
from openedx.core.djangoapps.models.course_details import CourseDetails
|
||||
from openedx.core.djangoapps.monitoring_utils import set_custom_metrics_for_course_key
|
||||
from openedx.core.djangoapps.plugin_api.views import EdxFragmentView
|
||||
from openedx.core.djangoapps.programs.utils import ProgramMarketingDataExtender
|
||||
from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
from openedx.features.course_experience import (
|
||||
course_home_url_name,
|
||||
UNIFIED_COURSE_EXPERIENCE_FLAG,
|
||||
UNIFIED_COURSE_VIEW_FLAG,
|
||||
course_home_url_name
|
||||
)
|
||||
from openedx.features.enterprise_support.api import data_sharing_consent_required
|
||||
from openedx.features.course_experience.views.course_dates import CourseDatesFragmentView
|
||||
from openedx.features.enterprise_support.api import data_sharing_consent_required
|
||||
from shoppingcart.utils import is_shopping_cart_enabled
|
||||
from student.models import UserTestGroup, CourseEnrollment
|
||||
from student.models import CourseEnrollment, UserTestGroup
|
||||
from survey.utils import must_answer_survey
|
||||
from util.cache import cache, cache_if_anonymous
|
||||
from util.date_utils import strftime_localized
|
||||
from util.db import outer_atomic
|
||||
from util.milestones_helpers import get_prerequisite_courses_display
|
||||
from util.views import _record_feedback_in_zendesk
|
||||
from util.views import ensure_valid_course_key, ensure_valid_usage_key
|
||||
from util.views import _record_feedback_in_zendesk, ensure_valid_course_key, ensure_valid_usage_key
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.modulestore.exceptions import ItemNotFoundError, NoPathToItem
|
||||
from xmodule.tabs import CourseTabList
|
||||
from xmodule.x_module import STUDENT_VIEW
|
||||
from web_fragments.fragment import Fragment
|
||||
|
||||
from ..entrance_exams import user_can_skip_entrance_exam
|
||||
from ..module_render import get_module_for_descriptor, get_module, get_module_by_usage_id
|
||||
from ..module_render import get_module, get_module_by_usage_id, get_module_for_descriptor
|
||||
|
||||
log = logging.getLogger("edx.courseware")
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ Defines URLs for the course experience.
|
||||
|
||||
from django.conf.urls import url
|
||||
|
||||
from views.course_bookmarks import CourseBookmarksView, CourseBookmarksFragmentView
|
||||
from views.course_bookmarks import CourseBookmarksFragmentView, CourseBookmarksView
|
||||
|
||||
urlpatterns = [
|
||||
url(
|
||||
|
||||
@@ -4,7 +4,7 @@ Defines URLs for the course experience.
|
||||
|
||||
from django.conf.urls import url
|
||||
|
||||
from views.course_home import CourseHomeView, CourseHomeFragmentView
|
||||
from views.course_home import CourseHomeFragmentView, CourseHomeView
|
||||
from views.course_outline import CourseOutlineFragmentView
|
||||
from views.course_updates import CourseUpdatesFragmentView, CourseUpdatesView
|
||||
from views.welcome_message import WelcomeMessageFragmentView
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
"""
|
||||
Common utilities for the course experience, including course outline.
|
||||
"""
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
from lms.djangoapps.course_api.blocks.api import get_blocks
|
||||
from lms.djangoapps.course_blocks.utils import get_student_module_as_dict
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from openedx.core.lib.cache_utils import memoized
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
|
||||
@@ -4,8 +4,9 @@ Fragment for rendering the course dates sidebar.
|
||||
from django.template.loader import render_to_string
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from web_fragments.fragment import Fragment
|
||||
|
||||
from courseware.courses import get_course_date_blocks, get_course_with_access
|
||||
from openedx.core.djangoapps.plugin_api.views import EdxFragmentView
|
||||
from courseware.courses import get_course_with_access, get_course_date_blocks
|
||||
|
||||
|
||||
class CourseDatesFragmentView(EdxFragmentView):
|
||||
|
||||
@@ -8,18 +8,18 @@ from django.template.loader import render_to_string
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views.decorators.cache import cache_control
|
||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from web_fragments.fragment import Fragment
|
||||
|
||||
from courseware.courses import get_course_info_section, get_course_with_access
|
||||
from lms.djangoapps.courseware.views.views import CourseTabView
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from openedx.core.djangoapps.plugin_api.views import EdxFragmentView
|
||||
from util.views import ensure_valid_course_key
|
||||
from web_fragments.fragment import Fragment
|
||||
|
||||
from .course_outline import CourseOutlineFragmentView
|
||||
from .course_dates import CourseDatesFragmentView
|
||||
from .welcome_message import WelcomeMessageFragmentView
|
||||
from ..utils import get_course_outline_block_tree
|
||||
from .course_dates import CourseDatesFragmentView
|
||||
from .course_outline import CourseOutlineFragmentView
|
||||
from .welcome_message import WelcomeMessageFragmentView
|
||||
|
||||
|
||||
class CourseHomeView(CourseTabView):
|
||||
|
||||
@@ -4,11 +4,11 @@ Views to show a course outline.
|
||||
|
||||
from django.core.context_processors import csrf
|
||||
from django.template.loader import render_to_string
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from web_fragments.fragment import Fragment
|
||||
|
||||
from courseware.courses import get_course_overview_with_access
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from openedx.core.djangoapps.plugin_api.views import EdxFragmentView
|
||||
from web_fragments.fragment import Fragment
|
||||
|
||||
from ..utils import get_course_outline_block_tree
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ from django.core.urlresolvers import reverse
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views.decorators.cache import cache_control
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from web_fragments.fragment import Fragment
|
||||
|
||||
from courseware.courses import get_course_info_section, get_course_with_access
|
||||
from lms.djangoapps.courseware.views.views import CourseTabView
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from openedx.core.djangoapps.plugin_api.views import EdxFragmentView
|
||||
from openedx.features.course_experience import default_course_url_name
|
||||
from web_fragments.fragment import Fragment
|
||||
|
||||
|
||||
class CourseUpdatesView(CourseTabView):
|
||||
|
||||
@@ -3,11 +3,11 @@ View logic for handling course welcome messages.
|
||||
"""
|
||||
|
||||
from django.template.loader import render_to_string
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from web_fragments.fragment import Fragment
|
||||
|
||||
from courseware.courses import get_course_info_section_module, get_course_with_access
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from openedx.core.djangoapps.plugin_api.views import EdxFragmentView
|
||||
from web_fragments.fragment import Fragment
|
||||
|
||||
|
||||
class WelcomeMessageFragmentView(EdxFragmentView):
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"""
|
||||
APIs providing support for enterprise functionality.
|
||||
"""
|
||||
from functools import wraps
|
||||
import hashlib
|
||||
import logging
|
||||
import six
|
||||
from functools import wraps
|
||||
|
||||
import six
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.cache import cache
|
||||
@@ -14,9 +14,15 @@ from django.shortcuts import redirect
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.http import urlencode
|
||||
from django.utils.translation import ugettext as _
|
||||
from slumber.exceptions import HttpClientError, HttpServerError
|
||||
|
||||
from edx_rest_api_client.client import EdxRestApiClient
|
||||
from requests.exceptions import ConnectionError, Timeout
|
||||
from slumber.exceptions import HttpClientError, HttpServerError, SlumberBaseException
|
||||
|
||||
from openedx.core.djangoapps.api_admin.utils import course_discovery_api_client
|
||||
from openedx.core.djangoapps.catalog.models import CatalogIntegration
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
from openedx.core.lib.token_utils import JwtBuilder
|
||||
|
||||
try:
|
||||
from enterprise import utils as enterprise_utils
|
||||
from enterprise.models import EnterpriseCourseEnrollment, EnterpriseCustomer
|
||||
@@ -24,13 +30,6 @@ try:
|
||||
from enterprise.utils import consent_necessary_for_course
|
||||
except ImportError:
|
||||
pass
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
from slumber.exceptions import SlumberBaseException
|
||||
from requests.exceptions import ConnectionError, Timeout
|
||||
from openedx.core.djangoapps.api_admin.utils import course_discovery_api_client
|
||||
|
||||
from openedx.core.lib.token_utils import JwtBuilder
|
||||
from openedx.core.djangoapps.catalog.models import CatalogIntegration
|
||||
|
||||
|
||||
CONSENT_FAILED_PARAMETER = 'consent_failed'
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
# Python libraries to install directly from github / PyPi
|
||||
|
||||
click==3.3
|
||||
isort==4.2.5
|
||||
|
||||
# Third-party:
|
||||
-e git+https://github.com/doctoryes/code_block_timer.git@f3d0629f086bcc649c3c77f4bc5b9c2c8172c3bf#egg=code_block_timer
|
||||
|
||||
Reference in New Issue
Block a user