mirror of
https://github.com/Tivix/django-rest-auth.git
synced 2024-12-03 22:33:43 +03:00
Removes six
This commit is contained in:
parent
3402d1f2cd
commit
a87a458ccf
|
@ -2,5 +2,4 @@ django>=1.9.0
|
||||||
dj-rest-auth==0.9.5
|
dj-rest-auth==0.9.5
|
||||||
djangorestframework>=3.7.0
|
djangorestframework>=3.7.0
|
||||||
django-allauth>=0.24.1
|
django-allauth>=0.24.1
|
||||||
six==1.9.0
|
|
||||||
django-rest-swagger==2.0.7
|
django-rest-swagger==2.0.7
|
||||||
|
|
|
@ -8,44 +8,27 @@ from dj_rest_auth.serializers import (
|
||||||
PasswordResetSerializer as DefaultPasswordResetSerializer,
|
PasswordResetSerializer as DefaultPasswordResetSerializer,
|
||||||
PasswordResetConfirmSerializer as DefaultPasswordResetConfirmSerializer,
|
PasswordResetConfirmSerializer as DefaultPasswordResetConfirmSerializer,
|
||||||
PasswordChangeSerializer as DefaultPasswordChangeSerializer)
|
PasswordChangeSerializer as DefaultPasswordChangeSerializer)
|
||||||
from .utils import import_callable, default_create_token
|
from .utils import default_create_token
|
||||||
|
|
||||||
create_token = import_callable(
|
create_token = getattr(settings, 'REST_AUTH_TOKEN_CREATOR', default_create_token)
|
||||||
getattr(settings, 'REST_AUTH_TOKEN_CREATOR', default_create_token))
|
|
||||||
|
|
||||||
serializers = getattr(settings, 'REST_AUTH_SERIALIZERS', {})
|
serializers = getattr(settings, 'REST_AUTH_SERIALIZERS', {})
|
||||||
|
|
||||||
TokenSerializer = import_callable(
|
TokenSerializer = serializers.get('TOKEN_SERIALIZER', DefaultTokenSerializer)
|
||||||
serializers.get('TOKEN_SERIALIZER', DefaultTokenSerializer))
|
|
||||||
|
|
||||||
JWTSerializer = import_callable(
|
JWTSerializer = serializers.get('JWT_SERIALIZER', DefaultJWTSerializer)
|
||||||
serializers.get('JWT_SERIALIZER', DefaultJWTSerializer))
|
|
||||||
|
|
||||||
UserDetailsSerializer = import_callable(
|
UserDetailsSerializer = serializers.get('USER_DETAILS_SERIALIZER', DefaultUserDetailsSerializer)
|
||||||
serializers.get('USER_DETAILS_SERIALIZER', DefaultUserDetailsSerializer)
|
|
||||||
)
|
|
||||||
|
|
||||||
LoginSerializer = import_callable(
|
LoginSerializer = serializers.get('LOGIN_SERIALIZER', DefaultLoginSerializer)
|
||||||
serializers.get('LOGIN_SERIALIZER', DefaultLoginSerializer)
|
|
||||||
)
|
|
||||||
|
|
||||||
PasswordResetSerializer = import_callable(
|
PasswordResetSerializer = serializers.get(
|
||||||
serializers.get(
|
|
||||||
'PASSWORD_RESET_SERIALIZER',
|
'PASSWORD_RESET_SERIALIZER',
|
||||||
DefaultPasswordResetSerializer
|
DefaultPasswordResetSerializer
|
||||||
)
|
)
|
||||||
|
|
||||||
|
PasswordResetConfirmSerializer = serializers.get(
|
||||||
|
'PASSWORD_RESET_CONFIRM_SERIALIZER', DefaultPasswordResetConfirmSerializer
|
||||||
)
|
)
|
||||||
|
|
||||||
PasswordResetConfirmSerializer = import_callable(
|
PasswordChangeSerializer = serializers.get('PASSWORD_CHANGE_SERIALIZER', DefaultPasswordChangeSerializer)
|
||||||
serializers.get(
|
|
||||||
'PASSWORD_RESET_CONFIRM_SERIALIZER',
|
|
||||||
DefaultPasswordResetConfirmSerializer
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
PasswordChangeSerializer = import_callable(
|
|
||||||
serializers.get(
|
|
||||||
'PASSWORD_CHANGE_SERIALIZER',
|
|
||||||
DefaultPasswordChangeSerializer
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
|
@ -2,9 +2,7 @@ from django.conf import settings
|
||||||
|
|
||||||
from rest_framework.authtoken.models import Token as DefaultTokenModel
|
from rest_framework.authtoken.models import Token as DefaultTokenModel
|
||||||
|
|
||||||
from .utils import import_callable
|
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
|
||||||
TokenModel = import_callable(
|
TokenModel = getattr(settings, 'REST_AUTH_TOKEN_MODEL', DefaultTokenModel)
|
||||||
getattr(settings, 'REST_AUTH_TOKEN_MODEL', DefaultTokenModel))
|
|
||||||
|
|
|
@ -2,18 +2,17 @@ from django.conf import settings
|
||||||
|
|
||||||
from rest_framework.permissions import AllowAny
|
from rest_framework.permissions import AllowAny
|
||||||
from rest_auth.registration.serializers import (
|
from rest_auth.registration.serializers import (
|
||||||
RegisterSerializer as DefaultRegisterSerializer)
|
RegisterSerializer as DefaultRegisterSerializer
|
||||||
from ..utils import import_callable
|
)
|
||||||
|
|
||||||
|
|
||||||
serializers = getattr(settings, 'REST_AUTH_REGISTER_SERIALIZERS', {})
|
serializers = getattr(settings, 'REST_AUTH_REGISTER_SERIALIZERS', {})
|
||||||
|
|
||||||
RegisterSerializer = import_callable(
|
RegisterSerializer = serializers.get('REGISTER_SERIALIZER', DefaultRegisterSerializer)
|
||||||
serializers.get('REGISTER_SERIALIZER', DefaultRegisterSerializer))
|
|
||||||
|
|
||||||
|
|
||||||
def register_permission_classes():
|
def register_permission_classes():
|
||||||
permission_classes = [AllowAny, ]
|
permission_classes = [AllowAny, ]
|
||||||
for klass in getattr(settings, 'REST_AUTH_REGISTER_PERMISSION_CLASSES', tuple()):
|
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)
|
return tuple(permission_classes)
|
||||||
|
|
|
@ -10,7 +10,6 @@ from rest_framework import serializers, exceptions
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
|
|
||||||
from .models import TokenModel
|
from .models import TokenModel
|
||||||
from .utils import import_callable
|
|
||||||
|
|
||||||
# Get the UserModel
|
# Get the UserModel
|
||||||
UserModel = get_user_model()
|
UserModel = get_user_model()
|
||||||
|
@ -146,9 +145,7 @@ class JWTSerializer(serializers.Serializer):
|
||||||
JWTSerializer. Defining it here to avoid circular imports
|
JWTSerializer. Defining it here to avoid circular imports
|
||||||
"""
|
"""
|
||||||
rest_auth_serializers = getattr(settings, 'REST_AUTH_SERIALIZERS', {})
|
rest_auth_serializers = getattr(settings, 'REST_AUTH_SERIALIZERS', {})
|
||||||
JWTUserDetailsSerializer = import_callable(
|
JWTUserDetailsSerializer = rest_auth_serializers.get('USER_DETAILS_SERIALIZER', UserDetailsSerializer)
|
||||||
rest_auth_serializers.get('USER_DETAILS_SERIALIZER', UserDetailsSerializer)
|
|
||||||
)
|
|
||||||
user_data = JWTUserDetailsSerializer(obj['user'], context=self.context).data
|
user_data = JWTUserDetailsSerializer(obj['user'], context=self.context).data
|
||||||
return user_data
|
return user_data
|
||||||
|
|
||||||
|
|
|
@ -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):
|
def default_create_token(token_model, user, serializer):
|
||||||
token, _ = token_model.objects.get_or_create(user=user)
|
token, _ = token_model.objects.get_or_create(user=user)
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -25,7 +25,6 @@ setup(
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'Django>=1.8.0',
|
'Django>=1.8.0',
|
||||||
'djangorestframework>=3.1.3',
|
'djangorestframework>=3.1.3',
|
||||||
'six>=1.9.0',
|
|
||||||
],
|
],
|
||||||
extras_require={
|
extras_require={
|
||||||
'with_social': ['django-allauth>=0.25.0'],
|
'with_social': ['django-allauth>=0.25.0'],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user