From f85e5b6f7549f3a1f82be1a75885b7e450dea14a Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 27 Mar 2018 17:47:53 +0800 Subject: [PATCH] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E6=94=B9=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/users/forms.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/users/forms.py b/apps/users/forms.py index 8d223b627..f7c8be563 100644 --- a/apps/users/forms.py +++ b/apps/users/forms.py @@ -27,7 +27,7 @@ class UserCreateUpdateForm(forms.ModelForm): ) role = forms.ChoiceField(choices=role_choices, required=True, initial=User.ROLE_USER, label=_("Role")) public_key = forms.CharField( - label=_('ssh public key'), max_length=5000, + label=_('ssh public key'), max_length=5000, required=False, widget=forms.Textarea(attrs={'placeholder': _('ssh-rsa AAAA...')}), help_text=_('Paste user id_rsa.pub here.') ) @@ -54,6 +54,8 @@ class UserCreateUpdateForm(forms.ModelForm): def clean_public_key(self): public_key = self.cleaned_data['public_key'] + if not public_key: + return public_key if self.instance.public_key and public_key == self.instance.public_key: msg = _('Public key should not be the same as your old one.') raise forms.ValidationError(msg)