Skip to content

Commit

Permalink
Merge pull request #3887 from mnach/enhancement-3886
Browse files Browse the repository at this point in the history
enhancement #3886 Internationalization in admin interface for authtoken
  • Loading branch information
xordoquy committed Feb 1, 2016
2 parents d738ad7 + d0f7b04 commit dce544e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions rest_framework/authtoken/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default_app_config = 'rest_framework.authtoken.apps.AuthTokenConfig'
7 changes: 7 additions & 0 deletions rest_framework/authtoken/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _


class AuthTokenConfig(AppConfig):
name = 'rest_framework.authtoken'
verbose_name = _("Auth Token")
9 changes: 6 additions & 3 deletions rest_framework/authtoken/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.conf import settings
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _

# Prior to Django 1.5, the AUTH_USER_MODEL setting does not exist.
# Note that we don't perform this code in the compat module due to
Expand All @@ -17,10 +18,10 @@ class Token(models.Model):
"""
The default authorization token model.
"""
key = models.CharField(max_length=40, primary_key=True)
key = models.CharField(_("Key"), max_length=40, primary_key=True)
user = models.OneToOneField(AUTH_USER_MODEL, related_name='auth_token',
on_delete=models.CASCADE)
created = models.DateTimeField(auto_now_add=True)
on_delete=models.CASCADE, verbose_name=_("User"))
created = models.DateTimeField(_("Created"), auto_now_add=True)

class Meta:
# Work around for a bug in Django:
Expand All @@ -29,6 +30,8 @@ class Meta:
# Also see corresponding ticket:
# https://github.com/tomchristie/django-rest-framework/issues/705
abstract = 'rest_framework.authtoken' not in settings.INSTALLED_APPS
verbose_name = _("Token")
verbose_name_plural = _("Tokens")

def save(self, *args, **kwargs):
if not self.key:
Expand Down
4 changes: 2 additions & 2 deletions rest_framework/authtoken/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@


class AuthTokenSerializer(serializers.Serializer):
username = serializers.CharField()
password = serializers.CharField(style={'input_type': 'password'})
username = serializers.CharField(label=_("Username"))
password = serializers.CharField(label=_("Password"), style={'input_type': 'password'})

def validate(self, attrs):
username = attrs.get('username')
Expand Down

0 comments on commit dce544e

Please sign in to comment.