Mark strings in AuthTokenSerializer as translatable

This commit is contained in:
Charlie Denton 2014-05-01 10:18:16 +01:00
parent 5333a93126
commit c15dab903d

View File

@ -1,4 +1,6 @@
from django.contrib.auth import authenticate
from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers
@ -15,10 +17,13 @@ class AuthTokenSerializer(serializers.Serializer):
if user:
if not user.is_active:
raise serializers.ValidationError('User account is disabled.')
msg = _('User account is disabled.')
raise serializers.ValidationError()
attrs['user'] = user
return attrs
else:
raise serializers.ValidationError('Unable to login with provided credentials.')
msg = _('Unable to login with provided credentials.')
raise serializers.ValidationError(msg)
else:
raise serializers.ValidationError('Must include "username" and "password"')
msg = _('Must include "username" and "password"')
raise serializers.ValidationError(msg)