From bf82a28dc12723974af2e4420b7d2aff34df2a10 Mon Sep 17 00:00:00 2001 From: ibuler Date: Fri, 18 Jun 2021 19:21:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=20i18n=20=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/forms.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/authentication/forms.py b/apps/authentication/forms.py index 447d842bd..a4b07700c 100644 --- a/apps/authentication/forms.py +++ b/apps/authentication/forms.py @@ -3,7 +3,7 @@ from django import forms from django.conf import settings -from django.utils.translation import gettext_lazy as _ +from django.utils.translation import ugettext_lazy as _ from captcha.fields import CaptchaField, CaptchaTextInput @@ -23,12 +23,17 @@ class UserLoginForm(forms.Form): max_length=1024, strip=False ) auto_login = forms.BooleanField( - label=_("{} days auto login").format(days_auto_login or 1), - required=False, initial=False, widget=forms.CheckboxInput( + required=False, initial=False, + widget=forms.CheckboxInput( attrs={'disabled': disable_days_auto_login} ) ) + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + auto_login_field = self.fields['auto_login'] + auto_login_field.label = _("{} days auto login").format(self.days_auto_login or 1) + def confirm_login_allowed(self, user): if not user.is_staff: raise forms.ValidationError(