From a6ff5e3005d41e1e8adaa959a22dbb2069b906cc Mon Sep 17 00:00:00 2001 From: Aarif Date: Thu, 11 Jul 2019 12:25:22 +0500 Subject: [PATCH] ran `python-modernize` and `isort` on openedx/core/djangoapps/user_authn (#20976) --- openedx/core/djangoapps/user_authn/apps.py | 4 +++- openedx/core/djangoapps/user_authn/cookies.py | 5 ++--- openedx/core/djangoapps/user_authn/exceptions.py | 2 ++ openedx/core/djangoapps/user_authn/urls.py | 4 +++- openedx/core/djangoapps/user_authn/urls_common.py | 5 +++-- openedx/core/djangoapps/user_authn/utils.py | 2 ++ openedx/core/djangoapps/user_authn/views/login.py | 2 +- openedx/core/djangoapps/user_authn/views/login_form.py | 2 +- openedx/core/djangoapps/user_authn/views/logout.py | 2 +- openedx/core/djangoapps/user_authn/views/tests/test_login.py | 3 ++- 10 files changed, 20 insertions(+), 11 deletions(-) diff --git a/openedx/core/djangoapps/user_authn/apps.py b/openedx/core/djangoapps/user_authn/apps.py index 128225801a..9e01559dfd 100644 --- a/openedx/core/djangoapps/user_authn/apps.py +++ b/openedx/core/djangoapps/user_authn/apps.py @@ -2,9 +2,11 @@ User Authentication Configuration """ +from __future__ import absolute_import + from django.apps import AppConfig -from openedx.core.djangoapps.plugins.constants import ProjectType, PluginURLs +from openedx.core.djangoapps.plugins.constants import PluginURLs, ProjectType class UserAuthnConfig(AppConfig): diff --git a/openedx/core/djangoapps/user_authn/cookies.py b/openedx/core/djangoapps/user_authn/cookies.py index 8fec6cb633..5c310dabf0 100644 --- a/openedx/core/djangoapps/user_authn/cookies.py +++ b/openedx/core/djangoapps/user_authn/cookies.py @@ -1,7 +1,7 @@ """ Utility functions for setting "logged in" cookies used by subdomains. """ -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import json import logging @@ -13,10 +13,10 @@ from django.contrib.auth.models import User from django.dispatch import Signal from django.urls import NoReverseMatch, reverse from django.utils.http import cookie_date - from edx_rest_framework_extensions.auth.jwt import cookies as jwt_cookies from edx_rest_framework_extensions.auth.jwt.constants import JWT_DELIMITER from oauth2_provider.models import Application + from openedx.core.djangoapps.oauth_dispatch.adapters import DOTAdapter from openedx.core.djangoapps.oauth_dispatch.api import create_dot_access_token from openedx.core.djangoapps.oauth_dispatch.jwt import create_jwt_from_token @@ -24,7 +24,6 @@ from openedx.core.djangoapps.user_api.accounts.utils import retrieve_last_sitewi from openedx.core.djangoapps.user_authn.exceptions import AuthFailedError from student.models import CourseEnrollment - log = logging.getLogger(__name__) diff --git a/openedx/core/djangoapps/user_authn/exceptions.py b/openedx/core/djangoapps/user_authn/exceptions.py index 7df072b69f..d79b0094ad 100644 --- a/openedx/core/djangoapps/user_authn/exceptions.py +++ b/openedx/core/djangoapps/user_authn/exceptions.py @@ -1,5 +1,7 @@ """ User Authn related Exceptions. """ +from __future__ import absolute_import + from openedx.core.djangolib.markup import Text diff --git a/openedx/core/djangoapps/user_authn/urls.py b/openedx/core/djangoapps/user_authn/urls.py index 7462a71b09..a278f3355e 100644 --- a/openedx/core/djangoapps/user_authn/urls.py +++ b/openedx/core/djangoapps/user_authn/urls.py @@ -1,10 +1,12 @@ """ URLs for User Authentication """ +from __future__ import absolute_import + from django.conf import settings from django.conf.urls import include, url from openedx.core.djangoapps.user_api.accounts import settings_views -from .views import login_form, login, deprecated +from .views import deprecated, login, login_form urlpatterns = [ # TODO this should really be declared in the user_api app diff --git a/openedx/core/djangoapps/user_authn/urls_common.py b/openedx/core/djangoapps/user_authn/urls_common.py index 1ba79798d0..b20698e8b0 100644 --- a/openedx/core/djangoapps/user_authn/urls_common.py +++ b/openedx/core/djangoapps/user_authn/urls_common.py @@ -6,11 +6,12 @@ For now, this is needed because of difference in CMS and LMS that have not yet been cleaned up. """ +from __future__ import absolute_import + from django.conf import settings from django.conf.urls import url -from .views import auto_auth, login, logout, deprecated - +from .views import auto_auth, deprecated, login, logout urlpatterns = [ url(r'^create_account$', deprecated.create_account, name='create_account'), diff --git a/openedx/core/djangoapps/user_authn/utils.py b/openedx/core/djangoapps/user_authn/utils.py index 6a58ac8eed..c33e8c6622 100644 --- a/openedx/core/djangoapps/user_authn/utils.py +++ b/openedx/core/djangoapps/user_authn/utils.py @@ -1,6 +1,8 @@ """ Utility functions used during user authentication. """ +from __future__ import absolute_import + from django.conf import settings from django.utils import http from oauth2_provider.models import Application diff --git a/openedx/core/djangoapps/user_authn/views/login.py b/openedx/core/djangoapps/user_authn/views/login.py index 8d952a2dd2..d730926602 100644 --- a/openedx/core/djangoapps/user_authn/views/login.py +++ b/openedx/core/djangoapps/user_authn/views/login.py @@ -20,7 +20,6 @@ from django.views.decorators.http import require_http_methods from ratelimitbackend.exceptions import RateLimitException import third_party_auth -from third_party_auth import pipeline, provider from edxmako.shortcuts import render_to_response from openedx.core.djangoapps.password_policy import compliance as password_policy_compliance from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers @@ -31,6 +30,7 @@ from openedx.core.djangolib.markup import HTML, Text from student.forms import send_password_reset_email_for_user from student.models import LoginFailures from student.views import send_reactivation_email_for_user +from third_party_auth import pipeline, provider from track import segment from util.json_request import JsonResponse from util.password_policy_validators import normalize_password diff --git a/openedx/core/djangoapps/user_authn/views/login_form.py b/openedx/core/djangoapps/user_authn/views/login_form.py index 3920df1e54..b6187c6874 100644 --- a/openedx/core/djangoapps/user_authn/views/login_form.py +++ b/openedx/core/djangoapps/user_authn/views/login_form.py @@ -14,6 +14,7 @@ from django.utils.translation import ugettext as _ from django.views.decorators.csrf import ensure_csrf_cookie from django.views.decorators.http import require_http_methods +import third_party_auth from edxmako.shortcuts import render_to_response from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers from openedx.core.djangoapps.theming.helpers import is_request_in_themed_site @@ -32,7 +33,6 @@ from openedx.features.enterprise_support.utils import ( update_logistration_context_for_enterprise ) from student.helpers import get_next_url_for_login_page -import third_party_auth from third_party_auth import pipeline from third_party_auth.decorators import xframe_allow_whitelisted diff --git a/openedx/core/djangoapps/user_authn/views/logout.py b/openedx/core/djangoapps/user_authn/views/logout.py index e9276a51e9..a77cb9f546 100644 --- a/openedx/core/djangoapps/user_authn/views/logout.py +++ b/openedx/core/djangoapps/user_authn/views/logout.py @@ -2,7 +2,6 @@ from __future__ import absolute_import import edx_oauth2_provider -from six.moves.urllib.parse import parse_qs, urlsplit, urlunsplit # pylint: disable=import-error import six.moves.urllib.parse as parse # pylint: disable=import-error from django.conf import settings from django.contrib.auth import logout @@ -10,6 +9,7 @@ from django.shortcuts import redirect from django.utils.http import urlencode from django.views.generic import TemplateView from provider.oauth2.models import Client +from six.moves.urllib.parse import parse_qs, urlsplit, urlunsplit # pylint: disable=import-error from openedx.core.djangoapps.user_authn.cookies import delete_logged_in_cookies from openedx.core.djangoapps.user_authn.utils import is_safe_login_or_logout_redirect diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_login.py b/openedx/core/djangoapps/user_authn/views/tests/test_login.py index 00618e8dae..6704de86ec 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_login.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_login.py @@ -18,6 +18,8 @@ from django.test.client import Client from django.test.utils import override_settings from django.urls import NoReverseMatch, reverse from mock import patch +from six.moves import range + from openedx.core.djangoapps.password_policy.compliance import ( NonCompliantPasswordException, NonCompliantPasswordWarning @@ -26,7 +28,6 @@ from openedx.core.djangoapps.user_api.config.waffle import PREVENT_AUTH_USER_WRI from openedx.core.djangoapps.user_authn.cookies import jwt_cookies from openedx.core.djangoapps.user_authn.tests.utils import setup_login_oauth_client from openedx.core.djangolib.testing.utils import CacheIsolationTestCase -from six.moves import range from student.tests.factories import RegistrationFactory, UserFactory, UserProfileFactory