Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dorantor/aeb26ab0f8d8d394cdc04ff22f1dd9df to your computer and use it in GitHub Desktop.
Save dorantor/aeb26ab0f8d8d394cdc04ff22f1dd9df to your computer and use it in GitHub Desktop.
Subject: [PATCH 1/1] Fixes to make it work with updated python-social-auth.
Ticket: #1307
---
weblate/accounts/auth.py | 6 +++---
weblate/accounts/migrations/0001_initial.py | 2 ++
weblate/accounts/models.py | 2 +-
weblate/accounts/pipeline.py | 4 ++--
weblate/accounts/urls.py | 2 +-
weblate/accounts/views.py | 6 +++---
weblate/settings_test.py | 1 +
7 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/weblate/accounts/auth.py b/weblate/accounts/auth.py
index 06fd6b6..d9ff635 100644
--- a/weblate/accounts/auth.py
+++ b/weblate/accounts/auth.py
@@ -28,15 +28,15 @@ from django.dispatch.dispatcher import receiver
from django.utils.translation import ugettext as _
from django.contrib.auth.backends import ModelBackend
-import social.backends.email
-from social.exceptions import AuthMissingParameter
+import social_core.backends.email
+from social_core.exceptions import AuthMissingParameter
from weblate.appsettings import ANONYMOUS_USER_NAME
from weblate.trans import messages
from weblate.utils.errors import report_error
-class EmailAuth(social.backends.email.EmailAuth):
+class EmailAuth(social_core.backends.email.EmailAuth):
"""Social auth handler to better report errors."""
def auth_complete(self, *args, **kwargs):
try:
diff --git a/weblate/accounts/migrations/0001_initial.py b/weblate/accounts/migrations/0001_initial.py
index f2f077b..9bafb97 100644
--- a/weblate/accounts/migrations/0001_initial.py
+++ b/weblate/accounts/migrations/0001_initial.py
@@ -8,6 +8,8 @@ from django.conf import settings
# App label has been changed in python-social-auth 0.2.20
if 'social_auth' in apps.app_configs:
SOCIAL_AUTH = 'social_auth'
+elif 'social_django' in apps.app_configs:
+ SOCIAL_AUTH = 'social_django'
else:
SOCIAL_AUTH = 'default'
diff --git a/weblate/accounts/models.py b/weblate/accounts/models.py
index c578b31..9b83bab 100644
--- a/weblate/accounts/models.py
+++ b/weblate/accounts/models.py
@@ -40,7 +40,7 @@ from django.utils.translation import LANGUAGE_SESSION_KEY
from rest_framework.authtoken.models import Token
-from social.apps.django_app.default.models import UserSocialAuth
+from social_django.models import UserSocialAuth
from weblate.lang.models import Language
from weblate.trans import messages
diff --git a/weblate/accounts/pipeline.py b/weblate/accounts/pipeline.py
index ad0b2df..113a0f1 100644
--- a/weblate/accounts/pipeline.py
+++ b/weblate/accounts/pipeline.py
@@ -29,8 +29,8 @@ from django.utils.translation import ugettext as _
from six.moves.urllib.request import Request, urlopen
-from social.pipeline.partial import partial
-from social.exceptions import (
+from social_core.pipeline.partial import partial
+from social_core.exceptions import (
AuthException, AuthMissingParameter, AuthAlreadyAssociated
)
diff --git a/weblate/accounts/urls.py b/weblate/accounts/urls.py
index 602f5fb..bd01493 100644
--- a/weblate/accounts/urls.py
+++ b/weblate/accounts/urls.py
@@ -57,5 +57,5 @@ urlpatterns = [
url(r'^login/$', weblate.accounts.views.weblate_login, name='login'),
url(r'^register/$', weblate.accounts.views.register, name='register'),
url(r'^email/$', weblate.accounts.views.email_login, name='email_login'),
- url(r'', include('social.apps.django_app.urls', namespace='social')),
+ url(r'', include('social_django.urls', namespace='social')),
]
diff --git a/weblate/accounts/views.py b/weblate/accounts/views.py
index 31ce248..ab1c3dd 100644
--- a/weblate/accounts/views.py
+++ b/weblate/accounts/views.py
@@ -41,9 +41,9 @@ from rest_framework.authtoken.models import Token
from six.moves.urllib.parse import urlencode
-from social.backends.utils import load_backends
-from social.apps.django_app.utils import BACKENDS
-from social.apps.django_app.views import complete
+from social_core.backends.utils import load_backends
+from social_django.utils import BACKENDS
+from social_django.views import complete
from weblate.accounts.forms import (
RegistrationForm, PasswordForm, PasswordChangeForm, EmailForm, ResetForm,
diff --git a/weblate/settings_test.py b/weblate/settings_test.py
index ad266fc..c840f7d 100644
--- a/weblate/settings_test.py
+++ b/weblate/settings_test.py
@@ -84,6 +84,7 @@ SESSION_COOKIE_HTTPONLY = False
# Test optional apps as well
INSTALLED_APPS += (
+ 'social_django',
'weblate.billing',
'weblate.gitexport',
)
--
2.1.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment