Passed
Pull Request — master (#266)
by
unknown
01:40
created

UserCreateSerializer.create()   A

Complexity

Conditions 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 2
1
from django.contrib.auth import authenticate, get_user_model
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
from django.contrib.auth.password_validation import validate_password
3
from django.core import exceptions as django_exceptions
0 ignored issues
show
Unused Code introduced by
Unused exceptions imported from django.core as django_exceptions
Loading history...
4
from django.db import IntegrityError, transaction
5
6
from rest_framework import exceptions, serializers
7
8
from djoser import constants, utils
9
from djoser.compat import get_user_email, get_user_email_field_name
10
from djoser.conf import settings
11
12
User = get_user_model()
0 ignored issues
show
Coding Style Naming introduced by
The name User does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
13
14
15
class UserSerializer(serializers.ModelSerializer):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
16
    class Meta:
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
introduced by
Old-style class defined.
Loading history...
Coding Style introduced by
This class has no __init__ method.
Loading history...
17
        model = User
18
        fields = tuple(User.REQUIRED_FIELDS) + (
19
            User._meta.pk.name,
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _meta was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
20
            User.USERNAME_FIELD,
21
        )
22
        read_only_fields = (User.USERNAME_FIELD,)
23
24
    def update(self, instance, validated_data):
25
        email_field = get_user_email_field_name(User)
26
        if settings.SEND_ACTIVATION_EMAIL and email_field in validated_data:
27
            instance_email = get_user_email(instance)
28
            if instance_email != validated_data[email_field]:
29
                instance.is_active = False
30
                instance.save(update_fields=['is_active'])
31
        return super(UserSerializer, self).update(instance, validated_data)
32
33
34
class UserCreateSerializer(serializers.ModelSerializer):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
35
    password = serializers.CharField(
36
        style={'input_type': 'password'},
37
        write_only=True
38
    )
39
40
    default_error_messages = {
41
        'cannot_create_user': constants.CANNOT_CREATE_USER_ERROR,
42
    }
43
44
    class Meta:
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
introduced by
Old-style class defined.
Loading history...
Coding Style introduced by
This class has no __init__ method.
Loading history...
45
        model = User
46
        fields = tuple(User.REQUIRED_FIELDS) + (
47
            User.USERNAME_FIELD, User._meta.pk.name, 'password',
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _meta was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
48
        )
49
50
    def validate_password(self, value):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
51
        validate_password(value)
52
        return value
53
54
    def create(self, validated_data):
55
        try:
56
            user = self.perform_create(validated_data)
57
        except IntegrityError:
58
            self.fail('cannot_create_user')
59
60
        return user
61
62
    def perform_create(self, validated_data):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
63
        with transaction.atomic():
64
            user = User.objects.create_user(**validated_data)
65
            if settings.SEND_ACTIVATION_EMAIL:
66
                user.is_active = False
67
                user.save(update_fields=['is_active'])
68
        return user
69
70
71
class TokenCreateSerializer(serializers.Serializer):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Bug introduced by
The method create which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method update which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
72
    password = serializers.CharField(
73
        required=False, style={'input_type': 'password'}
74
    )
75
76
    default_error_messages = {
77
        'invalid_credentials': constants.INVALID_CREDENTIALS_ERROR,
78
        'inactive_account': constants.INACTIVE_ACCOUNT_ERROR,
79
    }
80
81
    def __init__(self, *args, **kwargs):
82
        super(TokenCreateSerializer, self).__init__(*args, **kwargs)
83
        self.user = None
84
        self.fields[User.USERNAME_FIELD] = serializers.CharField(
85
            required=False
86
        )
87
88
    def validate(self, attrs):
89
        self.user = authenticate(
90
            username=attrs.get(User.USERNAME_FIELD),
91
            password=attrs.get('password')
92
        )
93
94
        self._validate_user_exists(self.user)
95
        self._validate_user_is_active(self.user)
96
        return attrs
97
98
    def _validate_user_exists(self, user):
99
        if not user:
100
            self.fail('invalid_credentials')
101
102
    def _validate_user_is_active(self, user):
103
        if not user.is_active:
104
            self.fail('inactive_account')
105
106
107
class PasswordResetSerializer(serializers.Serializer):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Bug introduced by
The method create which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method update which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
108
    email = serializers.EmailField()
109
110
    default_error_messages = {'email_not_found': constants.EMAIL_NOT_FOUND}
111
112
    def validate_email(self, value):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
113
        users = self.context['view'].get_users(value)
114
        if settings.PASSWORD_RESET_SHOW_EMAIL_NOT_FOUND and not users:
115
            self.fail('email_not_found')
116
        else:
117
            return value
118
119
120
class UidAndTokenSerializer(serializers.Serializer):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Bug introduced by
The method create which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method update which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
121
    uid = serializers.CharField()
122
    token = serializers.CharField()
123
124
    default_error_messages = {
125
        'invalid_token': constants.INVALID_TOKEN_ERROR,
126
        'invalid_uid': constants.INVALID_UID_ERROR,
127
    }
128
129
    def validate_uid(self, value):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
130
        try:
131
            uid = utils.decode_uid(value)
132
            self.user = User.objects.get(pk=uid)
0 ignored issues
show
Coding Style introduced by
The attribute user was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
133
        except (User.DoesNotExist, ValueError, TypeError, OverflowError):
134
            self.fail('invalid_uid')
135
136
        return value
137
138
    def validate(self, attrs):
139
        attrs = super(UidAndTokenSerializer, self).validate(attrs)
140
        is_token_valid = self.context['view'].token_generator.check_token(
141
            self.user, attrs['token']
142
        )
143
        if is_token_valid:
144
            return attrs
145
        else:
146
            self.fail('invalid_token')
147
148
149
class ActivationSerializer(UidAndTokenSerializer):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Bug introduced by
The method create which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method update which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
150
    default_error_messages = {'stale_token': constants.STALE_TOKEN_ERROR}
151
152
    def validate(self, attrs):
153
        attrs = super(ActivationSerializer, self).validate(attrs)
154
        if not self.user.is_active:
155
            return attrs
156
        raise exceptions.PermissionDenied(self.error_messages['stale_token'])
157
158
159
class PasswordSerializer(serializers.Serializer):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Bug introduced by
The method create which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method update which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
160
    new_password = serializers.CharField(style={'input_type': 'password'})
161
162
    def validate_new_password(self, value):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
163
        user = self.context['request'].user or self.user
0 ignored issues
show
Bug introduced by
The Instance of PasswordSerializer does not seem to have a member named user.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
164
        assert user is not None
165
        validate_password(value, user)
166
        return value
167
168
169
class PasswordRetypeSerializer(PasswordSerializer):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Bug introduced by
The method create which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method update which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
170
    re_new_password = serializers.CharField(style={'input_type': 'password'})
171
172
    default_error_messages = {
173
        'password_mismatch': constants.PASSWORD_MISMATCH_ERROR,
174
    }
175
176
    def validate(self, attrs):
177
        attrs = super(PasswordRetypeSerializer, self).validate(attrs)
178
        if attrs['new_password'] == attrs['re_new_password']:
179
            return attrs
180
        else:
181
            self.fail('password_mismatch')
182
183
184
class CurrentPasswordSerializer(serializers.Serializer):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Bug introduced by
The method create which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method update which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
185
    current_password = serializers.CharField(style={'input_type': 'password'})
186
187
    default_error_messages = {
188
        'invalid_password': constants.INVALID_PASSWORD_ERROR,
189
    }
190
191
    def validate_current_password(self, value):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
192
        is_password_valid = self.context['request'].user.check_password(value)
193
        if is_password_valid:
194
            return value
195
        else:
196
            self.fail('invalid_password')
197
198
199
class SetPasswordSerializer(PasswordSerializer, CurrentPasswordSerializer):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Bug introduced by
The method create which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method update which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
200
    pass
201
202
203
class SetPasswordRetypeSerializer(PasswordRetypeSerializer,
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Bug introduced by
The method create which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method update which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
204
                                  CurrentPasswordSerializer):
205
    pass
206
207
208
class PasswordResetConfirmSerializer(UidAndTokenSerializer,
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Bug introduced by
The method create which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method update which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
209
                                     PasswordSerializer):
210
    pass
211
212
213
class PasswordResetConfirmRetypeSerializer(UidAndTokenSerializer,
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Bug introduced by
The method create which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method update which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
214
                                           PasswordRetypeSerializer):
215
    pass
216
217
218
class UserDeleteSerializer(CurrentPasswordSerializer):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Bug introduced by
The method create which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method update which was declared abstract in the super-class BaseSerializer
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
219
    pass
220
221
222
class SetUsernameSerializer(serializers.ModelSerializer,
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
223
                            CurrentPasswordSerializer):
224
225
    class Meta(object):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
226
        model = User
227
        fields = (User.USERNAME_FIELD, 'current_password')
228
229
    def __init__(self, *args, **kwargs):
230
        """
231
        This method should probably be replaced by a better solution.
232
        Its purpose is to replace USERNAME_FIELD with 'new_' + USERNAME_FIELD
233
        so that the new field is being assigned a field for USERNAME_FIELD
234
        """
235
        super(SetUsernameSerializer, self).__init__(*args, **kwargs)
236
        username_field = User.USERNAME_FIELD
237
        self.fields['new_' + username_field] = self.fields.pop(username_field)
238
239
240
class SetUsernameRetypeSerializer(SetUsernameSerializer):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
241
    default_error_messages = {
242
        'username_mismatch': constants.USERNAME_MISMATCH_ERROR.format(
0 ignored issues
show
Bug introduced by
The Instance of __proxy__ does not seem to have a member named format.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
243
            User.USERNAME_FIELD
244
        ),
245
    }
246
247
    def __init__(self, *args, **kwargs):
248
        super(SetUsernameRetypeSerializer, self).__init__(*args, **kwargs)
249
        self.fields['re_new_' + User.USERNAME_FIELD] = serializers.CharField()
250
251
    def validate(self, attrs):
252
        attrs = super(SetUsernameRetypeSerializer, self).validate(attrs)
253
        new_username = attrs[User.USERNAME_FIELD]
254
        if new_username != attrs['re_new_' + User.USERNAME_FIELD]:
255
            self.fail('username_mismatch')
256
        else:
257
            return attrs
258
259
260
class TokenSerializer(serializers.ModelSerializer):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
261
    auth_token = serializers.CharField(source='key')
262
263
    class Meta:
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
introduced by
Old-style class defined.
Loading history...
Coding Style introduced by
This class has no __init__ method.
Loading history...
264
        model = settings.TOKEN_MODEL
265
        fields = ('auth_token',)
266