mirror of
				https://github.com/encode/django-rest-framework.git
				synced 2025-11-04 01:47:59 +03:00 
			
		
		
		
	Merge pull request #1561 from incuna/i18n
Mark strings in AuthTokenSerializer as translatable
This commit is contained in:
		
						commit
						0097fbc861
					
				| 
						 | 
					@ -1,4 +1,6 @@
 | 
				
			||||||
from django.contrib.auth import authenticate
 | 
					from django.contrib.auth import authenticate
 | 
				
			||||||
 | 
					from django.utils.translation import ugettext_lazy as _
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from rest_framework import serializers
 | 
					from rest_framework import serializers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,10 +17,13 @@ class AuthTokenSerializer(serializers.Serializer):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if user:
 | 
					            if user:
 | 
				
			||||||
                if not user.is_active:
 | 
					                if not user.is_active:
 | 
				
			||||||
                    raise serializers.ValidationError('User account is disabled.')
 | 
					                    msg = _('User account is disabled.')
 | 
				
			||||||
 | 
					                    raise serializers.ValidationError(msg)
 | 
				
			||||||
                attrs['user'] = user
 | 
					                attrs['user'] = user
 | 
				
			||||||
                return attrs
 | 
					                return attrs
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                raise serializers.ValidationError('Unable to login with provided credentials.')
 | 
					                msg = _('Unable to login with provided credentials.')
 | 
				
			||||||
 | 
					                raise serializers.ValidationError(msg)
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            raise serializers.ValidationError('Must include "username" and "password"')
 | 
					            msg = _('Must include "username" and "password"')
 | 
				
			||||||
 | 
					            raise serializers.ValidationError(msg)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user