review cleanup

This commit is contained in:
Jonathan Liuti 2015-12-18 14:15:34 +01:00
parent 24ba3b3743
commit ba21a1e551
3 changed files with 10 additions and 15 deletions

View File

@ -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

View File

@ -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

View File

@ -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)>' % (