Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
review cleanup
  • Loading branch information
johnraz committed Dec 18, 2015
commit ba21a1e551c047dc7cd5563b3c7d1fe0ec5b94ad
15 changes: 6 additions & 9 deletions rest_framework/authtoken/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,17 @@ def validate(self, attrs):
if user:
if not user.is_active:
msg = _('User account is disabled.')
raise serializers.ValidationError(
msg,
code='authorization')
code = 'authorization'
raise serializers.ValidationError(msg, code=code)
else:
msg = _('Unable to log in with provided credentials.')
raise serializers.ValidationError(
msg,
code='authorization')
code = 'authorization'
raise serializers.ValidationError(msg, code=code)

else:
msg = _('Must include "username" and "password".')
raise serializers.ValidationError(
msg,
code='authorization')
code = 'authorization'
raise serializers.ValidationError(msg, code=code)

attrs['user'] = user
return attrs
4 changes: 1 addition & 3 deletions rest_framework/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
MinValueValidator, duration_string, parse_duration, unicode_repr,
unicode_to_repr
)
from rest_framework.exceptions import (
ValidationError
)
from rest_framework.exceptions import ValidationError
from rest_framework.settings import api_settings
from rest_framework.utils import html, humanize_datetime, representation

Expand Down
6 changes: 3 additions & 3 deletions rest_framework/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ def __call__(self, attrs):
]
if None not in checked_values and queryset.exists():
field_names = ', '.join(self.fields)
raise ValidationError(
self.message.format(field_names=field_names),
code='unique')
message = self.message.format(field_names=field_names)
code = 'unique'
raise ValidationError(message, code=code)

def __repr__(self):
return unicode_to_repr('<%s(queryset=%s, fields=%s)>' % (
Expand Down