2013-02-23 22:20:34 +00:00
|
|
|
from django.contrib import admin
|
2015-02-23 00:53:57 +00:00
|
|
|
from django.contrib.auth.models import User as AuthUser
|
2011-10-13 18:04:12 +00:00
|
|
|
from django.contrib.contenttypes.models import ContentType
|
2015-10-01 18:57:58 +00:00
|
|
|
from django.core import checks, management
|
2015-01-28 12:35:27 +00:00
|
|
|
from django.db import DEFAULT_DB_ALIAS, models
|
2011-10-13 18:04:12 +00:00
|
|
|
from django.db.models import signals
|
2013-12-23 15:01:13 +00:00
|
|
|
from django.test import TestCase, override_settings
|
2015-11-17 05:39:28 +00:00
|
|
|
from django.test.utils import isolate_apps
|
2015-12-30 15:51:16 +00:00
|
|
|
from django.urls import reverse
|
2010-09-13 05:29:21 +00:00
|
|
|
|
2013-10-18 11:25:30 +00:00
|
|
|
from .admin import admin as force_admin_model_registration # NOQA
|
2015-01-28 12:35:27 +00:00
|
|
|
from .models import (
|
|
|
|
Abstract,
|
|
|
|
BaseUser,
|
|
|
|
Bug,
|
|
|
|
Country,
|
|
|
|
Improvement,
|
|
|
|
Issue,
|
|
|
|
LowerStatusPerson,
|
2016-03-27 19:20:54 +00:00
|
|
|
MultiUserProxy,
|
|
|
|
MyPerson,
|
|
|
|
MyPersonProxy,
|
|
|
|
OtherPerson,
|
|
|
|
Person,
|
|
|
|
ProxyBug,
|
|
|
|
ProxyImprovement,
|
|
|
|
ProxyProxyBug,
|
|
|
|
ProxyTrackerUser,
|
|
|
|
State,
|
|
|
|
StateProxy,
|
|
|
|
StatusPerson,
|
|
|
|
TrackerUser,
|
|
|
|
User,
|
|
|
|
UserProxy,
|
|
|
|
UserProxyProxy,
|
2015-01-28 12:35:27 +00:00
|
|
|
)
|
2010-09-13 05:29:21 +00:00
|
|
|
|
Fixed #3011 -- Added swappable auth.User models.
Thanks to the many people that contributed to the development and review of
this patch, including (but not limited to) Jacob Kaplan-Moss, Anssi
Kääriäinen, Ramiro Morales, Preston Holmes, Josh Ourisman, Thomas Sutton,
and Roger Barnes, as well as the many, many people who have contributed to
the design discussion around this ticket over many years.
Squashed commit of the following:
commit d84749a0f034a0a6906d20df047086b1219040d0
Merge: 531e771 7c11b1a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Wed Sep 26 18:37:04 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 531e7715da545f930c49919a19e954d41c59b446
Merge: 29d1abb 1f84b04
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Wed Sep 26 07:09:23 2012 +0800
Merged recent trunk changes.
commit 29d1abbe351fd5da855fe5ce09e24227d90ddc91
Merge: 8a527dd 54c81a1
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 24 07:49:46 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 8a527dda13c9bec955b1f7e8db5822d1d9b32a01
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 24 07:48:05 2012 +0800
Ensure sequences are reset correctly in the presence of swapped models.
commit e2b6e22f298eb986d74d28b8d9906f37f5ff8eb8
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 23 17:53:05 2012 +0800
Modifications to the handling and docs for auth forms.
commit 98aba856b534620aea9091f824b442b47d2fdb3c
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 23 15:28:57 2012 +0800
Improved error handling and docs for get_user_model()
commit 0229209c844f06dfeb33b0b8eeec000c127695b6
Merge: 6494bf9 8599f64
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 23 14:50:11 2012 +0800
Merged recent Django trunk changes.
commit 6494bf91f2ddaaabec3ec017f2e3131937c35517
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 17 21:38:44 2012 +0800
Improved validation of swappable model settings.
commit 5a04cde342cc860384eb844cfda5af55204564ad
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 17 07:15:14 2012 +0800
Removed some unused imports.
commit ffd535e4136dc54f084b6ac467e81444696e1c8a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 20:31:28 2012 +0800
Corrected attribute access on for get_by_natural_key
commit 913e1ac84c3d9c7c58a9b3bdbbb15ebccd8a8c0a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 20:12:34 2012 +0800
Added test for proxy model safeguards on swappable models.
commit 280bf19e94d0d534d0e51bae485c1842558f4ff4
Merge: dbb3900 935a863
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 18:16:49 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit dbb3900775a99df8b6cb1d7063cf364eab55621a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 18:09:27 2012 +0800
Fixes for Python 3 compatibility.
commit dfd72131d8664615e245aa0f95b82604ba6b3821
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 15:54:30 2012 +0800
Added protection against proxying swapped models.
commit abcb027190e53613e7f1734e77ee185b2587de31
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 15:11:10 2012 +0800
Cleanup and documentation of AbstractUser base class.
commit a9491a87763e307f0eb0dc246f54ac865a6ffb34
Merge: fd8bb4e 08bcb4a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 14:46:49 2012 +0800
Merge commit '08bcb4aec1ed154cefc631b8510ee13e9af0c19d' into t3011
commit fd8bb4e3e498a92d7a8b340f0684d5f088aa4c92
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 14:20:14 2012 +0800
Documentation improvements coming from community review.
commit b550a6d06d016ab6a0198c4cb2dffe9cceabe8a5
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 13:52:47 2012 +0800
Refactored skipIfCustomUser into the contrib.auth tests.
commit 52a02f11107c3f0d711742b8ca65b75175b79d6a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 13:46:10 2012 +0800
Refactored common 'get' pattern into manager method.
commit b441a6bbc7d6065175715cb09316b9f13268171b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 13:41:33 2012 +0800
Added note about backwards incompatible change to admin login messages.
commit 08bcb4aec1ed154cefc631b8510ee13e9af0c19d
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date: Sat Sep 15 18:30:33 2012 +0300
Splitted User to AbstractUser and User
commit d9f5e5addbad5e1a01f67e7358e4f5091c3cad81
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date: Sat Sep 15 18:30:02 2012 +0300
Reworked REQUIRED_FIELDS + create_user() interaction
commit 579f152e4a6e06671e1ac1e59e2b43cf4d764bf4
Merge: 9184972 93e6733
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 20:18:37 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 918497218c58227f5032873ff97261627b2ceab2
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 20:18:19 2012 +0800
Deprecate AUTH_PROFILE_MODULE and get_profile().
commit 334cdfc1bb6a6794791497cdefda843bca2ea57a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 20:00:12 2012 +0800
Added release notes for new swappable User feature.
commit 5d7bb22e8d913b51aba1c3360e7af8b01b6c0ab6
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 19:59:49 2012 +0800
Ensure swapped models can't be queried.
commit 57ac6e3d32605a67581e875b37ec5b2284711a32
Merge: f2ec915 abfba3b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 14:31:54 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit f2ec915b20f81c8afeaa3df25f80689712f720f8
Merge: 1952656 5e99a3d
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 08:29:51 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 19526563b54fa300785c49cfb625c0c6158ced67
Merge: 2c5e833 c4aa26a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 08:22:26 2012 +0800
Merge recent changes from master.
commit 2c5e833a30bef4305d55eacc0703533152f5c427
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 07:53:46 2012 +0800
Corrected admin_views tests following removal of the email fallback on admin logins.
commit 20d1892491839d6ef21f37db4ca136935c2076bf
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 01:00:37 2012 +0800
Added conditional skips for all tests dependent on the default User model
commit 40ea8b888284775481fc1eaadeff267dbd7e3dfa
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 8 23:47:02 2012 +0800
Added documentation for REQUIRED_FIELDS in custom auth.
commit e6aaf659708cf6491f5485d3edfa616cb9214cc0
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 8 23:20:02 2012 +0800
Added first draft of custom User docs.
Thanks to Greg Turner for the initial text.
commit 75118bd242eec87649da2859e8c50a199a8a1dca
Author: Thomas Sutton <me@thomas-sutton.id.au>
Date: Mon Aug 20 11:17:26 2012 +0800
Admin app should not allow username discovery
The admin app login form should not allow users to discover the username
associated with an email address.
commit d088b3af58dad7449fc58493193a327725c57c22
Author: Thomas Sutton <me@thomas-sutton.id.au>
Date: Mon Aug 20 10:32:13 2012 +0800
Admin app login form should use swapped user model
commit 7e82e83d67ee0871a72e1a3a723afdd214fcefc3
Merge: e29c010 39aa890
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Fri Sep 7 23:45:03 2012 +0800
Merged master changes.
commit e29c010beb96ca07697c4e3e0c0d5d3ffdc4c0a3
Merge: 8e3fd70 30bdf22
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Aug 20 13:12:57 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 8e3fd703d02c31a4c3ac9f51f5011d03c0bd47f6
Merge: 507bb50 26e0ba0
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Aug 20 13:09:09 2012 +0800
Merged recent changes from trunk.
commit 507bb50a9291bfcdcfa1198f9fea21d4e3b1e762
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Jun 4 20:41:37 2012 +0800
Modified auth app so that login with alternate auth app is possible.
commit dabe3628362ab7a4a6c9686dd874803baa997eaa
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Jun 4 20:10:51 2012 +0800
Modified auth management commands to handle custom user definitions.
commit 7cc0baf89d490c92ef3f1dc909b8090191a1294b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Jun 4 14:17:28 2012 +0800
Added model Meta option for swappable models, and made auth.User a swappable model
2012-09-26 10:48:09 +00:00
|
|
|
|
2010-09-13 05:29:21 +00:00
|
|
|
class ProxyModelTests(TestCase):
|
|
|
|
def test_same_manager_queries(self):
|
|
|
|
"""
|
|
|
|
The MyPerson model should be generating the same database queries as
|
|
|
|
the Person model (when the same manager is used in each case).
|
|
|
|
"""
|
|
|
|
my_person_sql = (
|
|
|
|
MyPerson.other.all().query.get_compiler(DEFAULT_DB_ALIAS).as_sql()
|
|
|
|
)
|
|
|
|
person_sql = (
|
|
|
|
Person.objects.order_by("name")
|
|
|
|
.query.get_compiler(DEFAULT_DB_ALIAS)
|
|
|
|
.as_sql()
|
2022-02-03 19:24:19 +00:00
|
|
|
)
|
2010-09-13 05:29:21 +00:00
|
|
|
self.assertEqual(my_person_sql, person_sql)
|
|
|
|
|
2015-12-02 23:55:50 +00:00
|
|
|
def test_inheritance_new_table(self):
|
2010-09-13 05:29:21 +00:00
|
|
|
"""
|
|
|
|
The StatusPerson models should have its own table (it's using ORM-level
|
|
|
|
inheritance).
|
|
|
|
"""
|
|
|
|
sp_sql = (
|
|
|
|
StatusPerson.objects.all().query.get_compiler(DEFAULT_DB_ALIAS).as_sql()
|
|
|
|
)
|
|
|
|
p_sql = Person.objects.all().query.get_compiler(DEFAULT_DB_ALIAS).as_sql()
|
|
|
|
self.assertNotEqual(sp_sql, p_sql)
|
|
|
|
|
|
|
|
def test_basic_proxy(self):
|
|
|
|
"""
|
|
|
|
Creating a Person makes them accessible through the MyPerson proxy.
|
|
|
|
"""
|
2011-03-09 23:46:28 +00:00
|
|
|
person = Person.objects.create(name="Foo McBar")
|
2010-09-13 05:29:21 +00:00
|
|
|
self.assertEqual(len(Person.objects.all()), 1)
|
|
|
|
self.assertEqual(len(MyPerson.objects.all()), 1)
|
2011-03-09 23:46:28 +00:00
|
|
|
self.assertEqual(MyPerson.objects.get(name="Foo McBar").id, person.id)
|
|
|
|
self.assertFalse(MyPerson.objects.get(id=person.id).has_special_name())
|
2010-09-13 05:29:21 +00:00
|
|
|
|
|
|
|
def test_no_proxy(self):
|
|
|
|
"""
|
|
|
|
Person is not proxied by StatusPerson subclass.
|
|
|
|
"""
|
|
|
|
Person.objects.create(name="Foo McBar")
|
|
|
|
self.assertEqual(list(StatusPerson.objects.all()), [])
|
|
|
|
|
|
|
|
def test_basic_proxy_reverse(self):
|
|
|
|
"""
|
|
|
|
A new MyPerson also shows up as a standard Person.
|
|
|
|
"""
|
|
|
|
MyPerson.objects.create(name="Bazza del Frob")
|
|
|
|
self.assertEqual(len(MyPerson.objects.all()), 1)
|
|
|
|
self.assertEqual(len(Person.objects.all()), 1)
|
|
|
|
|
|
|
|
LowerStatusPerson.objects.create(status="low", name="homer")
|
|
|
|
lsps = [lsp.name for lsp in LowerStatusPerson.objects.all()]
|
|
|
|
self.assertEqual(lsps, ["homer"])
|
|
|
|
|
|
|
|
def test_correct_type_proxy_of_proxy(self):
|
|
|
|
"""
|
|
|
|
Correct type when querying a proxy of proxy
|
|
|
|
"""
|
|
|
|
Person.objects.create(name="Foo McBar")
|
|
|
|
MyPerson.objects.create(name="Bazza del Frob")
|
|
|
|
LowerStatusPerson.objects.create(status="low", name="homer")
|
2013-08-29 23:20:00 +00:00
|
|
|
pp = sorted(mpp.name for mpp in MyPersonProxy.objects.all())
|
2010-09-13 05:29:21 +00:00
|
|
|
self.assertEqual(pp, ["Bazza del Frob", "Foo McBar", "homer"])
|
|
|
|
|
|
|
|
def test_proxy_included_in_ancestors(self):
|
|
|
|
"""
|
|
|
|
Proxy models are included in the ancestors for a model's DoesNotExist
|
|
|
|
and MultipleObjectsReturned
|
|
|
|
"""
|
|
|
|
Person.objects.create(name="Foo McBar")
|
|
|
|
MyPerson.objects.create(name="Bazza del Frob")
|
|
|
|
LowerStatusPerson.objects.create(status="low", name="homer")
|
|
|
|
max_id = Person.objects.aggregate(max_id=models.Max("id"))["max_id"]
|
|
|
|
|
2016-01-17 11:26:39 +00:00
|
|
|
with self.assertRaises(Person.DoesNotExist):
|
|
|
|
MyPersonProxy.objects.get(name="Zathras")
|
|
|
|
with self.assertRaises(Person.MultipleObjectsReturned):
|
|
|
|
MyPersonProxy.objects.get(id__lt=max_id + 1)
|
|
|
|
with self.assertRaises(Person.DoesNotExist):
|
|
|
|
StatusPerson.objects.get(name="Zathras")
|
2010-09-13 05:29:21 +00:00
|
|
|
|
2013-10-19 12:31:38 +00:00
|
|
|
StatusPerson.objects.create(name="Bazza Jr.")
|
|
|
|
StatusPerson.objects.create(name="Foo Jr.")
|
2010-09-13 05:29:21 +00:00
|
|
|
max_id = Person.objects.aggregate(max_id=models.Max("id"))["max_id"]
|
|
|
|
|
2016-01-17 11:26:39 +00:00
|
|
|
with self.assertRaises(Person.MultipleObjectsReturned):
|
|
|
|
StatusPerson.objects.get(id__lt=max_id + 1)
|
2010-09-13 05:29:21 +00:00
|
|
|
|
2016-03-30 16:01:33 +00:00
|
|
|
def test_abstract_base_with_model_fields(self):
|
|
|
|
msg = (
|
|
|
|
"Abstract base class containing model fields not permitted for proxy model "
|
|
|
|
"'NoAbstract'."
|
2022-02-04 07:08:27 +00:00
|
|
|
)
|
2016-03-30 16:01:33 +00:00
|
|
|
with self.assertRaisesMessage(TypeError, msg):
|
2022-02-03 19:24:19 +00:00
|
|
|
|
2010-09-13 05:29:21 +00:00
|
|
|
class NoAbstract(Abstract):
|
|
|
|
class Meta:
|
|
|
|
proxy = True
|
|
|
|
|
2016-03-30 16:01:33 +00:00
|
|
|
def test_too_many_concrete_classes(self):
|
|
|
|
msg = (
|
|
|
|
"Proxy model 'TooManyBases' has more than one non-abstract model base "
|
|
|
|
"class."
|
2022-02-04 07:08:27 +00:00
|
|
|
)
|
2016-03-30 16:01:33 +00:00
|
|
|
with self.assertRaisesMessage(TypeError, msg):
|
2022-02-03 19:24:19 +00:00
|
|
|
|
2016-03-30 16:01:33 +00:00
|
|
|
class TooManyBases(User, Person):
|
2010-09-13 05:29:21 +00:00
|
|
|
class Meta:
|
|
|
|
proxy = True
|
|
|
|
|
|
|
|
def test_no_base_classes(self):
|
2016-03-30 16:01:33 +00:00
|
|
|
msg = "Proxy model 'NoBaseClasses' has no non-abstract model base class."
|
|
|
|
with self.assertRaisesMessage(TypeError, msg):
|
2022-02-03 19:24:19 +00:00
|
|
|
|
2010-09-13 05:29:21 +00:00
|
|
|
class NoBaseClasses(models.Model):
|
|
|
|
class Meta:
|
|
|
|
proxy = True
|
|
|
|
|
2015-11-17 05:39:28 +00:00
|
|
|
@isolate_apps("proxy_models")
|
2010-09-13 05:29:21 +00:00
|
|
|
def test_new_fields(self):
|
2014-05-28 22:26:57 +00:00
|
|
|
class NoNewFields(Person):
|
|
|
|
newfield = models.BooleanField()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
proxy = True
|
|
|
|
|
|
|
|
errors = NoNewFields.check()
|
|
|
|
expected = [
|
|
|
|
checks.Error(
|
|
|
|
"Proxy model 'NoNewFields' contains model fields.",
|
|
|
|
id="models.E017",
|
|
|
|
)
|
|
|
|
]
|
|
|
|
self.assertEqual(errors, expected)
|
2010-09-13 05:29:21 +00:00
|
|
|
|
2013-10-14 13:14:17 +00:00
|
|
|
@override_settings(TEST_SWAPPABLE_MODEL="proxy_models.AlternateModel")
|
2015-11-17 05:39:28 +00:00
|
|
|
@isolate_apps("proxy_models")
|
Fixed #3011 -- Added swappable auth.User models.
Thanks to the many people that contributed to the development and review of
this patch, including (but not limited to) Jacob Kaplan-Moss, Anssi
Kääriäinen, Ramiro Morales, Preston Holmes, Josh Ourisman, Thomas Sutton,
and Roger Barnes, as well as the many, many people who have contributed to
the design discussion around this ticket over many years.
Squashed commit of the following:
commit d84749a0f034a0a6906d20df047086b1219040d0
Merge: 531e771 7c11b1a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Wed Sep 26 18:37:04 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 531e7715da545f930c49919a19e954d41c59b446
Merge: 29d1abb 1f84b04
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Wed Sep 26 07:09:23 2012 +0800
Merged recent trunk changes.
commit 29d1abbe351fd5da855fe5ce09e24227d90ddc91
Merge: 8a527dd 54c81a1
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 24 07:49:46 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 8a527dda13c9bec955b1f7e8db5822d1d9b32a01
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 24 07:48:05 2012 +0800
Ensure sequences are reset correctly in the presence of swapped models.
commit e2b6e22f298eb986d74d28b8d9906f37f5ff8eb8
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 23 17:53:05 2012 +0800
Modifications to the handling and docs for auth forms.
commit 98aba856b534620aea9091f824b442b47d2fdb3c
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 23 15:28:57 2012 +0800
Improved error handling and docs for get_user_model()
commit 0229209c844f06dfeb33b0b8eeec000c127695b6
Merge: 6494bf9 8599f64
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 23 14:50:11 2012 +0800
Merged recent Django trunk changes.
commit 6494bf91f2ddaaabec3ec017f2e3131937c35517
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 17 21:38:44 2012 +0800
Improved validation of swappable model settings.
commit 5a04cde342cc860384eb844cfda5af55204564ad
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 17 07:15:14 2012 +0800
Removed some unused imports.
commit ffd535e4136dc54f084b6ac467e81444696e1c8a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 20:31:28 2012 +0800
Corrected attribute access on for get_by_natural_key
commit 913e1ac84c3d9c7c58a9b3bdbbb15ebccd8a8c0a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 20:12:34 2012 +0800
Added test for proxy model safeguards on swappable models.
commit 280bf19e94d0d534d0e51bae485c1842558f4ff4
Merge: dbb3900 935a863
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 18:16:49 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit dbb3900775a99df8b6cb1d7063cf364eab55621a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 18:09:27 2012 +0800
Fixes for Python 3 compatibility.
commit dfd72131d8664615e245aa0f95b82604ba6b3821
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 15:54:30 2012 +0800
Added protection against proxying swapped models.
commit abcb027190e53613e7f1734e77ee185b2587de31
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 15:11:10 2012 +0800
Cleanup and documentation of AbstractUser base class.
commit a9491a87763e307f0eb0dc246f54ac865a6ffb34
Merge: fd8bb4e 08bcb4a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 14:46:49 2012 +0800
Merge commit '08bcb4aec1ed154cefc631b8510ee13e9af0c19d' into t3011
commit fd8bb4e3e498a92d7a8b340f0684d5f088aa4c92
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 14:20:14 2012 +0800
Documentation improvements coming from community review.
commit b550a6d06d016ab6a0198c4cb2dffe9cceabe8a5
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 13:52:47 2012 +0800
Refactored skipIfCustomUser into the contrib.auth tests.
commit 52a02f11107c3f0d711742b8ca65b75175b79d6a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 13:46:10 2012 +0800
Refactored common 'get' pattern into manager method.
commit b441a6bbc7d6065175715cb09316b9f13268171b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 13:41:33 2012 +0800
Added note about backwards incompatible change to admin login messages.
commit 08bcb4aec1ed154cefc631b8510ee13e9af0c19d
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date: Sat Sep 15 18:30:33 2012 +0300
Splitted User to AbstractUser and User
commit d9f5e5addbad5e1a01f67e7358e4f5091c3cad81
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date: Sat Sep 15 18:30:02 2012 +0300
Reworked REQUIRED_FIELDS + create_user() interaction
commit 579f152e4a6e06671e1ac1e59e2b43cf4d764bf4
Merge: 9184972 93e6733
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 20:18:37 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 918497218c58227f5032873ff97261627b2ceab2
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 20:18:19 2012 +0800
Deprecate AUTH_PROFILE_MODULE and get_profile().
commit 334cdfc1bb6a6794791497cdefda843bca2ea57a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 20:00:12 2012 +0800
Added release notes for new swappable User feature.
commit 5d7bb22e8d913b51aba1c3360e7af8b01b6c0ab6
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 19:59:49 2012 +0800
Ensure swapped models can't be queried.
commit 57ac6e3d32605a67581e875b37ec5b2284711a32
Merge: f2ec915 abfba3b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 14:31:54 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit f2ec915b20f81c8afeaa3df25f80689712f720f8
Merge: 1952656 5e99a3d
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 08:29:51 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 19526563b54fa300785c49cfb625c0c6158ced67
Merge: 2c5e833 c4aa26a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 08:22:26 2012 +0800
Merge recent changes from master.
commit 2c5e833a30bef4305d55eacc0703533152f5c427
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 07:53:46 2012 +0800
Corrected admin_views tests following removal of the email fallback on admin logins.
commit 20d1892491839d6ef21f37db4ca136935c2076bf
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 01:00:37 2012 +0800
Added conditional skips for all tests dependent on the default User model
commit 40ea8b888284775481fc1eaadeff267dbd7e3dfa
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 8 23:47:02 2012 +0800
Added documentation for REQUIRED_FIELDS in custom auth.
commit e6aaf659708cf6491f5485d3edfa616cb9214cc0
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 8 23:20:02 2012 +0800
Added first draft of custom User docs.
Thanks to Greg Turner for the initial text.
commit 75118bd242eec87649da2859e8c50a199a8a1dca
Author: Thomas Sutton <me@thomas-sutton.id.au>
Date: Mon Aug 20 11:17:26 2012 +0800
Admin app should not allow username discovery
The admin app login form should not allow users to discover the username
associated with an email address.
commit d088b3af58dad7449fc58493193a327725c57c22
Author: Thomas Sutton <me@thomas-sutton.id.au>
Date: Mon Aug 20 10:32:13 2012 +0800
Admin app login form should use swapped user model
commit 7e82e83d67ee0871a72e1a3a723afdd214fcefc3
Merge: e29c010 39aa890
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Fri Sep 7 23:45:03 2012 +0800
Merged master changes.
commit e29c010beb96ca07697c4e3e0c0d5d3ffdc4c0a3
Merge: 8e3fd70 30bdf22
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Aug 20 13:12:57 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 8e3fd703d02c31a4c3ac9f51f5011d03c0bd47f6
Merge: 507bb50 26e0ba0
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Aug 20 13:09:09 2012 +0800
Merged recent changes from trunk.
commit 507bb50a9291bfcdcfa1198f9fea21d4e3b1e762
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Jun 4 20:41:37 2012 +0800
Modified auth app so that login with alternate auth app is possible.
commit dabe3628362ab7a4a6c9686dd874803baa997eaa
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Jun 4 20:10:51 2012 +0800
Modified auth management commands to handle custom user definitions.
commit 7cc0baf89d490c92ef3f1dc909b8090191a1294b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Jun 4 14:17:28 2012 +0800
Added model Meta option for swappable models, and made auth.User a swappable model
2012-09-26 10:48:09 +00:00
|
|
|
def test_swappable(self):
|
2015-11-17 05:39:28 +00:00
|
|
|
class SwappableModel(models.Model):
|
|
|
|
class Meta:
|
|
|
|
swappable = "TEST_SWAPPABLE_MODEL"
|
Fixed #3011 -- Added swappable auth.User models.
Thanks to the many people that contributed to the development and review of
this patch, including (but not limited to) Jacob Kaplan-Moss, Anssi
Kääriäinen, Ramiro Morales, Preston Holmes, Josh Ourisman, Thomas Sutton,
and Roger Barnes, as well as the many, many people who have contributed to
the design discussion around this ticket over many years.
Squashed commit of the following:
commit d84749a0f034a0a6906d20df047086b1219040d0
Merge: 531e771 7c11b1a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Wed Sep 26 18:37:04 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 531e7715da545f930c49919a19e954d41c59b446
Merge: 29d1abb 1f84b04
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Wed Sep 26 07:09:23 2012 +0800
Merged recent trunk changes.
commit 29d1abbe351fd5da855fe5ce09e24227d90ddc91
Merge: 8a527dd 54c81a1
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 24 07:49:46 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 8a527dda13c9bec955b1f7e8db5822d1d9b32a01
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 24 07:48:05 2012 +0800
Ensure sequences are reset correctly in the presence of swapped models.
commit e2b6e22f298eb986d74d28b8d9906f37f5ff8eb8
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 23 17:53:05 2012 +0800
Modifications to the handling and docs for auth forms.
commit 98aba856b534620aea9091f824b442b47d2fdb3c
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 23 15:28:57 2012 +0800
Improved error handling and docs for get_user_model()
commit 0229209c844f06dfeb33b0b8eeec000c127695b6
Merge: 6494bf9 8599f64
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 23 14:50:11 2012 +0800
Merged recent Django trunk changes.
commit 6494bf91f2ddaaabec3ec017f2e3131937c35517
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 17 21:38:44 2012 +0800
Improved validation of swappable model settings.
commit 5a04cde342cc860384eb844cfda5af55204564ad
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 17 07:15:14 2012 +0800
Removed some unused imports.
commit ffd535e4136dc54f084b6ac467e81444696e1c8a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 20:31:28 2012 +0800
Corrected attribute access on for get_by_natural_key
commit 913e1ac84c3d9c7c58a9b3bdbbb15ebccd8a8c0a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 20:12:34 2012 +0800
Added test for proxy model safeguards on swappable models.
commit 280bf19e94d0d534d0e51bae485c1842558f4ff4
Merge: dbb3900 935a863
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 18:16:49 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit dbb3900775a99df8b6cb1d7063cf364eab55621a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 18:09:27 2012 +0800
Fixes for Python 3 compatibility.
commit dfd72131d8664615e245aa0f95b82604ba6b3821
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 15:54:30 2012 +0800
Added protection against proxying swapped models.
commit abcb027190e53613e7f1734e77ee185b2587de31
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 15:11:10 2012 +0800
Cleanup and documentation of AbstractUser base class.
commit a9491a87763e307f0eb0dc246f54ac865a6ffb34
Merge: fd8bb4e 08bcb4a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 14:46:49 2012 +0800
Merge commit '08bcb4aec1ed154cefc631b8510ee13e9af0c19d' into t3011
commit fd8bb4e3e498a92d7a8b340f0684d5f088aa4c92
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 14:20:14 2012 +0800
Documentation improvements coming from community review.
commit b550a6d06d016ab6a0198c4cb2dffe9cceabe8a5
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 13:52:47 2012 +0800
Refactored skipIfCustomUser into the contrib.auth tests.
commit 52a02f11107c3f0d711742b8ca65b75175b79d6a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 13:46:10 2012 +0800
Refactored common 'get' pattern into manager method.
commit b441a6bbc7d6065175715cb09316b9f13268171b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 13:41:33 2012 +0800
Added note about backwards incompatible change to admin login messages.
commit 08bcb4aec1ed154cefc631b8510ee13e9af0c19d
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date: Sat Sep 15 18:30:33 2012 +0300
Splitted User to AbstractUser and User
commit d9f5e5addbad5e1a01f67e7358e4f5091c3cad81
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date: Sat Sep 15 18:30:02 2012 +0300
Reworked REQUIRED_FIELDS + create_user() interaction
commit 579f152e4a6e06671e1ac1e59e2b43cf4d764bf4
Merge: 9184972 93e6733
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 20:18:37 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 918497218c58227f5032873ff97261627b2ceab2
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 20:18:19 2012 +0800
Deprecate AUTH_PROFILE_MODULE and get_profile().
commit 334cdfc1bb6a6794791497cdefda843bca2ea57a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 20:00:12 2012 +0800
Added release notes for new swappable User feature.
commit 5d7bb22e8d913b51aba1c3360e7af8b01b6c0ab6
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 19:59:49 2012 +0800
Ensure swapped models can't be queried.
commit 57ac6e3d32605a67581e875b37ec5b2284711a32
Merge: f2ec915 abfba3b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 14:31:54 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit f2ec915b20f81c8afeaa3df25f80689712f720f8
Merge: 1952656 5e99a3d
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 08:29:51 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 19526563b54fa300785c49cfb625c0c6158ced67
Merge: 2c5e833 c4aa26a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 08:22:26 2012 +0800
Merge recent changes from master.
commit 2c5e833a30bef4305d55eacc0703533152f5c427
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 07:53:46 2012 +0800
Corrected admin_views tests following removal of the email fallback on admin logins.
commit 20d1892491839d6ef21f37db4ca136935c2076bf
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 01:00:37 2012 +0800
Added conditional skips for all tests dependent on the default User model
commit 40ea8b888284775481fc1eaadeff267dbd7e3dfa
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 8 23:47:02 2012 +0800
Added documentation for REQUIRED_FIELDS in custom auth.
commit e6aaf659708cf6491f5485d3edfa616cb9214cc0
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 8 23:20:02 2012 +0800
Added first draft of custom User docs.
Thanks to Greg Turner for the initial text.
commit 75118bd242eec87649da2859e8c50a199a8a1dca
Author: Thomas Sutton <me@thomas-sutton.id.au>
Date: Mon Aug 20 11:17:26 2012 +0800
Admin app should not allow username discovery
The admin app login form should not allow users to discover the username
associated with an email address.
commit d088b3af58dad7449fc58493193a327725c57c22
Author: Thomas Sutton <me@thomas-sutton.id.au>
Date: Mon Aug 20 10:32:13 2012 +0800
Admin app login form should use swapped user model
commit 7e82e83d67ee0871a72e1a3a723afdd214fcefc3
Merge: e29c010 39aa890
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Fri Sep 7 23:45:03 2012 +0800
Merged master changes.
commit e29c010beb96ca07697c4e3e0c0d5d3ffdc4c0a3
Merge: 8e3fd70 30bdf22
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Aug 20 13:12:57 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 8e3fd703d02c31a4c3ac9f51f5011d03c0bd47f6
Merge: 507bb50 26e0ba0
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Aug 20 13:09:09 2012 +0800
Merged recent changes from trunk.
commit 507bb50a9291bfcdcfa1198f9fea21d4e3b1e762
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Jun 4 20:41:37 2012 +0800
Modified auth app so that login with alternate auth app is possible.
commit dabe3628362ab7a4a6c9686dd874803baa997eaa
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Jun 4 20:10:51 2012 +0800
Modified auth management commands to handle custom user definitions.
commit 7cc0baf89d490c92ef3f1dc909b8090191a1294b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Jun 4 14:17:28 2012 +0800
Added model Meta option for swappable models, and made auth.User a swappable model
2012-09-26 10:48:09 +00:00
|
|
|
|
2015-11-17 05:39:28 +00:00
|
|
|
class AlternateModel(models.Model):
|
|
|
|
pass
|
Fixed #3011 -- Added swappable auth.User models.
Thanks to the many people that contributed to the development and review of
this patch, including (but not limited to) Jacob Kaplan-Moss, Anssi
Kääriäinen, Ramiro Morales, Preston Holmes, Josh Ourisman, Thomas Sutton,
and Roger Barnes, as well as the many, many people who have contributed to
the design discussion around this ticket over many years.
Squashed commit of the following:
commit d84749a0f034a0a6906d20df047086b1219040d0
Merge: 531e771 7c11b1a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Wed Sep 26 18:37:04 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 531e7715da545f930c49919a19e954d41c59b446
Merge: 29d1abb 1f84b04
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Wed Sep 26 07:09:23 2012 +0800
Merged recent trunk changes.
commit 29d1abbe351fd5da855fe5ce09e24227d90ddc91
Merge: 8a527dd 54c81a1
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 24 07:49:46 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 8a527dda13c9bec955b1f7e8db5822d1d9b32a01
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 24 07:48:05 2012 +0800
Ensure sequences are reset correctly in the presence of swapped models.
commit e2b6e22f298eb986d74d28b8d9906f37f5ff8eb8
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 23 17:53:05 2012 +0800
Modifications to the handling and docs for auth forms.
commit 98aba856b534620aea9091f824b442b47d2fdb3c
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 23 15:28:57 2012 +0800
Improved error handling and docs for get_user_model()
commit 0229209c844f06dfeb33b0b8eeec000c127695b6
Merge: 6494bf9 8599f64
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 23 14:50:11 2012 +0800
Merged recent Django trunk changes.
commit 6494bf91f2ddaaabec3ec017f2e3131937c35517
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 17 21:38:44 2012 +0800
Improved validation of swappable model settings.
commit 5a04cde342cc860384eb844cfda5af55204564ad
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 17 07:15:14 2012 +0800
Removed some unused imports.
commit ffd535e4136dc54f084b6ac467e81444696e1c8a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 20:31:28 2012 +0800
Corrected attribute access on for get_by_natural_key
commit 913e1ac84c3d9c7c58a9b3bdbbb15ebccd8a8c0a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 20:12:34 2012 +0800
Added test for proxy model safeguards on swappable models.
commit 280bf19e94d0d534d0e51bae485c1842558f4ff4
Merge: dbb3900 935a863
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 18:16:49 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit dbb3900775a99df8b6cb1d7063cf364eab55621a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 18:09:27 2012 +0800
Fixes for Python 3 compatibility.
commit dfd72131d8664615e245aa0f95b82604ba6b3821
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 15:54:30 2012 +0800
Added protection against proxying swapped models.
commit abcb027190e53613e7f1734e77ee185b2587de31
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 15:11:10 2012 +0800
Cleanup and documentation of AbstractUser base class.
commit a9491a87763e307f0eb0dc246f54ac865a6ffb34
Merge: fd8bb4e 08bcb4a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 14:46:49 2012 +0800
Merge commit '08bcb4aec1ed154cefc631b8510ee13e9af0c19d' into t3011
commit fd8bb4e3e498a92d7a8b340f0684d5f088aa4c92
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 14:20:14 2012 +0800
Documentation improvements coming from community review.
commit b550a6d06d016ab6a0198c4cb2dffe9cceabe8a5
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 13:52:47 2012 +0800
Refactored skipIfCustomUser into the contrib.auth tests.
commit 52a02f11107c3f0d711742b8ca65b75175b79d6a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 13:46:10 2012 +0800
Refactored common 'get' pattern into manager method.
commit b441a6bbc7d6065175715cb09316b9f13268171b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 13:41:33 2012 +0800
Added note about backwards incompatible change to admin login messages.
commit 08bcb4aec1ed154cefc631b8510ee13e9af0c19d
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date: Sat Sep 15 18:30:33 2012 +0300
Splitted User to AbstractUser and User
commit d9f5e5addbad5e1a01f67e7358e4f5091c3cad81
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date: Sat Sep 15 18:30:02 2012 +0300
Reworked REQUIRED_FIELDS + create_user() interaction
commit 579f152e4a6e06671e1ac1e59e2b43cf4d764bf4
Merge: 9184972 93e6733
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 20:18:37 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 918497218c58227f5032873ff97261627b2ceab2
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 20:18:19 2012 +0800
Deprecate AUTH_PROFILE_MODULE and get_profile().
commit 334cdfc1bb6a6794791497cdefda843bca2ea57a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 20:00:12 2012 +0800
Added release notes for new swappable User feature.
commit 5d7bb22e8d913b51aba1c3360e7af8b01b6c0ab6
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 19:59:49 2012 +0800
Ensure swapped models can't be queried.
commit 57ac6e3d32605a67581e875b37ec5b2284711a32
Merge: f2ec915 abfba3b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 14:31:54 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit f2ec915b20f81c8afeaa3df25f80689712f720f8
Merge: 1952656 5e99a3d
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 08:29:51 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 19526563b54fa300785c49cfb625c0c6158ced67
Merge: 2c5e833 c4aa26a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 08:22:26 2012 +0800
Merge recent changes from master.
commit 2c5e833a30bef4305d55eacc0703533152f5c427
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 07:53:46 2012 +0800
Corrected admin_views tests following removal of the email fallback on admin logins.
commit 20d1892491839d6ef21f37db4ca136935c2076bf
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 01:00:37 2012 +0800
Added conditional skips for all tests dependent on the default User model
commit 40ea8b888284775481fc1eaadeff267dbd7e3dfa
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 8 23:47:02 2012 +0800
Added documentation for REQUIRED_FIELDS in custom auth.
commit e6aaf659708cf6491f5485d3edfa616cb9214cc0
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 8 23:20:02 2012 +0800
Added first draft of custom User docs.
Thanks to Greg Turner for the initial text.
commit 75118bd242eec87649da2859e8c50a199a8a1dca
Author: Thomas Sutton <me@thomas-sutton.id.au>
Date: Mon Aug 20 11:17:26 2012 +0800
Admin app should not allow username discovery
The admin app login form should not allow users to discover the username
associated with an email address.
commit d088b3af58dad7449fc58493193a327725c57c22
Author: Thomas Sutton <me@thomas-sutton.id.au>
Date: Mon Aug 20 10:32:13 2012 +0800
Admin app login form should use swapped user model
commit 7e82e83d67ee0871a72e1a3a723afdd214fcefc3
Merge: e29c010 39aa890
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Fri Sep 7 23:45:03 2012 +0800
Merged master changes.
commit e29c010beb96ca07697c4e3e0c0d5d3ffdc4c0a3
Merge: 8e3fd70 30bdf22
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Aug 20 13:12:57 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 8e3fd703d02c31a4c3ac9f51f5011d03c0bd47f6
Merge: 507bb50 26e0ba0
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Aug 20 13:09:09 2012 +0800
Merged recent changes from trunk.
commit 507bb50a9291bfcdcfa1198f9fea21d4e3b1e762
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Jun 4 20:41:37 2012 +0800
Modified auth app so that login with alternate auth app is possible.
commit dabe3628362ab7a4a6c9686dd874803baa997eaa
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Jun 4 20:10:51 2012 +0800
Modified auth management commands to handle custom user definitions.
commit 7cc0baf89d490c92ef3f1dc909b8090191a1294b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Jun 4 14:17:28 2012 +0800
Added model Meta option for swappable models, and made auth.User a swappable model
2012-09-26 10:48:09 +00:00
|
|
|
|
2015-11-17 05:39:28 +00:00
|
|
|
# You can't proxy a swapped model
|
|
|
|
with self.assertRaises(TypeError):
|
Fixed #3011 -- Added swappable auth.User models.
Thanks to the many people that contributed to the development and review of
this patch, including (but not limited to) Jacob Kaplan-Moss, Anssi
Kääriäinen, Ramiro Morales, Preston Holmes, Josh Ourisman, Thomas Sutton,
and Roger Barnes, as well as the many, many people who have contributed to
the design discussion around this ticket over many years.
Squashed commit of the following:
commit d84749a0f034a0a6906d20df047086b1219040d0
Merge: 531e771 7c11b1a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Wed Sep 26 18:37:04 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 531e7715da545f930c49919a19e954d41c59b446
Merge: 29d1abb 1f84b04
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Wed Sep 26 07:09:23 2012 +0800
Merged recent trunk changes.
commit 29d1abbe351fd5da855fe5ce09e24227d90ddc91
Merge: 8a527dd 54c81a1
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 24 07:49:46 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 8a527dda13c9bec955b1f7e8db5822d1d9b32a01
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 24 07:48:05 2012 +0800
Ensure sequences are reset correctly in the presence of swapped models.
commit e2b6e22f298eb986d74d28b8d9906f37f5ff8eb8
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 23 17:53:05 2012 +0800
Modifications to the handling and docs for auth forms.
commit 98aba856b534620aea9091f824b442b47d2fdb3c
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 23 15:28:57 2012 +0800
Improved error handling and docs for get_user_model()
commit 0229209c844f06dfeb33b0b8eeec000c127695b6
Merge: 6494bf9 8599f64
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 23 14:50:11 2012 +0800
Merged recent Django trunk changes.
commit 6494bf91f2ddaaabec3ec017f2e3131937c35517
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 17 21:38:44 2012 +0800
Improved validation of swappable model settings.
commit 5a04cde342cc860384eb844cfda5af55204564ad
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 17 07:15:14 2012 +0800
Removed some unused imports.
commit ffd535e4136dc54f084b6ac467e81444696e1c8a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 20:31:28 2012 +0800
Corrected attribute access on for get_by_natural_key
commit 913e1ac84c3d9c7c58a9b3bdbbb15ebccd8a8c0a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 20:12:34 2012 +0800
Added test for proxy model safeguards on swappable models.
commit 280bf19e94d0d534d0e51bae485c1842558f4ff4
Merge: dbb3900 935a863
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 18:16:49 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit dbb3900775a99df8b6cb1d7063cf364eab55621a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 18:09:27 2012 +0800
Fixes for Python 3 compatibility.
commit dfd72131d8664615e245aa0f95b82604ba6b3821
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 15:54:30 2012 +0800
Added protection against proxying swapped models.
commit abcb027190e53613e7f1734e77ee185b2587de31
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 15:11:10 2012 +0800
Cleanup and documentation of AbstractUser base class.
commit a9491a87763e307f0eb0dc246f54ac865a6ffb34
Merge: fd8bb4e 08bcb4a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 14:46:49 2012 +0800
Merge commit '08bcb4aec1ed154cefc631b8510ee13e9af0c19d' into t3011
commit fd8bb4e3e498a92d7a8b340f0684d5f088aa4c92
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 14:20:14 2012 +0800
Documentation improvements coming from community review.
commit b550a6d06d016ab6a0198c4cb2dffe9cceabe8a5
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 13:52:47 2012 +0800
Refactored skipIfCustomUser into the contrib.auth tests.
commit 52a02f11107c3f0d711742b8ca65b75175b79d6a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 13:46:10 2012 +0800
Refactored common 'get' pattern into manager method.
commit b441a6bbc7d6065175715cb09316b9f13268171b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 13:41:33 2012 +0800
Added note about backwards incompatible change to admin login messages.
commit 08bcb4aec1ed154cefc631b8510ee13e9af0c19d
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date: Sat Sep 15 18:30:33 2012 +0300
Splitted User to AbstractUser and User
commit d9f5e5addbad5e1a01f67e7358e4f5091c3cad81
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date: Sat Sep 15 18:30:02 2012 +0300
Reworked REQUIRED_FIELDS + create_user() interaction
commit 579f152e4a6e06671e1ac1e59e2b43cf4d764bf4
Merge: 9184972 93e6733
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 20:18:37 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 918497218c58227f5032873ff97261627b2ceab2
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 20:18:19 2012 +0800
Deprecate AUTH_PROFILE_MODULE and get_profile().
commit 334cdfc1bb6a6794791497cdefda843bca2ea57a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 20:00:12 2012 +0800
Added release notes for new swappable User feature.
commit 5d7bb22e8d913b51aba1c3360e7af8b01b6c0ab6
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 19:59:49 2012 +0800
Ensure swapped models can't be queried.
commit 57ac6e3d32605a67581e875b37ec5b2284711a32
Merge: f2ec915 abfba3b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 14:31:54 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit f2ec915b20f81c8afeaa3df25f80689712f720f8
Merge: 1952656 5e99a3d
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 08:29:51 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 19526563b54fa300785c49cfb625c0c6158ced67
Merge: 2c5e833 c4aa26a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 08:22:26 2012 +0800
Merge recent changes from master.
commit 2c5e833a30bef4305d55eacc0703533152f5c427
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 07:53:46 2012 +0800
Corrected admin_views tests following removal of the email fallback on admin logins.
commit 20d1892491839d6ef21f37db4ca136935c2076bf
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 01:00:37 2012 +0800
Added conditional skips for all tests dependent on the default User model
commit 40ea8b888284775481fc1eaadeff267dbd7e3dfa
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 8 23:47:02 2012 +0800
Added documentation for REQUIRED_FIELDS in custom auth.
commit e6aaf659708cf6491f5485d3edfa616cb9214cc0
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 8 23:20:02 2012 +0800
Added first draft of custom User docs.
Thanks to Greg Turner for the initial text.
commit 75118bd242eec87649da2859e8c50a199a8a1dca
Author: Thomas Sutton <me@thomas-sutton.id.au>
Date: Mon Aug 20 11:17:26 2012 +0800
Admin app should not allow username discovery
The admin app login form should not allow users to discover the username
associated with an email address.
commit d088b3af58dad7449fc58493193a327725c57c22
Author: Thomas Sutton <me@thomas-sutton.id.au>
Date: Mon Aug 20 10:32:13 2012 +0800
Admin app login form should use swapped user model
commit 7e82e83d67ee0871a72e1a3a723afdd214fcefc3
Merge: e29c010 39aa890
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Fri Sep 7 23:45:03 2012 +0800
Merged master changes.
commit e29c010beb96ca07697c4e3e0c0d5d3ffdc4c0a3
Merge: 8e3fd70 30bdf22
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Aug 20 13:12:57 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 8e3fd703d02c31a4c3ac9f51f5011d03c0bd47f6
Merge: 507bb50 26e0ba0
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Aug 20 13:09:09 2012 +0800
Merged recent changes from trunk.
commit 507bb50a9291bfcdcfa1198f9fea21d4e3b1e762
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Jun 4 20:41:37 2012 +0800
Modified auth app so that login with alternate auth app is possible.
commit dabe3628362ab7a4a6c9686dd874803baa997eaa
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Jun 4 20:10:51 2012 +0800
Modified auth management commands to handle custom user definitions.
commit 7cc0baf89d490c92ef3f1dc909b8090191a1294b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Jun 4 14:17:28 2012 +0800
Added model Meta option for swappable models, and made auth.User a swappable model
2012-09-26 10:48:09 +00:00
|
|
|
|
2015-11-17 05:39:28 +00:00
|
|
|
class ProxyModel(SwappableModel):
|
|
|
|
class Meta:
|
|
|
|
proxy = True
|
Fixed #3011 -- Added swappable auth.User models.
Thanks to the many people that contributed to the development and review of
this patch, including (but not limited to) Jacob Kaplan-Moss, Anssi
Kääriäinen, Ramiro Morales, Preston Holmes, Josh Ourisman, Thomas Sutton,
and Roger Barnes, as well as the many, many people who have contributed to
the design discussion around this ticket over many years.
Squashed commit of the following:
commit d84749a0f034a0a6906d20df047086b1219040d0
Merge: 531e771 7c11b1a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Wed Sep 26 18:37:04 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 531e7715da545f930c49919a19e954d41c59b446
Merge: 29d1abb 1f84b04
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Wed Sep 26 07:09:23 2012 +0800
Merged recent trunk changes.
commit 29d1abbe351fd5da855fe5ce09e24227d90ddc91
Merge: 8a527dd 54c81a1
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 24 07:49:46 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 8a527dda13c9bec955b1f7e8db5822d1d9b32a01
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 24 07:48:05 2012 +0800
Ensure sequences are reset correctly in the presence of swapped models.
commit e2b6e22f298eb986d74d28b8d9906f37f5ff8eb8
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 23 17:53:05 2012 +0800
Modifications to the handling and docs for auth forms.
commit 98aba856b534620aea9091f824b442b47d2fdb3c
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 23 15:28:57 2012 +0800
Improved error handling and docs for get_user_model()
commit 0229209c844f06dfeb33b0b8eeec000c127695b6
Merge: 6494bf9 8599f64
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 23 14:50:11 2012 +0800
Merged recent Django trunk changes.
commit 6494bf91f2ddaaabec3ec017f2e3131937c35517
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 17 21:38:44 2012 +0800
Improved validation of swappable model settings.
commit 5a04cde342cc860384eb844cfda5af55204564ad
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Sep 17 07:15:14 2012 +0800
Removed some unused imports.
commit ffd535e4136dc54f084b6ac467e81444696e1c8a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 20:31:28 2012 +0800
Corrected attribute access on for get_by_natural_key
commit 913e1ac84c3d9c7c58a9b3bdbbb15ebccd8a8c0a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 20:12:34 2012 +0800
Added test for proxy model safeguards on swappable models.
commit 280bf19e94d0d534d0e51bae485c1842558f4ff4
Merge: dbb3900 935a863
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 18:16:49 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit dbb3900775a99df8b6cb1d7063cf364eab55621a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 18:09:27 2012 +0800
Fixes for Python 3 compatibility.
commit dfd72131d8664615e245aa0f95b82604ba6b3821
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 15:54:30 2012 +0800
Added protection against proxying swapped models.
commit abcb027190e53613e7f1734e77ee185b2587de31
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 15:11:10 2012 +0800
Cleanup and documentation of AbstractUser base class.
commit a9491a87763e307f0eb0dc246f54ac865a6ffb34
Merge: fd8bb4e 08bcb4a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 14:46:49 2012 +0800
Merge commit '08bcb4aec1ed154cefc631b8510ee13e9af0c19d' into t3011
commit fd8bb4e3e498a92d7a8b340f0684d5f088aa4c92
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 14:20:14 2012 +0800
Documentation improvements coming from community review.
commit b550a6d06d016ab6a0198c4cb2dffe9cceabe8a5
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 13:52:47 2012 +0800
Refactored skipIfCustomUser into the contrib.auth tests.
commit 52a02f11107c3f0d711742b8ca65b75175b79d6a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 13:46:10 2012 +0800
Refactored common 'get' pattern into manager method.
commit b441a6bbc7d6065175715cb09316b9f13268171b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 16 13:41:33 2012 +0800
Added note about backwards incompatible change to admin login messages.
commit 08bcb4aec1ed154cefc631b8510ee13e9af0c19d
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date: Sat Sep 15 18:30:33 2012 +0300
Splitted User to AbstractUser and User
commit d9f5e5addbad5e1a01f67e7358e4f5091c3cad81
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date: Sat Sep 15 18:30:02 2012 +0300
Reworked REQUIRED_FIELDS + create_user() interaction
commit 579f152e4a6e06671e1ac1e59e2b43cf4d764bf4
Merge: 9184972 93e6733
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 20:18:37 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 918497218c58227f5032873ff97261627b2ceab2
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 20:18:19 2012 +0800
Deprecate AUTH_PROFILE_MODULE and get_profile().
commit 334cdfc1bb6a6794791497cdefda843bca2ea57a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 20:00:12 2012 +0800
Added release notes for new swappable User feature.
commit 5d7bb22e8d913b51aba1c3360e7af8b01b6c0ab6
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 19:59:49 2012 +0800
Ensure swapped models can't be queried.
commit 57ac6e3d32605a67581e875b37ec5b2284711a32
Merge: f2ec915 abfba3b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 15 14:31:54 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit f2ec915b20f81c8afeaa3df25f80689712f720f8
Merge: 1952656 5e99a3d
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 08:29:51 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 19526563b54fa300785c49cfb625c0c6158ced67
Merge: 2c5e833 c4aa26a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 08:22:26 2012 +0800
Merge recent changes from master.
commit 2c5e833a30bef4305d55eacc0703533152f5c427
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 07:53:46 2012 +0800
Corrected admin_views tests following removal of the email fallback on admin logins.
commit 20d1892491839d6ef21f37db4ca136935c2076bf
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sun Sep 9 01:00:37 2012 +0800
Added conditional skips for all tests dependent on the default User model
commit 40ea8b888284775481fc1eaadeff267dbd7e3dfa
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 8 23:47:02 2012 +0800
Added documentation for REQUIRED_FIELDS in custom auth.
commit e6aaf659708cf6491f5485d3edfa616cb9214cc0
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Sat Sep 8 23:20:02 2012 +0800
Added first draft of custom User docs.
Thanks to Greg Turner for the initial text.
commit 75118bd242eec87649da2859e8c50a199a8a1dca
Author: Thomas Sutton <me@thomas-sutton.id.au>
Date: Mon Aug 20 11:17:26 2012 +0800
Admin app should not allow username discovery
The admin app login form should not allow users to discover the username
associated with an email address.
commit d088b3af58dad7449fc58493193a327725c57c22
Author: Thomas Sutton <me@thomas-sutton.id.au>
Date: Mon Aug 20 10:32:13 2012 +0800
Admin app login form should use swapped user model
commit 7e82e83d67ee0871a72e1a3a723afdd214fcefc3
Merge: e29c010 39aa890
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Fri Sep 7 23:45:03 2012 +0800
Merged master changes.
commit e29c010beb96ca07697c4e3e0c0d5d3ffdc4c0a3
Merge: 8e3fd70 30bdf22
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Aug 20 13:12:57 2012 +0800
Merge remote-tracking branch 'django/master' into t3011
commit 8e3fd703d02c31a4c3ac9f51f5011d03c0bd47f6
Merge: 507bb50 26e0ba0
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Aug 20 13:09:09 2012 +0800
Merged recent changes from trunk.
commit 507bb50a9291bfcdcfa1198f9fea21d4e3b1e762
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Jun 4 20:41:37 2012 +0800
Modified auth app so that login with alternate auth app is possible.
commit dabe3628362ab7a4a6c9686dd874803baa997eaa
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Jun 4 20:10:51 2012 +0800
Modified auth management commands to handle custom user definitions.
commit 7cc0baf89d490c92ef3f1dc909b8090191a1294b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date: Mon Jun 4 14:17:28 2012 +0800
Added model Meta option for swappable models, and made auth.User a swappable model
2012-09-26 10:48:09 +00:00
|
|
|
|
2010-09-13 05:29:21 +00:00
|
|
|
def test_myperson_manager(self):
|
|
|
|
Person.objects.create(name="fred")
|
|
|
|
Person.objects.create(name="wilma")
|
|
|
|
Person.objects.create(name="barney")
|
|
|
|
|
|
|
|
resp = [p.name for p in MyPerson.objects.all()]
|
|
|
|
self.assertEqual(resp, ["barney", "fred"])
|
|
|
|
|
|
|
|
resp = [p.name for p in MyPerson._default_manager.all()]
|
|
|
|
self.assertEqual(resp, ["barney", "fred"])
|
|
|
|
|
|
|
|
def test_otherperson_manager(self):
|
|
|
|
Person.objects.create(name="fred")
|
|
|
|
Person.objects.create(name="wilma")
|
|
|
|
Person.objects.create(name="barney")
|
|
|
|
|
|
|
|
resp = [p.name for p in OtherPerson.objects.all()]
|
|
|
|
self.assertEqual(resp, ["barney", "wilma"])
|
|
|
|
|
|
|
|
resp = [p.name for p in OtherPerson.excluder.all()]
|
|
|
|
self.assertEqual(resp, ["barney", "fred"])
|
|
|
|
|
|
|
|
resp = [p.name for p in OtherPerson._default_manager.all()]
|
|
|
|
self.assertEqual(resp, ["barney", "wilma"])
|
|
|
|
|
2012-03-22 08:49:48 +00:00
|
|
|
def test_permissions_created(self):
|
|
|
|
from django.contrib.auth.models import Permission
|
2022-02-03 19:24:19 +00:00
|
|
|
|
2016-06-28 15:21:26 +00:00
|
|
|
Permission.objects.get(name="May display users information")
|
2012-03-22 08:49:48 +00:00
|
|
|
|
2010-09-13 05:29:21 +00:00
|
|
|
def test_proxy_model_signals(self):
|
|
|
|
"""
|
|
|
|
Test save signals for proxy models
|
|
|
|
"""
|
|
|
|
output = []
|
|
|
|
|
|
|
|
def make_handler(model, event):
|
|
|
|
def _handler(*args, **kwargs):
|
|
|
|
output.append("%s %s save" % (model, event))
|
2022-02-03 19:24:19 +00:00
|
|
|
|
2010-09-13 05:29:21 +00:00
|
|
|
return _handler
|
|
|
|
|
|
|
|
h1 = make_handler("MyPerson", "pre")
|
|
|
|
h2 = make_handler("MyPerson", "post")
|
|
|
|
h3 = make_handler("Person", "pre")
|
|
|
|
h4 = make_handler("Person", "post")
|
|
|
|
|
|
|
|
signals.pre_save.connect(h1, sender=MyPerson)
|
|
|
|
signals.post_save.connect(h2, sender=MyPerson)
|
|
|
|
signals.pre_save.connect(h3, sender=Person)
|
|
|
|
signals.post_save.connect(h4, sender=Person)
|
|
|
|
|
2013-10-19 12:31:38 +00:00
|
|
|
MyPerson.objects.create(name="dino")
|
2010-09-13 05:29:21 +00:00
|
|
|
self.assertEqual(output, ["MyPerson pre save", "MyPerson post save"])
|
|
|
|
|
|
|
|
output = []
|
|
|
|
|
|
|
|
h5 = make_handler("MyPersonProxy", "pre")
|
|
|
|
h6 = make_handler("MyPersonProxy", "post")
|
|
|
|
|
|
|
|
signals.pre_save.connect(h5, sender=MyPersonProxy)
|
|
|
|
signals.post_save.connect(h6, sender=MyPersonProxy)
|
|
|
|
|
2013-10-19 12:31:38 +00:00
|
|
|
MyPersonProxy.objects.create(name="pebbles")
|
2010-09-13 05:29:21 +00:00
|
|
|
|
|
|
|
self.assertEqual(output, ["MyPersonProxy pre save", "MyPersonProxy post save"])
|
|
|
|
|
|
|
|
signals.pre_save.disconnect(h1, sender=MyPerson)
|
|
|
|
signals.post_save.disconnect(h2, sender=MyPerson)
|
|
|
|
signals.pre_save.disconnect(h3, sender=Person)
|
|
|
|
signals.post_save.disconnect(h4, sender=Person)
|
|
|
|
signals.pre_save.disconnect(h5, sender=MyPersonProxy)
|
|
|
|
signals.post_save.disconnect(h6, sender=MyPersonProxy)
|
|
|
|
|
|
|
|
def test_content_type(self):
|
|
|
|
ctype = ContentType.objects.get_for_model
|
2014-10-28 10:02:56 +00:00
|
|
|
self.assertIs(ctype(Person), ctype(OtherPerson))
|
2010-09-13 05:29:21 +00:00
|
|
|
|
2016-03-27 19:20:54 +00:00
|
|
|
def test_user_proxy_models(self):
|
2010-09-13 05:29:21 +00:00
|
|
|
User.objects.create(name="Bruce")
|
|
|
|
|
|
|
|
resp = [u.name for u in User.objects.all()]
|
|
|
|
self.assertEqual(resp, ["Bruce"])
|
|
|
|
|
|
|
|
resp = [u.name for u in UserProxy.objects.all()]
|
|
|
|
self.assertEqual(resp, ["Bruce"])
|
|
|
|
|
|
|
|
resp = [u.name for u in UserProxyProxy.objects.all()]
|
|
|
|
self.assertEqual(resp, ["Bruce"])
|
|
|
|
|
2016-03-27 19:20:54 +00:00
|
|
|
self.assertEqual([u.name for u in MultiUserProxy.objects.all()], ["Bruce"])
|
|
|
|
|
2012-02-22 05:26:50 +00:00
|
|
|
def test_proxy_for_model(self):
|
|
|
|
self.assertEqual(UserProxy, UserProxyProxy._meta.proxy_for_model)
|
|
|
|
|
|
|
|
def test_concrete_model(self):
|
|
|
|
self.assertEqual(User, UserProxyProxy._meta.concrete_model)
|
|
|
|
|
2010-09-13 05:29:21 +00:00
|
|
|
def test_proxy_delete(self):
|
|
|
|
"""
|
|
|
|
Proxy objects can be deleted
|
|
|
|
"""
|
|
|
|
User.objects.create(name="Bruce")
|
|
|
|
u2 = UserProxy.objects.create(name="George")
|
|
|
|
|
|
|
|
resp = [u.name for u in UserProxy.objects.all()]
|
|
|
|
self.assertEqual(resp, ["Bruce", "George"])
|
|
|
|
|
|
|
|
u2.delete()
|
|
|
|
|
|
|
|
resp = [u.name for u in UserProxy.objects.all()]
|
|
|
|
self.assertEqual(resp, ["Bruce"])
|
|
|
|
|
2017-11-20 15:25:01 +00:00
|
|
|
def test_proxy_update(self):
|
|
|
|
user = User.objects.create(name="Bruce")
|
|
|
|
with self.assertNumQueries(1):
|
|
|
|
UserProxy.objects.filter(id=user.id).update(name="George")
|
|
|
|
user.refresh_from_db()
|
|
|
|
self.assertEqual(user.name, "George")
|
|
|
|
|
2010-09-13 05:29:21 +00:00
|
|
|
def test_select_related(self):
|
|
|
|
"""
|
|
|
|
We can still use `select_related()` to include related models in our
|
|
|
|
querysets.
|
|
|
|
"""
|
|
|
|
country = Country.objects.create(name="Australia")
|
2013-10-19 12:31:38 +00:00
|
|
|
State.objects.create(name="New South Wales", country=country)
|
2010-09-13 05:29:21 +00:00
|
|
|
|
|
|
|
resp = [s.name for s in State.objects.select_related()]
|
|
|
|
self.assertEqual(resp, ["New South Wales"])
|
|
|
|
|
|
|
|
resp = [s.name for s in StateProxy.objects.select_related()]
|
|
|
|
self.assertEqual(resp, ["New South Wales"])
|
|
|
|
|
2016-04-08 02:04:45 +00:00
|
|
|
self.assertEqual(
|
|
|
|
StateProxy.objects.get(name="New South Wales").name, "New South Wales"
|
|
|
|
)
|
2010-09-13 05:29:21 +00:00
|
|
|
|
|
|
|
resp = StateProxy.objects.select_related().get(name="New South Wales")
|
|
|
|
self.assertEqual(resp.name, "New South Wales")
|
|
|
|
|
2015-02-16 07:49:19 +00:00
|
|
|
def test_filter_proxy_relation_reverse(self):
|
2015-10-01 18:57:58 +00:00
|
|
|
tu = TrackerUser.objects.create(name="Contributor", status="contrib")
|
|
|
|
ptu = ProxyTrackerUser.objects.get()
|
|
|
|
issue = Issue.objects.create(assignee=tu)
|
|
|
|
self.assertEqual(tu.issues.get(), issue)
|
|
|
|
self.assertEqual(ptu.issues.get(), issue)
|
2016-09-10 09:36:27 +00:00
|
|
|
self.assertSequenceEqual(TrackerUser.objects.filter(issues=issue), [tu])
|
|
|
|
self.assertSequenceEqual(ProxyTrackerUser.objects.filter(issues=issue), [ptu])
|
2015-02-16 07:49:19 +00:00
|
|
|
|
2010-09-13 05:29:21 +00:00
|
|
|
def test_proxy_bug(self):
|
2016-04-08 02:04:45 +00:00
|
|
|
contributor = ProxyTrackerUser.objects.create(
|
|
|
|
name="Contributor", status="contrib"
|
|
|
|
)
|
2010-09-13 05:29:21 +00:00
|
|
|
someone = BaseUser.objects.create(name="Someone")
|
2016-04-08 02:04:45 +00:00
|
|
|
Bug.objects.create(
|
|
|
|
summary="fix this",
|
|
|
|
version="1.1beta",
|
|
|
|
assignee=contributor,
|
|
|
|
reporter=someone,
|
|
|
|
)
|
|
|
|
pcontributor = ProxyTrackerUser.objects.create(
|
|
|
|
name="OtherContributor", status="proxy"
|
|
|
|
)
|
|
|
|
Improvement.objects.create(
|
|
|
|
summary="improve that",
|
|
|
|
version="1.1beta",
|
2010-09-13 05:29:21 +00:00
|
|
|
assignee=contributor,
|
|
|
|
reporter=pcontributor,
|
2016-04-08 02:04:45 +00:00
|
|
|
associated_bug=ProxyProxyBug.objects.all()[0],
|
|
|
|
)
|
2010-09-13 05:29:21 +00:00
|
|
|
|
|
|
|
# Related field filter on proxy
|
|
|
|
resp = ProxyBug.objects.get(version__icontains="beta")
|
|
|
|
self.assertEqual(repr(resp), "<ProxyBug: ProxyBug:fix this>")
|
|
|
|
|
|
|
|
# Select related + filter on proxy
|
|
|
|
resp = ProxyBug.objects.select_related().get(version__icontains="beta")
|
|
|
|
self.assertEqual(repr(resp), "<ProxyBug: ProxyBug:fix this>")
|
|
|
|
|
|
|
|
# Proxy of proxy, select_related + filter
|
|
|
|
resp = ProxyProxyBug.objects.select_related().get(version__icontains="beta")
|
|
|
|
self.assertEqual(repr(resp), "<ProxyProxyBug: ProxyProxyBug:fix this>")
|
|
|
|
|
|
|
|
# Select related + filter on a related proxy field
|
|
|
|
resp = ProxyImprovement.objects.select_related().get(
|
|
|
|
reporter__name__icontains="butor"
|
|
|
|
)
|
2013-12-08 17:20:06 +00:00
|
|
|
self.assertEqual(
|
2010-09-13 05:29:21 +00:00
|
|
|
repr(resp), "<ProxyImprovement: ProxyImprovement:improve that>"
|
|
|
|
)
|
|
|
|
|
|
|
|
# Select related + filter on a related proxy of proxy field
|
|
|
|
resp = ProxyImprovement.objects.select_related().get(
|
|
|
|
associated_bug__summary__icontains="fix"
|
|
|
|
)
|
2013-12-08 17:20:06 +00:00
|
|
|
self.assertEqual(
|
2010-09-13 05:29:21 +00:00
|
|
|
repr(resp), "<ProxyImprovement: ProxyImprovement:improve that>"
|
|
|
|
)
|
|
|
|
|
|
|
|
def test_proxy_load_from_fixture(self):
|
2013-06-30 12:17:33 +00:00
|
|
|
management.call_command("loaddata", "mypeople.json", verbosity=0)
|
2010-09-13 05:29:21 +00:00
|
|
|
p = MyPerson.objects.get(pk=100)
|
|
|
|
self.assertEqual(p.name, "Elvis Presley")
|
2013-02-23 22:20:34 +00:00
|
|
|
|
2022-07-04 04:37:36 +00:00
|
|
|
def test_select_related_only(self):
|
|
|
|
user = ProxyTrackerUser.objects.create(name="Joe Doe", status="test")
|
|
|
|
issue = Issue.objects.create(summary="New issue", assignee=user)
|
|
|
|
qs = Issue.objects.select_related("assignee").only("assignee__status")
|
|
|
|
self.assertEqual(qs.get(), issue)
|
|
|
|
|
2013-08-07 06:51:32 +00:00
|
|
|
def test_eq(self):
|
|
|
|
self.assertEqual(MyPerson(id=100), Person(id=100))
|
|
|
|
|
2013-02-23 22:20:34 +00:00
|
|
|
|
2016-02-05 20:56:52 +00:00
|
|
|
@override_settings(ROOT_URLCONF="proxy_models.urls")
|
2013-02-23 22:20:34 +00:00
|
|
|
class ProxyModelAdminTests(TestCase):
|
2015-02-23 00:53:57 +00:00
|
|
|
@classmethod
|
|
|
|
def setUpTestData(cls):
|
2016-02-05 20:56:52 +00:00
|
|
|
cls.superuser = AuthUser.objects.create(is_superuser=True, is_staff=True)
|
2015-02-23 00:53:57 +00:00
|
|
|
cls.tu1 = ProxyTrackerUser.objects.create(name="Django Pony", status="emperor")
|
|
|
|
cls.i1 = Issue.objects.create(summary="Pony's Issue", assignee=cls.tu1)
|
2013-02-23 22:20:34 +00:00
|
|
|
|
|
|
|
def test_cascade_delete_proxy_model_admin_warning(self):
|
|
|
|
"""
|
|
|
|
Test if admin gives warning about cascade deleting models referenced
|
|
|
|
to concrete model by deleting proxy object.
|
|
|
|
"""
|
|
|
|
tracker_user = TrackerUser.objects.all()[0]
|
|
|
|
base_user = BaseUser.objects.all()[0]
|
|
|
|
issue = Issue.objects.all()[0]
|
2016-06-03 00:44:47 +00:00
|
|
|
with self.assertNumQueries(6):
|
2013-09-16 16:52:05 +00:00
|
|
|
collector = admin.utils.NestedObjects("default")
|
2013-02-23 22:20:34 +00:00
|
|
|
collector.collect(ProxyTrackerUser.objects.all())
|
2014-10-28 10:02:56 +00:00
|
|
|
self.assertIn(tracker_user, collector.edges.get(None, ()))
|
|
|
|
self.assertIn(base_user, collector.edges.get(None, ()))
|
|
|
|
self.assertIn(issue, collector.edges.get(tracker_user, ()))
|
2013-08-15 07:32:54 +00:00
|
|
|
|
|
|
|
def test_delete_str_in_model_admin(self):
|
|
|
|
"""
|
|
|
|
Test if the admin delete page shows the correct string representation
|
|
|
|
for a proxy model.
|
|
|
|
"""
|
|
|
|
user = TrackerUser.objects.get(name="Django Pony")
|
|
|
|
proxy = ProxyTrackerUser.objects.get(name="Django Pony")
|
|
|
|
|
2015-02-09 16:28:03 +00:00
|
|
|
user_str = 'Tracker user: <a href="%s">%s</a>' % (
|
2015-03-30 16:33:26 +00:00
|
|
|
reverse("admin_proxy:proxy_models_trackeruser_change", args=(user.pk,)),
|
|
|
|
user,
|
2015-02-09 16:28:03 +00:00
|
|
|
)
|
|
|
|
proxy_str = 'Proxy tracker user: <a href="%s">%s</a>' % (
|
2015-03-30 16:33:26 +00:00
|
|
|
reverse(
|
|
|
|
"admin_proxy:proxy_models_proxytrackeruser_change", args=(proxy.pk,)
|
|
|
|
),
|
|
|
|
proxy,
|
2015-02-09 16:28:03 +00:00
|
|
|
)
|
2013-08-15 07:32:54 +00:00
|
|
|
|
2016-02-05 20:56:52 +00:00
|
|
|
self.client.force_login(self.superuser)
|
2015-03-30 16:33:26 +00:00
|
|
|
response = self.client.get(
|
|
|
|
reverse("admin_proxy:proxy_models_trackeruser_delete", args=(user.pk,))
|
2022-02-03 19:24:19 +00:00
|
|
|
)
|
2013-08-15 07:32:54 +00:00
|
|
|
delete_str = response.context["deleted_objects"][0]
|
|
|
|
self.assertEqual(delete_str, user_str)
|
2015-03-30 16:33:26 +00:00
|
|
|
response = self.client.get(
|
|
|
|
reverse(
|
|
|
|
"admin_proxy:proxy_models_proxytrackeruser_delete", args=(proxy.pk,)
|
2022-02-03 19:24:19 +00:00
|
|
|
)
|
|
|
|
)
|
2013-08-15 07:32:54 +00:00
|
|
|
delete_str = response.context["deleted_objects"][0]
|
|
|
|
self.assertEqual(delete_str, proxy_str)
|