From 83bc838fae4f0a96d3f6cc37384ed8e000a227c5 Mon Sep 17 00:00:00 2001 From: Ayub khan Date: Thu, 11 Jul 2019 14:16:38 +0500 Subject: [PATCH] python 3 compatibility --- common/djangoapps/third_party_auth/__init__.py | 3 ++- common/djangoapps/third_party_auth/admin.py | 6 ++++-- common/djangoapps/third_party_auth/apps.py | 2 ++ common/djangoapps/third_party_auth/dummy.py | 2 ++ common/djangoapps/third_party_auth/exceptions.py | 2 ++ common/djangoapps/third_party_auth/middleware.py | 5 +++-- common/djangoapps/third_party_auth/settings.py | 2 ++ common/djangoapps/third_party_auth/tasks.py | 4 +++- common/djangoapps/third_party_auth/urls.py | 11 +++++++++-- common/djangoapps/third_party_auth/utils.py | 2 ++ 10 files changed, 31 insertions(+), 8 deletions(-) diff --git a/common/djangoapps/third_party_auth/__init__.py b/common/djangoapps/third_party_auth/__init__.py index 13f12c70de..f44e3f91a8 100644 --- a/common/djangoapps/third_party_auth/__init__.py +++ b/common/djangoapps/third_party_auth/__init__.py @@ -1,7 +1,8 @@ """Third party authentication. """ -from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers +from __future__ import absolute_import +from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers default_app_config = 'third_party_auth.apps.ThirdPartyAuthConfig' diff --git a/common/djangoapps/third_party_auth/admin.py b/common/djangoapps/third_party_auth/admin.py index a3b527b149..f3fd379244 100644 --- a/common/djangoapps/third_party_auth/admin.py +++ b/common/djangoapps/third_party_auth/admin.py @@ -2,13 +2,16 @@ """ Admin site configuration for third party authentication """ +from __future__ import absolute_import + from config_models.admin import KeyedConfigurationModelAdmin from django import forms from django.contrib import admin -from django.urls import reverse from django.db import DatabaseError, transaction +from django.urls import reverse from django.utils.translation import ugettext_lazy as _ +from openedx.core.djangolib.markup import HTML from third_party_auth.provider import Registry from .models import ( @@ -22,7 +25,6 @@ from .models import ( SAMLProviderData ) from .tasks import fetch_saml_metadata -from openedx.core.djangolib.markup import HTML class OAuth2ProviderConfigForm(forms.ModelForm): diff --git a/common/djangoapps/third_party_auth/apps.py b/common/djangoapps/third_party_auth/apps.py index 3836836af9..054f7b60cb 100644 --- a/common/djangoapps/third_party_auth/apps.py +++ b/common/djangoapps/third_party_auth/apps.py @@ -1,4 +1,6 @@ +from __future__ import absolute_import + from django.apps import AppConfig from django.conf import settings diff --git a/common/djangoapps/third_party_auth/dummy.py b/common/djangoapps/third_party_auth/dummy.py index 532f170e61..69c50b99c0 100644 --- a/common/djangoapps/third_party_auth/dummy.py +++ b/common/djangoapps/third_party_auth/dummy.py @@ -1,6 +1,8 @@ """ DummyBackend: A fake Third Party Auth provider for testing & development purposes. """ +from __future__ import absolute_import + from social_core.backends.oauth import BaseOAuth2 from social_core.exceptions import AuthFailed diff --git a/common/djangoapps/third_party_auth/exceptions.py b/common/djangoapps/third_party_auth/exceptions.py index bb0b2c0d5c..4c7b71846b 100644 --- a/common/djangoapps/third_party_auth/exceptions.py +++ b/common/djangoapps/third_party_auth/exceptions.py @@ -1,6 +1,8 @@ """ Exceptions for SAML Authentication. """ +from __future__ import absolute_import + from social_core.exceptions import AuthException diff --git a/common/djangoapps/third_party_auth/middleware.py b/common/djangoapps/third_party_auth/middleware.py index 19993ad64d..5484d87f5e 100644 --- a/common/djangoapps/third_party_auth/middleware.py +++ b/common/djangoapps/third_party_auth/middleware.py @@ -1,7 +1,8 @@ """Middleware classes for third_party_auth.""" -import urlparse +from __future__ import absolute_import +import six.moves.urllib.parse # pylint: disable=import-error from django.contrib import messages from django.shortcuts import redirect from django.urls import reverse @@ -39,7 +40,7 @@ class ExceptionMiddleware(SocialAuthExceptionMiddleware): referer_url = request.META.get('HTTP_REFERER', '') if (referer_url and isinstance(exception, HTTPError) and exception.response.status_code == 502): - referer_url = urlparse.urlparse(referer_url).path + referer_url = six.moves.urllib.parse.urlparse(referer_url).path if referer_url == reverse('signin_user'): messages.error(request, _('Unable to connect with the external provider, please try again'), extra_tags='social-auth') diff --git a/common/djangoapps/third_party_auth/settings.py b/common/djangoapps/third_party_auth/settings.py index dd921ada76..2f2c0230d2 100644 --- a/common/djangoapps/third_party_auth/settings.py +++ b/common/djangoapps/third_party_auth/settings.py @@ -10,6 +10,8 @@ If true, it: b) calls apply_settings(), passing in the Django settings """ +from __future__ import absolute_import + from openedx.features.enterprise_support.api import insert_enterprise_pipeline_elements diff --git a/common/djangoapps/third_party_auth/tasks.py b/common/djangoapps/third_party_auth/tasks.py index 02fb0b53d7..62d06661cd 100644 --- a/common/djangoapps/third_party_auth/tasks.py +++ b/common/djangoapps/third_party_auth/tasks.py @@ -3,6 +3,8 @@ Code to manage fetching and storing the metadata of IdPs. """ +from __future__ import absolute_import + import datetime import logging @@ -16,8 +18,8 @@ from onelogin.saml2.utils import OneLogin_Saml2_Utils from requests import exceptions from six import text_type -from third_party_auth.models import SAMLConfiguration, SAMLProviderConfig, SAMLProviderData from openedx.core.djangolib.markup import Text +from third_party_auth.models import SAMLConfiguration, SAMLProviderConfig, SAMLProviderData log = logging.getLogger(__name__) diff --git a/common/djangoapps/third_party_auth/urls.py b/common/djangoapps/third_party_auth/urls.py index 76ea17d10a..9b0fec5a58 100644 --- a/common/djangoapps/third_party_auth/urls.py +++ b/common/djangoapps/third_party_auth/urls.py @@ -1,9 +1,16 @@ """Url configuration for the auth module.""" +from __future__ import absolute_import + from django.conf.urls import include, url -from .views import (inactive_user_view, lti_login_and_complete_view, - post_to_custom_auth_form, saml_metadata_view, IdPRedirectView) +from .views import ( + IdPRedirectView, + inactive_user_view, + lti_login_and_complete_view, + post_to_custom_auth_form, + saml_metadata_view +) urlpatterns = [ url(r'^auth/inactive', inactive_user_view, name="third_party_inactive_redirect"), diff --git a/common/djangoapps/third_party_auth/utils.py b/common/djangoapps/third_party_auth/utils.py index 6f7b7582e8..6b4e2e23b7 100644 --- a/common/djangoapps/third_party_auth/utils.py +++ b/common/djangoapps/third_party_auth/utils.py @@ -2,6 +2,8 @@ Utility functions for third_party_auth """ +from __future__ import absolute_import + from django.contrib.auth.models import User