Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
0732c8e8
Kaydet (Commit)
0732c8e8
authored
May 06, 2013
tarafından
Mark Huang
Kaydeden (comit)
Simon Charette
May 16, 2013
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #20357 -- Allow empty username field label in `AuthentificationForm`.
üst
289afc31
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
forms.py
django/contrib/auth/forms.py
+1
-1
test_forms.py
django/contrib/auth/tests/test_forms.py
+21
-0
No files found.
django/contrib/auth/forms.py
Dosyayı görüntüle @
0732c8e8
...
...
@@ -171,7 +171,7 @@ class AuthenticationForm(forms.Form):
# Set the label for the "username" field.
UserModel
=
get_user_model
()
self
.
username_field
=
UserModel
.
_meta
.
get_field
(
UserModel
.
USERNAME_FIELD
)
if
not
self
.
fields
[
'username'
]
.
label
:
if
self
.
fields
[
'username'
]
.
label
is
None
:
self
.
fields
[
'username'
]
.
label
=
capfirst
(
self
.
username_field
.
verbose_name
)
def
clean
(
self
):
...
...
django/contrib/auth/tests/test_forms.py
Dosyayı görüntüle @
0732c8e8
from
__future__
import
unicode_literals
import
os
from
django.contrib.auth
import
get_user_model
from
django.contrib.auth.models
import
User
from
django.contrib.auth.forms
import
(
UserCreationForm
,
AuthenticationForm
,
PasswordChangeForm
,
SetPasswordForm
,
UserChangeForm
,
PasswordResetForm
,
...
...
@@ -13,6 +15,7 @@ from django.test.utils import override_settings
from
django.utils.encoding
import
force_text
from
django.utils._os
import
upath
from
django.utils
import
translation
from
django.utils.text
import
capfirst
from
django.utils.translation
import
ugettext
as
_
...
...
@@ -146,6 +149,24 @@ class AuthenticationFormTest(TestCase):
form
=
CustomAuthenticationForm
()
self
.
assertEqual
(
form
[
'username'
]
.
label
,
"Name"
)
def
test_username_field_label_not_set
(
self
):
class
CustomAuthenticationForm
(
AuthenticationForm
):
username
=
CharField
()
form
=
CustomAuthenticationForm
()
UserModel
=
get_user_model
()
username_field
=
UserModel
.
_meta
.
get_field
(
UserModel
.
USERNAME_FIELD
)
self
.
assertEqual
(
form
.
fields
[
'username'
]
.
label
,
capfirst
(
username_field
.
verbose_name
))
def
test_username_field_label_empty_string
(
self
):
class
CustomAuthenticationForm
(
AuthenticationForm
):
username
=
CharField
(
label
=
''
)
form
=
CustomAuthenticationForm
()
self
.
assertEqual
(
form
.
fields
[
'username'
]
.
label
,
""
)
@skipIfCustomUser
@override_settings
(
USE_TZ
=
False
,
PASSWORD_HASHERS
=
(
'django.contrib.auth.hashers.SHA1PasswordHasher'
,))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment