Projet

Général

Profil

0002-api_views-pep8ness-7862.patch

Benjamin Dauvergne, 13 novembre 2015 11:03

Télécharger (2,33 ko)

Voir les différences:

Subject: [PATCH 2/4] api_views: pep8ness (#7862)

 src/authentic2/api_views.py | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
src/authentic2/api_views.py
14 14
from rest_framework.generics import GenericAPIView
15 15
from rest_framework.response import Response
16 16
from rest_framework import authentication, permissions, status
17
from rest_framework.exceptions import PermissionDenied
18 17

  
19 18
from . import utils, decorators
20 19

  
......
59 58
                                                    'this ou'))
60 59
        User = get_user_model()
61 60
        if data['ou'] and data['ou'].email_is_unique and \
62
                User.objects.filter(ou=data['ou'],
63
                                   email__iexact=data['email']).exists():
61
                User.objects.filter(ou=data['ou'], email__iexact=data['email']).exists():
64 62
            raise serializers.ValidationError(
65 63
                _('You already have an account'))
66
        if data['ou'] and data['ou'].username_is_unique and not \
67
                'username' in data:
64
        if data['ou'] and data['ou'].username_is_unique and 'username' not in data:
68 65
            raise serializers.ValidationError(
69 66
                _('Username is required in this ou'))
70 67
        if data['ou'] and data['ou'].username_is_unique and \
71
               User.objects.filter(ou=data['ou'],
72
                                   username=data['username']).exists():
68
                User.objects.filter(ou=data['ou'], username=data['username']).exists():
73 69
            raise serializers.ValidationError(
74 70
                _('You already have an account'))
75 71
        return data
76 72

  
73

  
77 74
class RpcMixin(object):
78 75
    def post(self, request, format=None):
79 76
        serializer = self.get_serializer(data=request.data)
......
156 153

  
157 154
register = Register.as_view()
158 155

  
156

  
159 157
class PasswordChangeSerializer(serializers.Serializer):
160 158
    '''Register RPC payload'''
161 159
    email = serializers.EmailField()
162
-