Commit f8b50cd4 authored by Michael Fladischer's avatar Michael Fladischer

New upstream version 1.3.0

parent 54f4d660
Metadata-Version: 1.1 Metadata-Version: 1.1
Name: djoser Name: djoser
Version: 1.2.1 Version: 1.3.0
Summary: REST version of Django authentication system. Summary: REST version of Django authentication system.
Home-page: https://github.com/sunscrapers/djoser Home-page: https://github.com/sunscrapers/djoser
Author: SUNSCRAPERS Author: SUNSCRAPERS
...@@ -43,9 +43,10 @@ Description: ====== ...@@ -43,9 +43,10 @@ Description: ======
To be able to run **djoser** you have to meet following requirements: To be able to run **djoser** you have to meet following requirements:
- Python (2.7, 3.4, 3.5, 3.6) - Python (2.7, 3.4, 3.5, 3.6)
- Django (1.11, 2.0) - Django (1.11, 2.0, 2.1)
- Django REST Framework (3.7, 3.8) - Django REST Framework (3.7, 3.8)
Bear in mind that for Django-2.x you will need at least Python 3.5
Installation Installation
============ ============
......
...@@ -35,9 +35,10 @@ Requirements ...@@ -35,9 +35,10 @@ Requirements
To be able to run **djoser** you have to meet following requirements: To be able to run **djoser** you have to meet following requirements:
- Python (2.7, 3.4, 3.5, 3.6) - Python (2.7, 3.4, 3.5, 3.6)
- Django (1.11, 2.0) - Django (1.11, 2.0, 2.1)
- Django REST Framework (3.7, 3.8) - Django REST Framework (3.7, 3.8)
Bear in mind that for Django-2.x you will need at least Python 3.5
Installation Installation
============ ============
......
Metadata-Version: 1.1 Metadata-Version: 1.1
Name: djoser Name: djoser
Version: 1.2.1 Version: 1.3.0
Summary: REST version of Django authentication system. Summary: REST version of Django authentication system.
Home-page: https://github.com/sunscrapers/djoser Home-page: https://github.com/sunscrapers/djoser
Author: SUNSCRAPERS Author: SUNSCRAPERS
...@@ -43,9 +43,10 @@ Description: ====== ...@@ -43,9 +43,10 @@ Description: ======
To be able to run **djoser** you have to meet following requirements: To be able to run **djoser** you have to meet following requirements:
- Python (2.7, 3.4, 3.5, 3.6) - Python (2.7, 3.4, 3.5, 3.6)
- Django (1.11, 2.0) - Django (1.11, 2.0, 2.1)
- Django REST Framework (3.7, 3.8) - Django REST Framework (3.7, 3.8)
Bear in mind that for Django-2.x you will need at least Python 3.5
Installation Installation
============ ============
......
__version__ = "1.2.0" __version__ = "1.3.0"
...@@ -55,6 +55,8 @@ default_settings = { ...@@ -55,6 +55,8 @@ default_settings = {
'djoser.serializers.UserDeleteSerializer', 'djoser.serializers.UserDeleteSerializer',
'user': 'user':
'djoser.serializers.UserSerializer', 'djoser.serializers.UserSerializer',
'current_user':
'djoser.serializers.CurrentUserSerializer',
'token': 'token':
'djoser.serializers.TokenSerializer', 'djoser.serializers.TokenSerializer',
'token_create': 'token_create':
......
import warnings
from django.contrib.auth import authenticate, get_user_model from django.contrib.auth import authenticate, get_user_model
from django.contrib.auth.password_validation import validate_password from django.contrib.auth.password_validation import validate_password
from django.core import exceptions as django_exceptions from django.core import exceptions as django_exceptions
...@@ -31,6 +33,23 @@ class UserSerializer(serializers.ModelSerializer): ...@@ -31,6 +33,23 @@ class UserSerializer(serializers.ModelSerializer):
return super(UserSerializer, self).update(instance, validated_data) return super(UserSerializer, self).update(instance, validated_data)
class CurrentUserSerializer(settings.SERIALIZERS.user):
def __init__(self, *args, **kwargs):
# Warn user about serializer split
warnings.simplefilter('default')
warnings.warn(
(
'Current user endpoints now use their own serializer setting. '
'For more information, see: '
'https://djoser.readthedocs.io/en/latest/settings.html#serializers' # noqa
),
DeprecationWarning,
)
# Perform regular init actions
super(CurrentUserSerializer, self).__init__(*args, **kwargs)
class UserCreateSerializer(serializers.ModelSerializer): class UserCreateSerializer(serializers.ModelSerializer):
password = serializers.CharField( password = serializers.CharField(
style={'input_type': 'password'}, style={'input_type': 'password'},
......
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.contrib.auth.tokens import default_token_generator from django.contrib.auth.tokens import default_token_generator
from django.urls.exceptions import NoReverseMatch from django.urls.exceptions import NoReverseMatch
from django.utils.timezone import now
from rest_framework import generics, permissions, status, views, viewsets from rest_framework import generics, permissions, status, views, viewsets
from rest_framework.decorators import list_route from rest_framework.decorators import list_route
from rest_framework.response import Response from rest_framework.response import Response
...@@ -194,6 +195,8 @@ class PasswordResetConfirmView(utils.ActionViewMixin, generics.GenericAPIView): ...@@ -194,6 +195,8 @@ class PasswordResetConfirmView(utils.ActionViewMixin, generics.GenericAPIView):
def _action(self, serializer): def _action(self, serializer):
serializer.user.set_password(serializer.data['new_password']) serializer.user.set_password(serializer.data['new_password'])
if hasattr(serializer.user, 'last_login'):
serializer.user.last_login = now()
serializer.user.save() serializer.user.save()
return Response(status=status.HTTP_204_NO_CONTENT) return Response(status=status.HTTP_204_NO_CONTENT)
...@@ -283,17 +286,28 @@ class UserViewSet(UserCreateView, viewsets.ModelViewSet): ...@@ -283,17 +286,28 @@ class UserViewSet(UserCreateView, viewsets.ModelViewSet):
return super(UserViewSet, self).get_permissions() return super(UserViewSet, self).get_permissions()
def get_serializer_class(self): def get_serializer_class(self):
if self.action == 'me':
# Use the current user serializer on 'me' endpoints
self.serializer_class = settings.SERIALIZERS.current_user
if self.action == 'create': if self.action == 'create':
return settings.SERIALIZERS.user_create return settings.SERIALIZERS.user_create
elif self.action == 'remove' or ( elif self.action == 'remove' or (
self.action == 'me' and self.request.method == 'DELETE'): self.action == 'me' and self.request and
self.request.method == 'DELETE'
):
return settings.SERIALIZERS.user_delete return settings.SERIALIZERS.user_delete
elif self.action == 'confirm': elif self.action == 'confirm':
return settings.SERIALIZERS.activation return settings.SERIALIZERS.activation
elif self.action == 'change_username': elif self.action == 'change_username':
if settings.SET_USERNAME_RETYPE: if settings.SET_USERNAME_RETYPE:
return settings.SERIALIZERS.set_username_retype return settings.SERIALIZERS.set_username_retype
return settings.SERIALIZERS.set_username return settings.SERIALIZERS.set_username
return self.serializer_class return self.serializer_class
def get_instance(self): def get_instance(self):
......
...@@ -4,6 +4,7 @@ djangorestframework-jwt==1.11.0 ...@@ -4,6 +4,7 @@ djangorestframework-jwt==1.11.0
djet==0.2.1 djet==0.2.1
social-auth-app-django==2.1.0 social-auth-app-django==2.1.0
coverage==4.4.1 coverage==4.4.1
coreapi==2.3.3
pytest==3.6.2 pytest==3.6.2
pytest-cov==2.5.1 pytest-cov==2.5.1
......
...@@ -17,7 +17,7 @@ def get_packages(package): ...@@ -17,7 +17,7 @@ def get_packages(package):
setup( setup(
name='djoser', name='djoser',
version='1.2.1', version='1.3.0',
packages=get_packages('djoser'), packages=get_packages('djoser'),
license='MIT', license='MIT',
author='SUNSCRAPERS', author='SUNSCRAPERS',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment