mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-09 06:44:47 +03:00
review cleanup
This commit is contained in:
parent
24ba3b3743
commit
ba21a1e551
|
@ -18,20 +18,17 @@ class AuthTokenSerializer(serializers.Serializer):
|
||||||
if user:
|
if user:
|
||||||
if not user.is_active:
|
if not user.is_active:
|
||||||
msg = _('User account is disabled.')
|
msg = _('User account is disabled.')
|
||||||
raise serializers.ValidationError(
|
code = 'authorization'
|
||||||
msg,
|
raise serializers.ValidationError(msg, code=code)
|
||||||
code='authorization')
|
|
||||||
else:
|
else:
|
||||||
msg = _('Unable to log in with provided credentials.')
|
msg = _('Unable to log in with provided credentials.')
|
||||||
raise serializers.ValidationError(
|
code = 'authorization'
|
||||||
msg,
|
raise serializers.ValidationError(msg, code=code)
|
||||||
code='authorization')
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
msg = _('Must include "username" and "password".')
|
msg = _('Must include "username" and "password".')
|
||||||
raise serializers.ValidationError(
|
code = 'authorization'
|
||||||
msg,
|
raise serializers.ValidationError(msg, code=code)
|
||||||
code='authorization')
|
|
||||||
|
|
||||||
attrs['user'] = user
|
attrs['user'] = user
|
||||||
return attrs
|
return attrs
|
||||||
|
|
|
@ -31,9 +31,7 @@ from rest_framework.compat import (
|
||||||
MinValueValidator, duration_string, parse_duration, unicode_repr,
|
MinValueValidator, duration_string, parse_duration, unicode_repr,
|
||||||
unicode_to_repr
|
unicode_to_repr
|
||||||
)
|
)
|
||||||
from rest_framework.exceptions import (
|
from rest_framework.exceptions import ValidationError
|
||||||
ValidationError
|
|
||||||
)
|
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework.settings import api_settings
|
||||||
from rest_framework.utils import html, humanize_datetime, representation
|
from rest_framework.utils import html, humanize_datetime, representation
|
||||||
|
|
||||||
|
|
|
@ -147,9 +147,9 @@ class UniqueTogetherValidator(object):
|
||||||
]
|
]
|
||||||
if None not in checked_values and queryset.exists():
|
if None not in checked_values and queryset.exists():
|
||||||
field_names = ', '.join(self.fields)
|
field_names = ', '.join(self.fields)
|
||||||
raise ValidationError(
|
message = self.message.format(field_names=field_names)
|
||||||
self.message.format(field_names=field_names),
|
code = 'unique'
|
||||||
code='unique')
|
raise ValidationError(message, code=code)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return unicode_to_repr('<%s(queryset=%s, fields=%s)>' % (
|
return unicode_to_repr('<%s(queryset=%s, fields=%s)>' % (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user