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
14e34dcf
Kaydet (Commit)
14e34dcf
authored
Şub 17, 2018
tarafından
Mikhail Porokhovnichenko
Kaydeden (comit)
Tim Graham
Şub 21, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #29132 -- Avoided connecting update_last_login() handler if User.last_login isn't a field.
üst
5c4c87e5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
3 deletions
+18
-3
apps.py
django/contrib/auth/apps.py
+4
-1
__init__.py
tests/auth_tests/models/__init__.py
+2
-1
with_last_login_attr.py
tests/auth_tests/models/with_last_login_attr.py
+5
-0
test_signals.py
tests/auth_tests/test_signals.py
+7
-1
No files found.
django/contrib/auth/apps.py
Dosyayı görüntüle @
14e34dcf
from
django.apps
import
AppConfig
from
django.core
import
checks
from
django.db.models.query_utils
import
DeferredAttribute
from
django.db.models.signals
import
post_migrate
from
django.utils.translation
import
gettext_lazy
as
_
...
...
@@ -18,7 +19,9 @@ class AuthConfig(AppConfig):
create_permissions
,
dispatch_uid
=
"django.contrib.auth.management.create_permissions"
)
if
hasattr
(
get_user_model
(),
'last_login'
):
last_login_field
=
getattr
(
get_user_model
(),
'last_login'
,
None
)
# Register the handler only if UserModel.last_login is a field.
if
isinstance
(
last_login_field
,
DeferredAttribute
):
from
.models
import
update_last_login
user_logged_in
.
connect
(
update_last_login
,
dispatch_uid
=
'update_last_login'
)
checks
.
register
(
check_user_model
,
checks
.
Tags
.
models
)
...
...
tests/auth_tests/models/__init__.py
Dosyayı görüntüle @
14e34dcf
...
...
@@ -8,10 +8,11 @@ from .minimal import MinimalUser
from
.uuid_pk
import
UUIDUser
from
.with_foreign_key
import
CustomUserWithFK
,
Email
from
.with_integer_username
import
IntegerUsernameUser
from
.with_last_login_attr
import
UserWithDisabledLastLoginField
__all__
=
(
'CustomUser'
,
'CustomUserWithoutIsActiveField'
,
'CustomPermissionsUser'
,
'CustomUserWithFK'
,
'Email'
,
'ExtensionUser'
,
'IsActiveTestUser1'
,
'MinimalUser'
,
'UUIDUser'
,
'CustomUserNonUniqueUsername'
,
'IntegerUsernameUser'
,
'IntegerUsernameUser'
,
'UserWithDisabledLastLoginField'
,
)
tests/auth_tests/models/with_last_login_attr.py
0 → 100644
Dosyayı görüntüle @
14e34dcf
from
django.contrib.auth.base_user
import
AbstractBaseUser
class
UserWithDisabledLastLoginField
(
AbstractBaseUser
):
last_login
=
None
tests/auth_tests/test_signals.py
Dosyayı görüntüle @
14e34dcf
...
...
@@ -5,7 +5,7 @@ from django.core.exceptions import FieldDoesNotExist
from
django.test
import
TestCase
,
override_settings
from
django.test.client
import
RequestFactory
from
.models
import
MinimalUser
from
.models
import
MinimalUser
,
UserWithDisabledLastLoginField
@override_settings
(
ROOT_URLCONF
=
'auth_tests.urls'
)
...
...
@@ -101,6 +101,12 @@ class SignalTestCase(TestCase):
apps
.
get_app_config
(
'auth'
)
.
ready
()
self
.
assertEqual
(
signals
.
user_logged_in
.
receivers
,
[])
# last_login is a property whose value is None.
self
.
assertIsNone
(
UserWithDisabledLastLoginField
()
.
last_login
)
with
self
.
settings
(
AUTH_USER_MODEL
=
'auth_tests.UserWithDisabledLastLoginField'
):
apps
.
get_app_config
(
'auth'
)
.
ready
()
self
.
assertEqual
(
signals
.
user_logged_in
.
receivers
,
[])
with
self
.
settings
(
AUTH_USER_MODEL
=
'auth.User'
):
apps
.
get_app_config
(
'auth'
)
.
ready
()
self
.
assertEqual
(
len
(
signals
.
user_logged_in
.
receivers
),
1
)
...
...
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