Removes six

This commit is contained in:
Michael 2020-02-29 20:30:21 -06:00
parent 3402d1f2cd
commit a87a458ccf
7 changed files with 17 additions and 54 deletions

View File

@ -2,5 +2,4 @@ django>=1.9.0
dj-rest-auth==0.9.5
djangorestframework>=3.7.0
django-allauth>=0.24.1
six==1.9.0
django-rest-swagger==2.0.7

View File

@ -8,44 +8,27 @@ from dj_rest_auth.serializers import (
PasswordResetSerializer as DefaultPasswordResetSerializer,
PasswordResetConfirmSerializer as DefaultPasswordResetConfirmSerializer,
PasswordChangeSerializer as DefaultPasswordChangeSerializer)
from .utils import import_callable, default_create_token
from .utils import default_create_token
create_token = import_callable(
getattr(settings, 'REST_AUTH_TOKEN_CREATOR', default_create_token))
create_token = getattr(settings, 'REST_AUTH_TOKEN_CREATOR', default_create_token)
serializers = getattr(settings, 'REST_AUTH_SERIALIZERS', {})
TokenSerializer = import_callable(
serializers.get('TOKEN_SERIALIZER', DefaultTokenSerializer))
TokenSerializer = serializers.get('TOKEN_SERIALIZER', DefaultTokenSerializer)
JWTSerializer = import_callable(
serializers.get('JWT_SERIALIZER', DefaultJWTSerializer))
JWTSerializer = serializers.get('JWT_SERIALIZER', DefaultJWTSerializer)
UserDetailsSerializer = import_callable(
serializers.get('USER_DETAILS_SERIALIZER', DefaultUserDetailsSerializer)
)
UserDetailsSerializer = serializers.get('USER_DETAILS_SERIALIZER', DefaultUserDetailsSerializer)
LoginSerializer = import_callable(
serializers.get('LOGIN_SERIALIZER', DefaultLoginSerializer)
)
LoginSerializer = serializers.get('LOGIN_SERIALIZER', DefaultLoginSerializer)
PasswordResetSerializer = import_callable(
serializers.get(
PasswordResetSerializer = serializers.get(
'PASSWORD_RESET_SERIALIZER',
DefaultPasswordResetSerializer
)
PasswordResetConfirmSerializer = serializers.get(
'PASSWORD_RESET_CONFIRM_SERIALIZER', DefaultPasswordResetConfirmSerializer
)
PasswordResetConfirmSerializer = import_callable(
serializers.get(
'PASSWORD_RESET_CONFIRM_SERIALIZER',
DefaultPasswordResetConfirmSerializer
)
)
PasswordChangeSerializer = import_callable(
serializers.get(
'PASSWORD_CHANGE_SERIALIZER',
DefaultPasswordChangeSerializer
)
)
PasswordChangeSerializer = serializers.get('PASSWORD_CHANGE_SERIALIZER', DefaultPasswordChangeSerializer)

View File

@ -2,9 +2,7 @@ from django.conf import settings
from rest_framework.authtoken.models import Token as DefaultTokenModel
from .utils import import_callable
# Register your models here.
TokenModel = import_callable(
getattr(settings, 'REST_AUTH_TOKEN_MODEL', DefaultTokenModel))
TokenModel = getattr(settings, 'REST_AUTH_TOKEN_MODEL', DefaultTokenModel)

View File

@ -2,18 +2,17 @@ from django.conf import settings
from rest_framework.permissions import AllowAny
from rest_auth.registration.serializers import (
RegisterSerializer as DefaultRegisterSerializer)
from ..utils import import_callable
RegisterSerializer as DefaultRegisterSerializer
)
serializers = getattr(settings, 'REST_AUTH_REGISTER_SERIALIZERS', {})
RegisterSerializer = import_callable(
serializers.get('REGISTER_SERIALIZER', DefaultRegisterSerializer))
RegisterSerializer = serializers.get('REGISTER_SERIALIZER', DefaultRegisterSerializer)
def register_permission_classes():
permission_classes = [AllowAny, ]
for klass in getattr(settings, 'REST_AUTH_REGISTER_PERMISSION_CLASSES', tuple()):
permission_classes.append(import_callable(klass))
permission_classes.append(klass)
return tuple(permission_classes)

View File

@ -10,7 +10,6 @@ from rest_framework import serializers, exceptions
from rest_framework.exceptions import ValidationError
from .models import TokenModel
from .utils import import_callable
# Get the UserModel
UserModel = get_user_model()
@ -146,9 +145,7 @@ class JWTSerializer(serializers.Serializer):
JWTSerializer. Defining it here to avoid circular imports
"""
rest_auth_serializers = getattr(settings, 'REST_AUTH_SERIALIZERS', {})
JWTUserDetailsSerializer = import_callable(
rest_auth_serializers.get('USER_DETAILS_SERIALIZER', UserDetailsSerializer)
)
JWTUserDetailsSerializer = rest_auth_serializers.get('USER_DETAILS_SERIALIZER', UserDetailsSerializer)
user_data = JWTUserDetailsSerializer(obj['user'], context=self.context).data
return user_data

View File

@ -1,15 +1,3 @@
from six import string_types
from importlib import import_module
def import_callable(path_or_callable):
if hasattr(path_or_callable, '__call__'):
return path_or_callable
else:
assert isinstance(path_or_callable, string_types)
package, attr = path_or_callable.rsplit('.', 1)
return getattr(import_module(package), attr)
def default_create_token(token_model, user, serializer):
token, _ = token_model.objects.get_or_create(user=user)

View File

@ -25,7 +25,6 @@ setup(
install_requires=[
'Django>=1.8.0',
'djangorestframework>=3.1.3',
'six>=1.9.0',
],
extras_require={
'with_social': ['django-allauth>=0.25.0'],