]> git.parisson.com Git - django-social-auth.git/commitdiff
Account already in use exception
authorAndrii Kostenko <andrey@kostenko.name>
Fri, 17 Feb 2012 11:41:04 +0000 (15:41 +0400)
committerAndrii Kostenko <andrey@kostenko.name>
Fri, 17 Feb 2012 11:41:04 +0000 (15:41 +0400)
Moved exception class to exceptions.py module

social_auth/backends/__init__.py
social_auth/backends/exceptions.py
social_auth/backends/pipeline/social.py
social_auth/locale/ru/LC_MESSAGES/django.mo
social_auth/locale/ru/LC_MESSAGES/django.po
social_auth/tests/facebook.py
social_auth/utils.py
social_auth/views.py

index 0b06d371ea1c0cd385e28de0969f6a0e0dca99a9..ea99c1eaf8d5ae2f9ae4d6b87050f4202cdd7e37 100644 (file)
@@ -27,7 +27,8 @@ from django.contrib.auth.backends import ModelBackend
 from django.utils import simplejson
 from django.utils.importlib import import_module
 
-from social_auth.utils import setting, log, model_to_ctype, ctype_to_model, DSAException
+from social_auth.utils import setting, log, model_to_ctype, ctype_to_model
+from social_auth.backends.exceptions import DSAException
 from social_auth.store import DjangoOpenIDStore
 from social_auth.backends.exceptions import StopPipeline
 
index 8518b314b8ae1d88c6b0597bcf60e2b40b5ce896..c0e52cba5e70aa1a4dacc57079e39b2a687ffab6 100644 (file)
@@ -1,5 +1,15 @@
+# coding=utf-8
+
 class StopPipeline(Exception):
     """Stop pipeline process exception.
     Raise this exception to stop the rest of the pipeline process.
     """
     pass
+
+
+class DSAException(ValueError):
+    """
+    django-social-auth exception. This exception can be showed to user. It is thrown in normal situations – user declined
+    access, access token expired, etc.
+    """
+    pass
\ No newline at end of file
index d8436166d20c6cd8165cec91a32bbbbb47cac7bb..02c085fafb0fdc4927bb1357eb73b9d5299ea96a 100644 (file)
@@ -1,8 +1,10 @@
 from django.db.utils import IntegrityError
+from django.utils.translation import ugettext
 
 from social_auth.utils import setting
 from social_auth.models import UserSocialAuth
 from social_auth.backends.pipeline import warn_setting
+from social_auth.backends.exceptions import DSAException
 
 
 def social_auth_user(backend, uid, user=None, *args, **kwargs):
@@ -20,7 +22,9 @@ def social_auth_user(backend, uid, user=None, *args, **kwargs):
 
     if social_user:
         if user and social_user.user != user:
-            raise ValueError('Account already in use.', social_user)
+            raise DSAException(ugettext('This %(provider)s account already in use.') % {
+                'provider':backend.name,
+            })
         elif not user:
             user = social_user.user
     return {'social_user': social_user, 'user': user}
index 9d0cc9cd89afc38d2c0b0f16294668bd6b62097f..7cf315be43b13e7264b59fee9e3f2aa42d74b0c1 100644 (file)
Binary files a/social_auth/locale/ru/LC_MESSAGES/django.mo and b/social_auth/locale/ru/LC_MESSAGES/django.mo differ
index 1a62569ab1d02f2f4a8db30dd8e3d34e8d5325f7..a810bb396bca24065b62e7f2be4a36053ca23c1b 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-02-16 21:41+0400\n"
+"POT-Creation-Date: 2012-02-17 15:25+0400\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -16,22 +16,23 @@ msgstr ""
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%"
-"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
+"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
+"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
 
-#: build/lib/social_auth/views.py:70 social_auth/views.py:70
+#: views.py:71
 msgid "Unknown authentication error. Try again later."
 msgstr "Непредвиденная ошибка аутентификации. Попробуйте позже."
 
-#: build/lib/social_auth/backends/__init__.py:634
-#: build/lib/social_auth/backends/__init__.py:655
-#: social_auth/backends/__init__.py:634 social_auth/backends/__init__.py:655
+#: backends/__init__.py:635 backends/__init__.py:656
 msgid "Authentication process was cancelled"
 msgstr "Процесс аутентификации был прерван"
 
-#: build/lib/social_auth/backends/__init__.py:636
-#: build/lib/social_auth/backends/__init__.py:657
-#: social_auth/backends/__init__.py:636 social_auth/backends/__init__.py:657
+#: backends/__init__.py:637 backends/__init__.py:658
 #, python-format
 msgid "Authentication failed: %s"
 msgstr "Ошибка аутентификации: %s"
+
+#: backends/pipeline/social.py:25
+#, python-format
+msgid "This %(provider)s account already in use."
+msgstr "Этот аккаунт %(provider)s уже используется."
index 74d5b47e752b10ae9acaacbc6c1bfa4227465f51..444343b75bfd860d4056192a060b4810c6088370 100644 (file)
@@ -58,6 +58,7 @@ class FacebookTestLogin(FacebookTestCase):
             redirect_page = content
 
         url = REDIRECT_RE.findall(redirect_page)
+        print redirect_page
         self.assertTrue(url)
         # URL comes on JS scaped, needs to be clean first, any better way?
         url = url[0].replace('\u0025', '%').replace('\\', '')
index 4a0601a83cf1f0453b7300262892b0a997b9abbc..e53f680e61b2bf0ba7c6708a559ce76dfc249195 100644 (file)
@@ -7,13 +7,6 @@ from django.conf import settings
 from django.db.models import Model
 from django.contrib.contenttypes.models import ContentType
 
-class DSAException(ValueError):
-    """
-    django-social-auth exception. This exception can be showed to user. It is thrown in normal situations – user declined
-    access, access token expired, etc.
-    """
-    pass
-
 
 def sanitize_log_data(secret, data=None, leave_characters=4):
     """
index 6caeaebd93a5f61528d8cd046b7a6dc7b9601981..ba99f94ec8e70a8c63b31e314cf34d9d0fc311d5 100644 (file)
@@ -17,7 +17,8 @@ from django.utils.translation import ugettext
 from django.views.decorators.csrf import csrf_exempt
 
 from social_auth.backends import get_backend
-from social_auth.utils import sanitize_redirect, setting, log, DSAException
+from social_auth.utils import sanitize_redirect, setting, log
+from social_auth.backends.exceptions import DSAException
 
 
 DEFAULT_REDIRECT = setting('SOCIAL_AUTH_LOGIN_REDIRECT_URL') or \