From 0d762a6901fdab8454938a1f7d312ce17c1bd45a Mon Sep 17 00:00:00 2001 From: Steven Cummings Date: Sun, 24 Jun 2012 22:56:12 -0500 Subject: [PATCH] Moved definition of USERNAME_MAX_LENGTH to models modules --- social_auth/backends/pipeline/__init__.py | 9 ++------- social_auth/backends/pipeline/user.py | 4 ++-- social_auth/django_models.py | 7 +------ social_auth/mongoengine_models.py | 7 +------ 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/social_auth/backends/pipeline/__init__.py b/social_auth/backends/pipeline/__init__.py index 2866a99..7daabc9 100644 --- a/social_auth/backends/pipeline/__init__.py +++ b/social_auth/backends/pipeline/__init__.py @@ -5,16 +5,11 @@ to next pipeline item. Pipelines must take **kwargs parameters to avoid failure. At some point a pipeline entry must create a UserSocialAuth instance and load it to the output if the user logged in correctly. """ -import warnings - -from django.conf import settings -from social_auth.models import User -from social_auth.models import USERNAME, get_username_max_length -from social_auth.backends import get_backend, PIPELINE +import warnings -USERNAME_MAX_LENGTH = get_username_max_length() +from django.conf import settings def warn_setting(name, func_name): diff --git a/social_auth/backends/pipeline/user.py b/social_auth/backends/pipeline/user.py index ea06079..16eb1a3 100644 --- a/social_auth/backends/pipeline/user.py +++ b/social_auth/backends/pipeline/user.py @@ -3,8 +3,8 @@ from uuid import uuid4 from social_auth.utils import setting from social_auth.models import create_user as create_user_in_db from social_auth.models import simple_user_exists -from social_auth.backends.pipeline import USERNAME, USERNAME_MAX_LENGTH, \ - warn_setting +from social_auth.models import USERNAME, USERNAME_MAX_LENGTH +from social_auth.backends.pipeline import warn_setting from social_auth.signals import socialauth_not_registered, \ socialauth_registered, \ pre_update diff --git a/social_auth/django_models.py b/social_auth/django_models.py index 34f04f9..ed37b0d 100644 --- a/social_auth/django_models.py +++ b/social_auth/django_models.py @@ -27,12 +27,7 @@ else: # TODO make this a complementary config setting to SOCIAL_AUTH_USER_MODEL USERNAME = 'username' - - -def get_username_max_length(): - """Get the max length constraint from the User model username field. - """ - return User._meta.get_field(USERNAME).max_length +USERNAME_MAX_LENGTH = User._meta.get_field(USERNAME).max_length def simple_user_exists(*args, **kwargs): diff --git a/social_auth/mongoengine_models.py b/social_auth/mongoengine_models.py index 1f12b86..6a2a27d 100644 --- a/social_auth/mongoengine_models.py +++ b/social_auth/mongoengine_models.py @@ -35,12 +35,7 @@ else: # TODO make this a complementary config setting to SOCIAL_AUTH_USER_MODEL USERNAME = 'username' - - -def get_username_max_length(): - """Get the max length constraint from the User model username field. - """ - return getattr(User, USERNAME).max_length +USERNAME_MAX_LENGTH = getattr(User, USERNAME).max_length def simple_user_exists(*args, **kwargs): -- 2.39.5