2008-08-08 18:07:33 +00:00
# coding: utf-8
2013-07-29 17:19:04 +00:00
from __future__ import unicode_literals
2008-07-18 23:54:34 +00:00
2012-02-09 18:59:05 +00:00
import os
2009-03-10 11:19:26 +00:00
import re
2009-03-29 18:52:38 +00:00
import datetime
2013-07-01 20:49:07 +00:00
import unittest
2010-12-04 07:28:12 +00:00
2012-04-09 13:24:57 +00:00
from django . conf import settings , global_settings
2010-11-21 19:00:40 +00:00
from django . core import mail
2009-04-18 20:29:55 +00:00
from django . core . files import temp as tempfile
2013-09-07 13:20:04 +00:00
from django . core . urlresolvers import reverse , NoReverseMatch
2010-12-04 07:28:12 +00:00
# Register auth models with the admin.
2013-07-01 13:19:55 +00:00
from django . contrib . auth import get_permission_codename
2011-10-13 18:51:33 +00:00
from django . contrib . admin . helpers import ACTION_CHECKBOX_NAME
2009-05-07 13:10:59 +00:00
from django . contrib . admin . models import LogEntry , DELETION
2008-09-02 21:10:00 +00:00
from django . contrib . admin . sites import LOGIN_FORM_KEY
2013-09-16 16:52:05 +00:00
from django . contrib . admin . utils import quote
2011-01-02 01:32:40 +00:00
from django . contrib . admin . views . main import IS_POPUP_VAR
2012-02-19 16:42:12 +00:00
from django . contrib . admin . tests import AdminSeleniumWebDriverTestCase
from django . contrib . auth import REDIRECT_FIELD_NAME
2013-06-18 18:02:00 +00:00
from django . contrib . auth . models import Group , User , Permission
2011-10-13 18:51:33 +00:00
from django . contrib . contenttypes . models import ContentType
2013-05-10 14:56:42 +00:00
from django . db import connection
2013-09-16 16:52:05 +00:00
from django . forms . utils import ErrorList
2011-04-22 18:17:16 +00:00
from django . template . response import TemplateResponse
2010-05-13 13:29:31 +00:00
from django . test import TestCase
2013-05-15 23:14:28 +00:00
from django . test . utils import patch_logger
2013-09-05 19:38:59 +00:00
from django . test . utils import override_settings
2013-07-01 20:49:07 +00:00
from django . utils import formats
from django . utils import translation
2009-07-13 13:46:31 +00:00
from django . utils . cache import get_max_age
2012-08-28 18:59:56 +00:00
from django . utils . encoding import iri_to_uri , force_bytes
2008-07-18 23:54:34 +00:00
from django . utils . html import escape
2013-03-18 20:52:16 +00:00
from django . utils . http import urlencode , urlquote
2013-09-05 19:38:59 +00:00
from django . utils . six . moves . urllib . parse import urljoin
2012-12-08 10:13:52 +00:00
from django . utils . _os import upath
2012-07-20 12:48:51 +00:00
from django . utils import six
2008-07-18 23:54:34 +00:00
# local test models
2011-10-13 18:51:33 +00:00
from . models import ( Article , BarAccount , CustomArticle , EmptyModel , FooAccount ,
Gallery , ModelWithStringPrimaryKey , Person , Persona , Picture , Podcast ,
Section , Subscriber , Vodcast , Language , Collector , Widget , Grommet ,
DooHickey , FancyDoodad , Whatsit , Category , Post , Plot , FunkyTag , Chapter ,
Book , Promo , WorkHour , Employee , Question , Answer , Inquisition , Actor ,
FoodDelivery , RowLevelChangePermissionModel , Paper , CoverLetter , Story ,
2013-05-19 08:52:29 +00:00
OtherStory , ComplexSortedPerson , PluggableSearchPerson , Parent , Child , AdminOrderedField ,
2011-12-19 14:59:14 +00:00
AdminOrderedModelMethod , AdminOrderedAdminMethod , AdminOrderedCallable ,
2012-07-22 01:10:24 +00:00
Report , MainPrepopulated , RelatedPrepopulated , UnorderedObject ,
2013-08-29 13:39:31 +00:00
Simple , UndeletableObject , UnchangeableObject , Choice , ShortMessage ,
2013-09-06 20:28:48 +00:00
Telegram , Pizza , Topping , FilteredManager )
2013-07-18 19:17:40 +00:00
from . admin import site , site2
2011-10-13 18:51:33 +00:00
2009-03-10 11:19:26 +00:00
2011-09-22 04:16:21 +00:00
ERROR_MESSAGE = " Please enter the correct username and password \
2012-12-15 23:18:45 +00:00
for a staff account . Note that both fields may be case - sensitive . "
2011-09-22 04:16: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
2013-10-14 13:14:17 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) ,
USE_I18N = True , USE_L10N = False , LANGUAGE_CODE = ' en ' )
2013-06-28 00:13:42 +00:00
class AdminViewBasicTestCase ( TestCase ) :
2010-11-21 19:29:15 +00:00
fixtures = [ ' admin-views-users.xml ' , ' admin-views-colors.xml ' ,
' admin-views-fabrics.xml ' , ' admin-views-books.xml ' ]
2009-03-10 11:19:26 +00:00
# Store the bit of the URL where the admin is registered as a class
2009-01-14 20:22:25 +00:00
# variable. That way we can test a second AdminSite just by subclassing
# this test case and changing urlbit.
urlbit = ' admin '
2009-03-10 11:19:26 +00:00
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2011-09-20 18:16:49 +00:00
2008-08-09 20:52:40 +00:00
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
2009-03-10 11:19:26 +00:00
2008-08-09 20:52:40 +00:00
def tearDown ( self ) :
self . client . logout ( )
2011-02-04 13:52:36 +00:00
formats . reset_format_cache ( )
2009-03-10 11:19:26 +00:00
2012-08-14 12:36:11 +00:00
def assertContentBefore ( self , response , text1 , text2 , failing_msg = None ) :
"""
Testing utility asserting that text1 appears before text2 in response
content .
"""
self . assertEqual ( response . status_code , 200 )
2012-08-28 18:59:56 +00:00
self . assertTrue ( response . content . index ( force_bytes ( text1 ) ) < response . content . index ( force_bytes ( text2 ) ) ,
2012-08-14 12:36:11 +00:00
failing_msg
)
2013-06-28 00:13:42 +00:00
class AdminViewBasicTest ( AdminViewBasicTestCase ) :
2008-08-09 20:52:40 +00:00
def testTrailingSlashRequired ( self ) :
"""
If you leave off the trailing slash , app should redirect and add it .
"""
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/ %s /admin_views/article/add ' % self . urlbit )
self . assertRedirects ( response ,
2009-01-14 20:22:25 +00:00
' /test_admin/ %s /admin_views/article/add/ ' % self . urlbit , status_code = 301
2008-08-09 20:52:40 +00:00
)
2009-03-10 11:19:26 +00:00
2008-08-09 20:52:40 +00:00
def testBasicAddGet ( self ) :
"""
A smoke test to ensure GET on the add_view works .
"""
2009-01-14 20:22:25 +00:00
response = self . client . get ( ' /test_admin/ %s /admin_views/section/add/ ' % self . urlbit )
2011-04-22 18:17:16 +00:00
self . assertIsInstance ( response , TemplateResponse )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 200 )
2009-03-10 11:19:26 +00:00
2008-08-29 16:09:29 +00:00
def testAddWithGETArgs ( self ) :
2009-01-14 20:22:25 +00:00
response = self . client . get ( ' /test_admin/ %s /admin_views/section/add/ ' % self . urlbit , { ' name ' : ' My Section ' } )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 200 )
2012-04-14 13:35:25 +00:00
self . assertContains ( response , ' value= " My Section " ' ,
msg_prefix = " Couldn ' t find an input with the right value in the response "
2008-08-29 16:09:29 +00:00
)
2009-03-10 11:19:26 +00:00
2008-08-09 20:52:40 +00:00
def testBasicEditGet ( self ) :
"""
2009-12-28 14:08:11 +00:00
A smoke test to ensure GET on the change_view works .
2008-08-09 20:52:40 +00:00
"""
2009-01-14 20:22:25 +00:00
response = self . client . get ( ' /test_admin/ %s /admin_views/section/1/ ' % self . urlbit )
2011-04-22 18:17:16 +00:00
self . assertIsInstance ( response , TemplateResponse )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 200 )
2009-03-10 11:19:26 +00:00
2009-12-28 14:08:11 +00:00
def testBasicEditGetStringPK ( self ) :
"""
2013-03-01 05:01:25 +00:00
Ensure GET on the change_view works ( returns an HTTP 404 error , see
#11191) when passing a string as the PK argument for a model with an
integer PK field .
2009-12-28 14:08:11 +00:00
"""
response = self . client . get ( ' /test_admin/ %s /admin_views/section/abc/ ' % self . urlbit )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 404 )
2009-12-28 14:08:11 +00:00
2013-03-01 05:01:25 +00:00
def testBasicInheritanceGetStringPK ( self ) :
"""
Ensure GET on the change_view works on inherited models ( returns an
HTTP 404 error , see #19951) when passing a string as the PK argument
for a model with an integer PK field .
"""
response = self . client . get ( ' /test_admin/ %s /admin_views/supervillain/abc/ ' % self . urlbit )
self . assertEqual ( response . status_code , 404 )
2008-08-09 20:52:40 +00:00
def testBasicAddPost ( self ) :
"""
A smoke test to ensure POST on add_view works .
"""
post_data = {
2012-06-07 16:08:47 +00:00
" name " : " Another Section " ,
2008-08-09 20:52:40 +00:00
# inline data
2012-06-07 16:08:47 +00:00
" article_set-TOTAL_FORMS " : " 3 " ,
" article_set-INITIAL_FORMS " : " 0 " ,
" article_set-MAX_NUM_FORMS " : " 0 " ,
2008-08-09 20:52:40 +00:00
}
2009-01-14 20:22:25 +00:00
response = self . client . post ( ' /test_admin/ %s /admin_views/section/add/ ' % self . urlbit , post_data )
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
self . assertEqual ( response . status_code , 302 ) # redirect somewhere
2009-03-10 11:19:26 +00:00
2011-01-02 17:34:52 +00:00
def testPopupAddPost ( self ) :
"""
Ensure http response from a popup is properly escaped .
"""
post_data = {
2012-06-07 16:08:47 +00:00
' _popup ' : ' 1 ' ,
' title ' : ' title with a new \n line ' ,
' content ' : ' some content ' ,
' date_0 ' : ' 2010-09-10 ' ,
' date_1 ' : ' 14:55:39 ' ,
2011-01-02 17:34:52 +00:00
}
response = self . client . post ( ' /test_admin/ %s /admin_views/article/add/ ' % self . urlbit , post_data )
2011-10-14 00:20:50 +00:00
self . assertEqual ( response . status_code , 200 )
2011-01-02 17:34:52 +00:00
self . assertContains ( response , ' dismissAddAnotherPopup ' )
2012-06-07 16:08:47 +00:00
self . assertContains ( response , ' title with a new \\ u000Aline ' )
2011-01-02 17:34:52 +00:00
2009-04-02 00:01:15 +00:00
# Post data for edit inline
inline_post_data = {
2012-06-07 16:08:47 +00:00
" name " : " Test section " ,
2009-04-02 00:01:15 +00:00
# inline data
2012-06-07 16:08:47 +00:00
" article_set-TOTAL_FORMS " : " 6 " ,
" article_set-INITIAL_FORMS " : " 3 " ,
" article_set-MAX_NUM_FORMS " : " 0 " ,
" article_set-0-id " : " 1 " ,
2009-04-02 00:01:15 +00:00
# there is no title in database, give one here or formset will fail.
2012-06-07 16:08:47 +00:00
" article_set-0-title " : " Norske bostaver æøå skaper problemer " ,
" article_set-0-content " : " <p>Middle content</p> " ,
" article_set-0-date_0 " : " 2008-03-18 " ,
" article_set-0-date_1 " : " 11:54:58 " ,
" article_set-0-section " : " 1 " ,
" article_set-1-id " : " 2 " ,
" article_set-1-title " : " Need a title. " ,
" article_set-1-content " : " <p>Oldest content</p> " ,
" article_set-1-date_0 " : " 2000-03-18 " ,
" article_set-1-date_1 " : " 11:54:58 " ,
" article_set-2-id " : " 3 " ,
" article_set-2-title " : " Need a title. " ,
" article_set-2-content " : " <p>Newest content</p> " ,
" article_set-2-date_0 " : " 2009-03-18 " ,
" article_set-2-date_1 " : " 11:54:58 " ,
" article_set-3-id " : " " ,
" article_set-3-title " : " " ,
" article_set-3-content " : " " ,
" article_set-3-date_0 " : " " ,
" article_set-3-date_1 " : " " ,
" article_set-4-id " : " " ,
" article_set-4-title " : " " ,
" article_set-4-content " : " " ,
" article_set-4-date_0 " : " " ,
" article_set-4-date_1 " : " " ,
" article_set-5-id " : " " ,
" article_set-5-title " : " " ,
" article_set-5-content " : " " ,
" article_set-5-date_0 " : " " ,
" article_set-5-date_1 " : " " ,
2009-04-02 00:01:15 +00:00
}
2008-08-09 20:52:40 +00:00
def testBasicEditPost ( self ) :
"""
A smoke test to ensure POST on edit_view works .
"""
2009-04-02 00:01:15 +00:00
response = self . client . post ( ' /test_admin/ %s /admin_views/section/1/ ' % self . urlbit , self . inline_post_data )
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
self . assertEqual ( response . status_code , 302 ) # redirect somewhere
2009-04-02 00:01:15 +00:00
def testEditSaveAs ( self ) :
"""
Test " save as " .
"""
post_data = self . inline_post_data . copy ( )
post_data . update ( {
2012-06-07 16:08:47 +00:00
' _saveasnew ' : ' Save+as+new ' ,
" article_set-1-section " : " 1 " ,
" article_set-2-section " : " 1 " ,
" article_set-3-section " : " 1 " ,
" article_set-4-section " : " 1 " ,
" article_set-5-section " : " 1 " ,
2009-04-02 00:01:15 +00:00
} )
2009-01-14 20:22:25 +00:00
response = self . client . post ( ' /test_admin/ %s /admin_views/section/1/ ' % self . urlbit , post_data )
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
self . assertEqual ( response . status_code , 302 ) # redirect somewhere
2008-08-09 20:52:40 +00:00
2008-10-08 14:47:01 +00:00
def testChangeListSortingCallable ( self ) :
"""
2009-03-10 11:19:26 +00:00
Ensure we can sort on a list_display field that is a callable
2008-10-08 14:47:01 +00:00
( column 2 is callable_year in ArticleAdmin )
"""
2011-06-02 16:18:47 +00:00
response = self . client . get ( ' /test_admin/ %s /admin_views/article/ ' % self . urlbit , { ' o ' : 2 } )
2012-08-14 12:36:11 +00:00
self . assertContentBefore ( response , ' Oldest content ' , ' Middle content ' ,
" Results of sorting on callable are out of order. " )
self . assertContentBefore ( response , ' Middle content ' , ' Newest content ' ,
" Results of sorting on callable are out of order. " )
2009-03-10 11:19:26 +00:00
2008-10-08 14:47:01 +00:00
def testChangeListSortingModel ( self ) :
"""
2009-03-10 11:19:26 +00:00
Ensure we can sort on a list_display field that is a Model method
2008-10-08 14:47:01 +00:00
( colunn 3 is ' model_year ' in ArticleAdmin )
"""
2011-06-02 16:18:47 +00:00
response = self . client . get ( ' /test_admin/ %s /admin_views/article/ ' % self . urlbit , { ' o ' : ' -3 ' } )
2012-08-14 12:36:11 +00:00
self . assertContentBefore ( response , ' Newest content ' , ' Middle content ' ,
" Results of sorting on Model method are out of order. " )
self . assertContentBefore ( response , ' Middle content ' , ' Oldest content ' ,
" Results of sorting on Model method are out of order. " )
2009-03-10 11:19:26 +00:00
2008-10-08 14:47:01 +00:00
def testChangeListSortingModelAdmin ( self ) :
"""
2009-03-10 11:19:26 +00:00
Ensure we can sort on a list_display field that is a ModelAdmin method
2008-10-08 14:47:01 +00:00
( colunn 4 is ' modeladmin_year ' in ArticleAdmin )
"""
2011-06-02 16:18:47 +00:00
response = self . client . get ( ' /test_admin/ %s /admin_views/article/ ' % self . urlbit , { ' o ' : ' 4 ' } )
2012-08-14 12:36:11 +00:00
self . assertContentBefore ( response , ' Oldest content ' , ' Middle content ' ,
" Results of sorting on ModelAdmin method are out of order. " )
self . assertContentBefore ( response , ' Middle content ' , ' Newest content ' ,
" Results of sorting on ModelAdmin method are out of order. " )
2009-03-10 11:19:26 +00:00
2011-06-02 16:18:47 +00:00
def testChangeListSortingMultiple ( self ) :
p1 = Person . objects . create ( name = " Chris " , gender = 1 , alive = True )
p2 = Person . objects . create ( name = " Chris " , gender = 2 , alive = True )
p3 = Person . objects . create ( name = " Bob " , gender = 1 , alive = True )
2012-09-25 01:02:59 +00:00
link1 = reverse ( ' admin:admin_views_person_change ' , args = ( p1 . pk , ) )
link2 = reverse ( ' admin:admin_views_person_change ' , args = ( p2 . pk , ) )
link3 = reverse ( ' admin:admin_views_person_change ' , args = ( p3 . pk , ) )
2011-06-02 16:18:47 +00:00
# Sort by name, gender
# This hard-codes the URL because it'll fail if it runs against the
# 'admin2' custom admin (which doesn't have the Person model).
response = self . client . get ( ' /test_admin/admin/admin_views/person/ ' , { ' o ' : ' 1.2 ' } )
2012-09-25 01:02:59 +00:00
self . assertContentBefore ( response , link3 , link1 )
self . assertContentBefore ( response , link1 , link2 )
2011-06-02 16:18:47 +00:00
# Sort by gender descending, name
response = self . client . get ( ' /test_admin/admin/admin_views/person/ ' , { ' o ' : ' -2.1 ' } )
2012-09-25 01:02:59 +00:00
self . assertContentBefore ( response , link2 , link3 )
self . assertContentBefore ( response , link3 , link1 )
2011-06-02 16:18:47 +00:00
def testChangeListSortingPreserveQuerySetOrdering ( self ) :
2012-03-03 02:13:35 +00:00
"""
If no ordering is defined in ` ModelAdmin . ordering ` or in the query
string , then the underlying order of the queryset should not be
2013-03-08 14:15:23 +00:00
changed , even if it is defined in ` Modeladmin . get_queryset ( ) ` .
2012-03-03 02:13:35 +00:00
Refs #11868, #7309.
"""
2011-06-02 16:18:47 +00:00
p1 = Person . objects . create ( name = " Amy " , gender = 1 , alive = True , age = 80 )
p2 = Person . objects . create ( name = " Bob " , gender = 1 , alive = True , age = 70 )
p3 = Person . objects . create ( name = " Chris " , gender = 2 , alive = False , age = 60 )
2012-09-25 01:02:59 +00:00
link1 = reverse ( ' admin:admin_views_person_change ' , args = ( p1 . pk , ) )
link2 = reverse ( ' admin:admin_views_person_change ' , args = ( p2 . pk , ) )
link3 = reverse ( ' admin:admin_views_person_change ' , args = ( p3 . pk , ) )
2011-06-02 16:18:47 +00:00
# This hard-codes the URL because it'll fail if it runs against the
# 'admin2' custom admin (which doesn't have the Person model).
response = self . client . get ( ' /test_admin/admin/admin_views/person/ ' , { } )
2012-09-25 01:02:59 +00:00
self . assertContentBefore ( response , link3 , link2 )
self . assertContentBefore ( response , link2 , link1 )
2011-06-02 16:18:47 +00:00
def testChangeListSortingModelMeta ( self ) :
# Test ordering on Model Meta is respected
l1 = Language . objects . create ( iso = ' ur ' , name = ' Urdu ' )
l2 = Language . objects . create ( iso = ' ar ' , name = ' Arabic ' )
2012-09-25 01:02:59 +00:00
link1 = reverse ( ' admin:admin_views_language_change ' , args = ( quote ( l1 . pk ) , ) )
link2 = reverse ( ' admin:admin_views_language_change ' , args = ( quote ( l2 . pk ) , ) )
2011-06-02 16:18:47 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/language/ ' , { } )
2012-09-25 01:02:59 +00:00
self . assertContentBefore ( response , link2 , link1 )
2011-06-02 16:18:47 +00:00
# Test we can override with query string
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
response = self . client . get ( ' /test_admin/admin/admin_views/language/ ' , { ' o ' : ' -1 ' } )
2012-09-25 01:02:59 +00:00
self . assertContentBefore ( response , link1 , link2 )
2011-06-02 16:18:47 +00:00
2011-09-20 18:16:49 +00:00
def testChangeListSortingOverrideModelAdmin ( self ) :
2011-06-02 16:18:47 +00:00
# Test ordering on Model Admin is respected, and overrides Model Meta
dt = datetime . datetime . now ( )
p1 = Podcast . objects . create ( name = " A " , release_date = dt )
p2 = Podcast . objects . create ( name = " B " , release_date = dt - datetime . timedelta ( 10 ) )
2012-09-25 01:02:59 +00:00
link1 = reverse ( ' admin:admin_views_podcast_change ' , args = ( p1 . pk , ) )
link2 = reverse ( ' admin:admin_views_podcast_change ' , args = ( p2 . pk , ) )
2011-06-02 16:18:47 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/podcast/ ' , { } )
2012-09-25 01:02:59 +00:00
self . assertContentBefore ( response , link1 , link2 )
2011-06-02 16:18:47 +00:00
2011-06-03 11:54:29 +00:00
def testMultipleSortSameField ( self ) :
# Check that we get the columns we expect if we have two columns
# that correspond to the same ordering field
dt = datetime . datetime . now ( )
p1 = Podcast . objects . create ( name = " A " , release_date = dt )
p2 = Podcast . objects . create ( name = " B " , release_date = dt - datetime . timedelta ( 10 ) )
2012-09-25 01:02:59 +00:00
link1 = reverse ( ' admin:admin_views_podcast_change ' , args = ( quote ( p1 . pk ) , ) )
link2 = reverse ( ' admin:admin_views_podcast_change ' , args = ( quote ( p2 . pk ) , ) )
2011-06-03 11:54:29 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/podcast/ ' , { } )
2012-09-25 01:02:59 +00:00
self . assertContentBefore ( response , link1 , link2 )
2011-06-03 11:54:29 +00:00
p1 = ComplexSortedPerson . objects . create ( name = " Bob " , age = 10 )
p2 = ComplexSortedPerson . objects . create ( name = " Amy " , age = 20 )
2012-09-25 01:02:59 +00:00
link1 = reverse ( ' admin:admin_views_complexsortedperson_change ' , args = ( p1 . pk , ) )
link2 = reverse ( ' admin:admin_views_complexsortedperson_change ' , args = ( p2 . pk , ) )
2011-06-03 11:54:29 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/complexsortedperson/ ' , { } )
# Should have 5 columns (including action checkbox col)
self . assertContains ( response , ' <th scope= " col " ' , count = 5 )
self . assertContains ( response , ' Name ' )
self . assertContains ( response , ' Colored name ' )
# Check order
2012-08-14 12:36:11 +00:00
self . assertContentBefore ( response , ' Name ' , ' Colored name ' )
2011-06-03 11:54:29 +00:00
# Check sorting - should be by name
2012-09-25 01:02:59 +00:00
self . assertContentBefore ( response , link2 , link1 )
2011-06-03 11:54:29 +00:00
2011-11-22 09:14:09 +00:00
def testSortIndicatorsAdminOrder ( self ) :
"""
Ensures that the admin shows default sort indicators for all
kinds of ' ordering ' fields : field names , method on the model
admin and model itself , and other callables . See #17252.
"""
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
models = [ ( AdminOrderedField , ' adminorderedfield ' ) ,
2011-11-22 09:14:09 +00:00
( AdminOrderedModelMethod , ' adminorderedmodelmethod ' ) ,
( AdminOrderedAdminMethod , ' adminorderedadminmethod ' ) ,
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
( AdminOrderedCallable , ' adminorderedcallable ' ) ]
2011-11-22 09:14:09 +00:00
for model , url in models :
2013-09-08 15:05:16 +00:00
model . objects . create ( stuff = ' The Last Item ' , order = 3 )
model . objects . create ( stuff = ' The First Item ' , order = 1 )
model . objects . create ( stuff = ' The Middle Item ' , order = 2 )
2011-11-22 09:14:09 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/ %s / ' % url , { } )
self . assertEqual ( response . status_code , 200 )
# Should have 3 columns including action checkbox col.
self . assertContains ( response , ' <th scope= " col " ' , count = 3 , msg_prefix = url )
# Check if the correct column was selected. 2 is the index of the
# 'order' column in the model admin's 'list_display' with 0 being
# the implicit 'action_checkbox' and 1 being the column 'stuff'.
self . assertEqual ( response . context [ ' cl ' ] . get_ordering_field_columns ( ) , { 2 : ' asc ' } )
# Check order of records.
2012-08-14 12:36:11 +00:00
self . assertContentBefore ( response , ' The First Item ' , ' The Middle Item ' )
self . assertContentBefore ( response , ' The Middle Item ' , ' The Last Item ' )
2011-11-22 09:14:09 +00:00
2008-10-21 19:03:21 +00:00
def testLimitedFilter ( self ) :
2010-11-21 19:29:15 +00:00
""" Ensure admin changelist filters do not contain objects excluded via limit_choices_to.
This also tests relation - spanning filters ( e . g . ' color__value ' ) .
"""
2009-01-14 20:22:25 +00:00
response = self . client . get ( ' /test_admin/ %s /admin_views/thing/ ' % self . urlbit )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 200 )
2012-04-14 13:35:25 +00:00
self . assertContains ( response , ' <div id= " changelist-filter " > ' ,
msg_prefix = " Expected filter not found in changelist view "
2008-10-21 19:03:21 +00:00
)
2012-04-14 13:35:25 +00:00
self . assertNotContains ( response , ' <a href= " ?color__id__exact=3 " >Blue</a> ' ,
msg_prefix = " Changelist filter not correctly limited by limit_choices_to "
2008-10-21 19:03:21 +00:00
)
2009-03-10 11:19:26 +00:00
2010-11-21 19:29:15 +00:00
def testRelationSpanningFilters ( self ) :
response = self . client . get ( ' /test_admin/ %s /admin_views/chapterxtra1/ ' %
self . urlbit )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 200 )
2010-11-21 19:29:15 +00:00
self . assertContains ( response , ' <div id= " changelist-filter " > ' )
filters = {
' chap__id__exact ' : dict (
values = [ c . id for c in Chapter . objects . all ( ) ] ,
test = lambda obj , value : obj . chap . id == value ) ,
' chap__title ' : dict (
values = [ c . title for c in Chapter . objects . all ( ) ] ,
test = lambda obj , value : obj . chap . title == value ) ,
' chap__book__id__exact ' : dict (
values = [ b . id for b in Book . objects . all ( ) ] ,
test = lambda obj , value : obj . chap . book . id == value ) ,
' chap__book__name ' : dict (
values = [ b . name for b in Book . objects . all ( ) ] ,
test = lambda obj , value : obj . chap . book . name == value ) ,
' chap__book__promo__id__exact ' : dict (
values = [ p . id for p in Promo . objects . all ( ) ] ,
2013-10-19 23:33:10 +00:00
test = lambda obj , value : obj . chap . book . promo_set . filter ( id = value ) . exists ( ) ) ,
2010-11-21 19:29:15 +00:00
' chap__book__promo__name ' : dict (
values = [ p . name for p in Promo . objects . all ( ) ] ,
2013-10-19 23:33:10 +00:00
test = lambda obj , value : obj . chap . book . promo_set . filter ( name = value ) . exists ( ) ) ,
2013-10-18 09:02:43 +00:00
}
2010-11-21 19:29:15 +00:00
for filter_path , params in filters . items ( ) :
for value in params [ ' values ' ] :
query_string = urlencode ( { filter_path : value } )
# ensure filter link exists
self . assertContains ( response , ' <a href= " ? %s " > ' % query_string )
# ensure link works
filtered_response = self . client . get (
' /test_admin/ %s /admin_views/chapterxtra1/? %s ' % (
self . urlbit , query_string ) )
2010-12-04 07:28:12 +00:00
self . assertEqual ( filtered_response . status_code , 200 )
2010-11-21 19:29:15 +00:00
# ensure changelist contains only valid objects
2013-03-08 14:15:23 +00:00
for obj in filtered_response . context [ ' cl ' ] . queryset . all ( ) :
2010-11-21 19:29:15 +00:00
self . assertTrue ( params [ ' test ' ] ( obj , value ) )
2008-10-22 23:09:35 +00:00
def testIncorrectLookupParameters ( self ) :
""" Ensure incorrect lookup parameters are handled gracefully. """
2009-01-14 20:22:25 +00:00
response = self . client . get ( ' /test_admin/ %s /admin_views/thing/ ' % self . urlbit , { ' notarealfield ' : ' 5 ' } )
2009-03-10 11:19:26 +00:00
self . assertRedirects ( response , ' /test_admin/ %s /admin_views/thing/?e=1 ' % self . urlbit )
2011-08-28 07:57:56 +00:00
# Spanning relationships through an inexistant related object (Refs #16716)
response = self . client . get ( ' /test_admin/ %s /admin_views/thing/ ' % self . urlbit , { ' notarealfield__whatever ' : ' 5 ' } )
self . assertRedirects ( response , ' /test_admin/ %s /admin_views/thing/?e=1 ' % self . urlbit )
2009-01-14 20:22:25 +00:00
response = self . client . get ( ' /test_admin/ %s /admin_views/thing/ ' % self . urlbit , { ' color__id__exact ' : ' StringNotInteger! ' } )
self . assertRedirects ( response , ' /test_admin/ %s /admin_views/thing/?e=1 ' % self . urlbit )
2012-09-15 23:20:56 +00:00
# Regression test for #18530
response = self . client . get ( ' /test_admin/ %s /admin_views/thing/ ' % self . urlbit , { ' pub_date__gte ' : ' foo ' } )
self . assertRedirects ( response , ' /test_admin/ %s /admin_views/thing/?e=1 ' % self . urlbit )
2010-03-16 19:01:40 +00:00
def testIsNullLookups ( self ) :
""" Ensure is_null is handled correctly. """
Article . objects . create ( title = " I Could Go Anywhere " , content = " Versatile " , date = datetime . datetime . now ( ) )
response = self . client . get ( ' /test_admin/ %s /admin_views/article/ ' % self . urlbit )
2012-04-14 13:35:25 +00:00
self . assertContains ( response , ' 4 articles ' )
2010-03-16 19:01:40 +00:00
response = self . client . get ( ' /test_admin/ %s /admin_views/article/ ' % self . urlbit , { ' section__isnull ' : ' false ' } )
2012-04-14 13:35:25 +00:00
self . assertContains ( response , ' 3 articles ' )
2013-05-27 16:31:49 +00:00
response = self . client . get ( ' /test_admin/ %s /admin_views/article/ ' % self . urlbit , { ' section__isnull ' : ' 0 ' } )
self . assertContains ( response , ' 3 articles ' )
2010-03-16 19:01:40 +00:00
response = self . client . get ( ' /test_admin/ %s /admin_views/article/ ' % self . urlbit , { ' section__isnull ' : ' true ' } )
2012-04-14 13:35:25 +00:00
self . assertContains ( response , ' 1 article ' )
2013-05-27 16:31:49 +00:00
response = self . client . get ( ' /test_admin/ %s /admin_views/article/ ' % self . urlbit , { ' section__isnull ' : ' 1 ' } )
self . assertContains ( response , ' 1 article ' )
2010-03-16 19:01:40 +00:00
2009-07-16 16:16:13 +00:00
def testLogoutAndPasswordChangeURLs ( self ) :
response = self . client . get ( ' /test_admin/ %s /admin_views/article/ ' % self . urlbit )
2012-04-14 13:35:25 +00:00
self . assertContains ( response , ' <a href= " /test_admin/ %s /logout/ " > ' % self . urlbit )
self . assertContains ( response , ' <a href= " /test_admin/ %s /password_change/ " > ' % self . urlbit )
2009-07-16 16:16:13 +00:00
2009-04-01 14:14:20 +00:00
def testNamedGroupFieldChoicesChangeList ( self ) :
"""
Ensures the admin changelist shows correct values in the relevant column
for rows corresponding to instances of a model in which a named group
has been used in the choices option of a field .
"""
2012-09-25 01:02:59 +00:00
link1 = reverse ( ' admin:admin_views_fabric_change ' , args = ( 1 , ) , current_app = self . urlbit )
link2 = reverse ( ' admin:admin_views_fabric_change ' , args = ( 2 , ) , current_app = self . urlbit )
2009-04-01 14:14:20 +00:00
response = self . client . get ( ' /test_admin/ %s /admin_views/fabric/ ' % self . urlbit )
2012-08-14 12:36:11 +00:00
fail_msg = " Changelist table isn ' t showing the right human-readable values set by a model field ' choices ' option named group. "
2012-09-25 01:02:59 +00:00
self . assertContains ( response , ' <a href= " %s " >Horizontal</a> ' % link1 , msg_prefix = fail_msg , html = True )
self . assertContains ( response , ' <a href= " %s " >Vertical</a> ' % link2 , msg_prefix = fail_msg , html = True )
2009-04-01 14:14:20 +00:00
def testNamedGroupFieldChoicesFilter ( self ) :
"""
Ensures the filter UI shows correctly when at least one named group has
been used in the choices option of a model field .
"""
response = self . client . get ( ' /test_admin/ %s /admin_views/fabric/ ' % self . urlbit )
2012-08-14 12:36:11 +00:00
fail_msg = " Changelist filter isn ' t showing options contained inside a model field ' choices ' option named group. "
2012-04-14 13:35:25 +00:00
self . assertContains ( response , ' <div id= " changelist-filter " > ' )
2012-08-14 12:36:11 +00:00
self . assertContains ( response ,
' <a href= " ?surface__exact=x " >Horizontal</a> ' , msg_prefix = fail_msg , html = True )
self . assertContains ( response ,
' <a href= " ?surface__exact=y " >Vertical</a> ' , msg_prefix = fail_msg , html = True )
2009-04-01 14:14:20 +00:00
2010-03-10 08:37:17 +00:00
def testChangeListNullBooleanDisplay ( self ) :
Post . objects . create ( public = None )
# This hard-codes the URl because it'll fail if it runs
# against the 'admin2' custom admin (which doesn't have the
# Post model).
response = self . client . get ( " /test_admin/admin/admin_views/post/ " )
2012-04-14 13:35:25 +00:00
self . assertContains ( response , ' icon-unknown.gif ' )
2010-03-10 08:37:17 +00:00
2010-05-02 19:46:31 +00:00
def testI18NLanguageNonEnglishDefault ( self ) :
"""
2012-03-02 17:16:52 +00:00
Check if the JavaScript i18n view returns an empty language catalog
2010-05-02 19:46:31 +00:00
if the default language is non - English but the selected language
is English . See #13388 and #3594 for more details.
"""
2013-08-16 18:12:10 +00:00
with self . settings ( LANGUAGE_CODE = ' fr ' ) , translation . override ( ' en-us ' ) :
response = self . client . get ( ' /test_admin/admin/jsi18n/ ' )
self . assertNotContains ( response , ' Choisir une heure ' )
2010-05-02 19:46:31 +00:00
def testI18NLanguageNonEnglishFallback ( self ) :
"""
Makes sure that the fallback language is still working properly
in cases where the selected language cannot be found .
"""
2013-08-16 18:12:10 +00:00
with self . settings ( LANGUAGE_CODE = ' fr ' ) , translation . override ( ' none ' ) :
response = self . client . get ( ' /test_admin/admin/jsi18n/ ' )
self . assertContains ( response , ' Choisir une heure ' )
2011-02-04 13:52:36 +00:00
def testL10NDeactivated ( self ) :
"""
2012-03-02 17:16:52 +00:00
Check if L10N is deactivated , the JavaScript i18n view doesn ' t
2011-02-04 13:52:36 +00:00
return localized date / time formats . Refs #14824.
"""
2013-08-16 18:12:10 +00:00
with self . settings ( LANGUAGE_CODE = ' ru ' , USE_L10N = False ) , translation . override ( ' none ' ) :
response = self . client . get ( ' /test_admin/admin/jsi18n/ ' )
self . assertNotContains ( response , ' %d . % m. % Y % H: % M: % S ' )
self . assertContains ( response , ' % Y- % m- %d % H: % M: % S ' )
2010-05-02 19:46:31 +00:00
2010-12-23 03:44:38 +00:00
def test_disallowed_filtering ( self ) :
2013-05-15 23:14:28 +00:00
with patch_logger ( ' django.security.DisallowedModelAdminLookup ' , ' error ' ) as calls :
response = self . client . get ( " /test_admin/admin/admin_views/album/?owner__email__startswith=fuzzy " )
self . assertEqual ( response . status_code , 400 )
self . assertEqual ( len ( calls ) , 1 )
2010-12-23 03:44:38 +00:00
2013-05-15 23:14:28 +00:00
# Filters are allowed if explicitly included in list_filter
response = self . client . get ( " /test_admin/admin/admin_views/thing/?color__value__startswith=red " )
self . assertEqual ( response . status_code , 200 )
response = self . client . get ( " /test_admin/admin/admin_views/thing/?color__value=red " )
self . assertEqual ( response . status_code , 200 )
2010-05-02 19:46:31 +00:00
2013-05-15 23:14:28 +00:00
# Filters should be allowed if they involve a local field without the
# need to whitelist them in list_filter or date_hierarchy.
response = self . client . get ( " /test_admin/admin/admin_views/person/?age__gt=30 " )
self . assertEqual ( response . status_code , 200 )
2011-01-03 13:56:31 +00:00
2011-01-12 23:30:47 +00:00
e1 = Employee . objects . create ( name = ' Anonymous ' , gender = 1 , age = 22 , alive = True , code = ' 123 ' )
e2 = Employee . objects . create ( name = ' Visitor ' , gender = 2 , age = 19 , alive = True , code = ' 124 ' )
WorkHour . objects . create ( datum = datetime . datetime . now ( ) , employee = e1 )
WorkHour . objects . create ( datum = datetime . datetime . now ( ) , employee = e2 )
response = self . client . get ( " /test_admin/admin/admin_views/workhour/ " )
self . assertEqual ( response . status_code , 200 )
self . assertContains ( response , ' employee__person_ptr__exact ' )
response = self . client . get ( " /test_admin/admin/admin_views/workhour/?employee__person_ptr__exact= %d " % e1 . pk )
self . assertEqual ( response . status_code , 200 )
2011-01-28 14:08:25 +00:00
def test_allowed_filtering_15103 ( self ) :
"""
Regressions test for ticket 15103 - filtering on fields defined in a
ForeignKey ' limit_choices_to ' should be allowed , otherwise raw_id_fields
can break .
"""
2013-05-15 23:14:28 +00:00
# Filters should be allowed if they are defined on a ForeignKey pointing to this model
response = self . client . get ( " /test_admin/admin/admin_views/inquisition/?leader__name=Palin&leader__age=27 " )
self . assertEqual ( response . status_code , 200 )
2011-01-28 14:08:25 +00:00
2013-06-27 23:39:20 +00:00
def test_popup_dismiss_related ( self ) :
"""
Regression test for ticket 20664 - ensure the pk is properly quoted .
"""
actor = Actor . objects . create ( name = " Palin " , age = 27 )
response = self . client . get ( " /test_admin/admin/admin_views/actor/? %s " % IS_POPUP_VAR )
self . assertContains ( response , " opener.dismissRelatedLookupPopup(window, ' %s ') " % actor . pk )
2012-04-29 11:56:22 +00:00
def test_hide_change_password ( self ) :
"""
Tests if the " change password " link in the admin is hidden if the User
does not have a usable password set .
( against 9 bea85795705d015cdadc82c68b99196a8554f5c )
"""
user = User . objects . get ( username = ' super ' )
user . set_unusable_password ( )
user . save ( )
response = self . client . get ( ' /test_admin/admin/ ' )
2012-08-14 12:36:11 +00:00
self . assertNotContains ( response , reverse ( ' admin:password_change ' ) ,
msg_prefix = ' The " change password " link should not be displayed if a user does not have a usable password. ' )
2012-04-29 11:56:22 +00:00
2012-07-22 01:10:24 +00:00
def test_change_view_with_show_delete_extra_context ( self ) :
"""
Ensured that the ' show_delete ' context variable in the admin ' s change
view actually controls the display of the delete button .
Refs #10057.
"""
instance = UndeletableObject . objects . create ( name = ' foo ' )
response = self . client . get ( ' /test_admin/ %s /admin_views/undeletableobject/ %d / ' %
( self . urlbit , instance . pk ) )
self . assertNotContains ( response , ' deletelink ' )
2012-02-05 10:26:05 +00:00
2012-09-08 15:18:08 +00:00
def test_allows_attributeerror_to_bubble_up ( self ) :
"""
Ensure that AttributeErrors are allowed to bubble when raised inside
a change list view .
Requires a model to be created so there ' s something to be displayed
Refs : #16655, #18593, and #18747
"""
Simple . objects . create ( )
with self . assertRaises ( AttributeError ) :
self . client . get ( ' /test_admin/ %s /admin_views/simple/ ' % self . urlbit )
2013-08-21 16:22:22 +00:00
def test_changelist_with_no_change_url ( self ) :
"""
ModelAdmin . changelist_view shouldn ' t result in a NoReverseMatch if url
for change_view is removed from get_urls
Regression test for #20934
"""
UnchangeableObject . objects . create ( )
response = self . client . get ( ' /test_admin/admin/admin_views/unchangeableobject/ ' )
self . assertEqual ( response . status_code , 200 )
# Check the format of the shown object -- shouldn't contain a change link
self . assertContains ( response , ' <th class= " field-__str__ " >UnchangeableObject object</th> ' , html = True )
2013-09-07 13:20:04 +00:00
def test_invalid_appindex_url ( self ) :
"""
#21056 -- URL reversing shouldn't work for nonexistent apps.
"""
good_url = ' /test_admin/admin/admin_views/ '
confirm_good_url = reverse ( ' admin:app_list ' ,
kwargs = { ' app_label ' : ' admin_views ' } )
self . assertEqual ( good_url , confirm_good_url )
with self . assertRaises ( NoReverseMatch ) :
reverse ( ' admin:app_list ' , kwargs = { ' app_label ' : ' this_should_fail ' } )
with self . assertRaises ( NoReverseMatch ) :
reverse ( ' admin:app_list ' , args = ( ' admin_views2 ' , ) )
2012-09-08 15:18:08 +00:00
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2012-02-09 18:56:32 +00:00
class AdminViewFormUrlTest ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2012-02-09 18:56:32 +00:00
fixtures = [ " admin-views-users.xml " ]
urlbit = " admin3 "
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
def testChangeFormUrlHasCorrectValue ( self ) :
"""
2012-08-14 12:36:11 +00:00
Tests whether change_view has form_url in response . context
2012-02-09 18:56:32 +00:00
"""
response = self . client . get ( ' /test_admin/ %s /admin_views/section/1/ ' % self . urlbit )
self . assertTrue ( ' form_url ' in response . context , msg = ' form_url not present in response.context ' )
self . assertEqual ( response . context [ ' form_url ' ] , ' pony ' )
2012-02-09 18:59:05 +00:00
def test_filter_with_custom_template ( self ) :
"""
Ensure that one can use a custom template to render an admin filter .
Refs #17515.
"""
template_dirs = settings . TEMPLATE_DIRS + (
2012-12-08 10:13:52 +00:00
os . path . join ( os . path . dirname ( upath ( __file__ ) ) , ' templates ' ) , )
2012-02-09 18:59:05 +00:00
with self . settings ( TEMPLATE_DIRS = template_dirs ) :
response = self . client . get ( " /test_admin/admin/admin_views/color2/ " )
2013-04-10 08:16:15 +00:00
self . assertTemplateUsed ( response , ' custom_filter_template.html ' )
2012-02-09 18:59:05 +00:00
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2012-02-27 13:29:56 +00:00
class AdminJavaScriptTest ( TestCase ) :
fixtures = [ ' admin-views-users.xml ' ]
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2011-09-20 18:16:49 +00:00
2012-02-27 13:29:56 +00:00
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
2012-02-05 10:26:05 +00:00
def test_js_minified_only_if_debug_is_false ( self ) :
"""
Ensure that the minified versions of the JS files are only used when
DEBUG is False .
Refs #17521.
"""
with override_settings ( DEBUG = False ) :
response = self . client . get (
2012-02-27 13:29:56 +00:00
' /test_admin/ %s /admin_views/section/add/ ' % ' admin ' )
2012-02-05 10:26:05 +00:00
self . assertNotContains ( response , ' jquery.js ' )
self . assertContains ( response , ' jquery.min.js ' )
self . assertNotContains ( response , ' prepopulate.js ' )
self . assertContains ( response , ' prepopulate.min.js ' )
self . assertNotContains ( response , ' actions.js ' )
self . assertContains ( response , ' actions.min.js ' )
self . assertNotContains ( response , ' collapse.js ' )
self . assertContains ( response , ' collapse.min.js ' )
self . assertNotContains ( response , ' inlines.js ' )
self . assertContains ( response , ' inlines.min.js ' )
with override_settings ( DEBUG = True ) :
response = self . client . get (
2012-02-27 13:29:56 +00:00
' /test_admin/ %s /admin_views/section/add/ ' % ' admin ' )
2012-02-05 10:26:05 +00:00
self . assertContains ( response , ' jquery.js ' )
self . assertNotContains ( response , ' jquery.min.js ' )
self . assertContains ( response , ' prepopulate.js ' )
self . assertNotContains ( response , ' prepopulate.min.js ' )
self . assertContains ( response , ' actions.js ' )
self . assertNotContains ( response , ' actions.min.js ' )
self . assertContains ( response , ' collapse.js ' )
self . assertNotContains ( response , ' collapse.min.js ' )
self . assertContains ( response , ' inlines.js ' )
self . assertNotContains ( response , ' inlines.min.js ' )
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2009-05-08 12:53:14 +00:00
class SaveAsTests ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
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
fixtures = [ ' admin-views-users.xml ' , ' admin-views-person.xml ' ]
2009-05-09 11:40:13 +00:00
2009-05-08 12:53:14 +00:00
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
2009-05-09 11:40:13 +00:00
2009-05-08 12:53:14 +00:00
def test_save_as_duplication ( self ) :
""" Ensure save as actually creates a new person """
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
post_data = { ' _saveasnew ' : ' ' , ' name ' : ' John M ' , ' gender ' : 1 , ' age ' : 42 }
2013-09-08 15:05:16 +00:00
self . client . post ( ' /test_admin/admin/admin_views/person/1/ ' , post_data )
2009-05-08 12:53:14 +00:00
self . assertEqual ( len ( Person . objects . filter ( name = ' John M ' ) ) , 1 )
self . assertEqual ( len ( Person . objects . filter ( id = 1 ) ) , 1 )
2009-05-09 11:40:13 +00:00
2009-05-08 12:53:14 +00:00
def test_save_as_display ( self ) :
"""
Ensure that ' save as ' is displayed when activated and after submitting
invalid data aside save_as_new will not show us a form to overwrite the
initial model .
"""
response = self . client . get ( ' /test_admin/admin/admin_views/person/1/ ' )
2011-03-03 15:04:39 +00:00
self . assertTrue ( response . context [ ' save_as ' ] )
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
post_data = { ' _saveasnew ' : ' ' , ' name ' : ' John M ' , ' gender ' : 3 , ' alive ' : ' checked ' }
2009-05-08 12:53:14 +00:00
response = self . client . post ( ' /test_admin/admin/admin_views/person/1/ ' , post_data )
2011-09-20 18:30:06 +00:00
self . assertEqual ( response . context [ ' form_url ' ] , ' /test_admin/admin/admin_views/person/add/ ' )
2009-05-08 12:53:14 +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
2013-06-28 00:13:42 +00:00
class CustomModelAdminTest ( AdminViewBasicTestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2009-01-14 20:22:25 +00:00
urlbit = " admin2 "
2010-12-02 00:44:35 +00:00
def testCustomAdminSiteLoginForm ( self ) :
self . client . logout ( )
2011-04-22 18:17:16 +00:00
response = self . client . get ( ' /test_admin/admin2/ ' )
self . assertIsInstance ( response , TemplateResponse )
self . assertEqual ( response . status_code , 200 )
2010-12-02 00:44:35 +00:00
login = self . client . post ( ' /test_admin/admin2/ ' , {
REDIRECT_FIELD_NAME : ' /test_admin/admin2/ ' ,
LOGIN_FORM_KEY : 1 ,
' username ' : ' customform ' ,
' password ' : ' secret ' ,
} )
2011-04-22 18:17:16 +00:00
self . assertIsInstance ( login , TemplateResponse )
2010-12-04 07:28:12 +00:00
self . assertEqual ( login . status_code , 200 )
2010-12-02 00:44:35 +00:00
self . assertContains ( login , ' custom form error ' )
2009-01-14 20:22:25 +00:00
def testCustomAdminSiteLoginTemplate ( self ) :
self . client . logout ( )
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin2/ ' )
self . assertIsInstance ( response , TemplateResponse )
self . assertTemplateUsed ( response , ' custom_admin/login.html ' )
self . assertContains ( response , ' Hello from a custom login template ' )
2009-01-14 20:22:25 +00:00
2010-01-12 23:34:46 +00:00
def testCustomAdminSiteLogoutTemplate ( self ) :
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin2/logout/ ' )
self . assertIsInstance ( response , TemplateResponse )
self . assertTemplateUsed ( response , ' custom_admin/logout.html ' )
self . assertContains ( response , ' Hello from a custom logout template ' )
2010-01-12 23:34:46 +00:00
2009-01-14 20:22:25 +00:00
def testCustomAdminSiteIndexViewAndTemplate ( self ) :
2012-12-03 23:39:03 +00:00
try :
response = self . client . get ( ' /test_admin/admin2/ ' )
except TypeError :
self . fail ( ' AdminSite.index_template should accept a list of template paths ' )
2012-08-14 12:36:11 +00:00
self . assertIsInstance ( response , TemplateResponse )
self . assertTemplateUsed ( response , ' custom_admin/index.html ' )
self . assertContains ( response , ' Hello from a custom index template *bar* ' )
2009-03-10 11:19:26 +00:00
2013-07-31 06:37:54 +00:00
def testCustomAdminSiteAppIndexViewandTemplate ( self ) :
response = self . client . get ( ' /test_admin/admin2/admin_views/ ' )
self . assertIsInstance ( response , TemplateResponse )
self . assertTemplateUsed ( response , ' custom_admin/app_index.html ' )
self . assertContains ( response , ' Hello from a custom app_index template ' )
2010-01-12 23:34:46 +00:00
def testCustomAdminSitePasswordChangeTemplate ( self ) :
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin2/password_change/ ' )
self . assertIsInstance ( response , TemplateResponse )
self . assertTemplateUsed ( response , ' custom_admin/password_change_form.html ' )
self . assertContains ( response , ' Hello from a custom password change form template ' )
2010-01-12 23:34:46 +00:00
def testCustomAdminSitePasswordChangeDoneTemplate ( self ) :
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin2/password_change/done/ ' )
self . assertIsInstance ( response , TemplateResponse )
self . assertTemplateUsed ( response , ' custom_admin/password_change_done.html ' )
self . assertContains ( response , ' Hello from a custom password change done template ' )
2010-01-12 23:34:46 +00:00
2009-01-14 20:22:25 +00:00
def testCustomAdminSiteView ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
response = self . client . get ( ' /test_admin/ %s /my_view/ ' % self . urlbit )
2012-08-14 09:57:18 +00:00
self . assertEqual ( response . content , b " Django is a magical pony! " )
2009-01-14 20:22:25 +00:00
2012-12-03 23:39:03 +00:00
def test_pwd_change_custom_template ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
su = User . objects . get ( username = ' super ' )
try :
response = self . client . get ( ' /test_admin/admin4/auth/user/ %s /password/ ' % su . pk )
except TypeError :
self . fail ( ' ModelAdmin.change_user_password_template should accept a list of template paths ' )
self . assertEqual ( response . status_code , 200 )
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
2008-07-18 23:54:34 +00:00
def get_perm ( Model , perm ) :
""" Return the permission object, for the Model """
ct = ContentType . objects . get_for_model ( Model )
2008-08-09 20:52:40 +00:00
return Permission . objects . get ( content_type = ct , codename = perm )
2008-07-18 23:54:34 +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
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2008-07-18 23:54:34 +00:00
class AdminViewPermissionsTest ( TestCase ) :
""" Tests for Admin Views Permissions. """
2008-08-08 18:07:33 +00:00
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2008-07-18 23:54:34 +00:00
fixtures = [ ' admin-views-users.xml ' ]
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
def setUp ( self ) :
""" Test setup. """
2008-08-08 18:07:33 +00:00
# Setup permissions, for our users who can add, change, and delete.
2008-07-18 23:54:34 +00:00
# We can't put this into the fixture, because the content type id
# and the permission id could be different on each run of the test.
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
opts = Article . _meta
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
# User who can add Articles
add_user = User . objects . get ( username = ' adduser ' )
add_user . user_permissions . add ( get_perm ( Article ,
2013-07-01 13:19:55 +00:00
get_permission_codename ( ' add ' , opts ) ) )
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
# User who can change Articles
change_user = User . objects . get ( username = ' changeuser ' )
change_user . user_permissions . add ( get_perm ( Article ,
2013-07-01 13:19:55 +00:00
get_permission_codename ( ' change ' , opts ) ) )
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
# User who can delete Articles
delete_user = User . objects . get ( username = ' deleteuser ' )
delete_user . user_permissions . add ( get_perm ( Article ,
2013-07-01 13:19:55 +00:00
get_permission_codename ( ' delete ' , opts ) ) )
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
delete_user . user_permissions . add ( get_perm ( Section ,
2013-07-01 13:19:55 +00:00
get_permission_codename ( ' delete ' , Section . _meta ) ) )
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
# login POST dicts
2008-09-02 21:10:00 +00:00
self . super_login = {
2010-12-02 00:44:35 +00:00
REDIRECT_FIELD_NAME : ' /test_admin/admin/ ' ,
LOGIN_FORM_KEY : 1 ,
' username ' : ' super ' ,
' password ' : ' secret ' ,
}
2008-09-02 21:10:00 +00:00
self . super_email_login = {
2010-12-02 00:44:35 +00:00
REDIRECT_FIELD_NAME : ' /test_admin/admin/ ' ,
LOGIN_FORM_KEY : 1 ,
' username ' : ' super@example.com ' ,
' password ' : ' secret ' ,
}
2008-09-02 21:10:00 +00:00
self . super_email_bad_login = {
2010-12-02 00:44:35 +00:00
REDIRECT_FIELD_NAME : ' /test_admin/admin/ ' ,
LOGIN_FORM_KEY : 1 ,
' username ' : ' super@example.com ' ,
' password ' : ' notsecret ' ,
}
2008-09-02 21:10:00 +00:00
self . adduser_login = {
2010-12-02 00:44:35 +00:00
REDIRECT_FIELD_NAME : ' /test_admin/admin/ ' ,
LOGIN_FORM_KEY : 1 ,
' username ' : ' adduser ' ,
' password ' : ' secret ' ,
}
2008-09-02 21:10:00 +00:00
self . changeuser_login = {
2010-12-02 00:44:35 +00:00
REDIRECT_FIELD_NAME : ' /test_admin/admin/ ' ,
LOGIN_FORM_KEY : 1 ,
' username ' : ' changeuser ' ,
' password ' : ' secret ' ,
}
2008-09-02 21:10:00 +00:00
self . deleteuser_login = {
2010-12-02 00:44:35 +00:00
REDIRECT_FIELD_NAME : ' /test_admin/admin/ ' ,
LOGIN_FORM_KEY : 1 ,
' username ' : ' deleteuser ' ,
' password ' : ' secret ' ,
}
2008-09-02 21:10:00 +00:00
self . joepublic_login = {
2010-12-02 00:44:35 +00:00
REDIRECT_FIELD_NAME : ' /test_admin/admin/ ' ,
LOGIN_FORM_KEY : 1 ,
' username ' : ' joepublic ' ,
' password ' : ' secret ' ,
}
2009-09-10 16:50:57 +00:00
self . no_username_login = {
2010-12-02 00:44:35 +00:00
REDIRECT_FIELD_NAME : ' /test_admin/admin/ ' ,
LOGIN_FORM_KEY : 1 ,
' password ' : ' secret ' ,
}
2008-07-18 23:54:34 +00:00
def testLogin ( self ) :
"""
Make sure only staff members can log in .
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
Successful posts to the login page will redirect to the orignal url .
2008-08-08 18:07:33 +00:00
Unsuccessfull attempts will continue to render the login page with
2008-07-18 23:54:34 +00:00
a 200 status code .
"""
# Super User
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/ ' )
self . assertEqual ( response . status_code , 200 )
2008-07-18 23:54:34 +00:00
login = self . client . post ( ' /test_admin/admin/ ' , self . super_login )
self . assertRedirects ( login , ' /test_admin/admin/ ' )
2010-12-04 07:28:12 +00:00
self . assertFalse ( login . context )
2008-07-18 23:54:34 +00:00
self . client . get ( ' /test_admin/admin/logout/ ' )
2008-08-08 18:07:33 +00:00
2012-09-26 12:14:51 +00:00
# Test if user enters email address
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/ ' )
self . assertEqual ( response . status_code , 200 )
2008-07-18 23:54:34 +00:00
login = self . client . post ( ' /test_admin/admin/ ' , self . super_email_login )
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
self . assertContains ( login , ERROR_MESSAGE )
2008-07-18 23:54:34 +00:00
# only correct passwords get a username hint
login = self . client . post ( ' /test_admin/admin/ ' , self . super_email_bad_login )
2011-09-22 04:16:21 +00:00
self . assertContains ( login , ERROR_MESSAGE )
2008-07-18 23:54:34 +00:00
new_user = User ( username = ' jondoe ' , password = ' secret ' , email = ' super@example.com ' )
new_user . save ( )
2012-09-26 12:14:51 +00:00
# check to ensure if there are multiple email addresses a user doesn't get a 500
2008-07-18 23:54:34 +00:00
login = self . client . post ( ' /test_admin/admin/ ' , self . super_email_login )
2011-09-22 04:16:21 +00:00
self . assertContains ( login , ERROR_MESSAGE )
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
# Add User
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/ ' )
self . assertEqual ( response . status_code , 200 )
2008-07-18 23:54:34 +00:00
login = self . client . post ( ' /test_admin/admin/ ' , self . adduser_login )
self . assertRedirects ( login , ' /test_admin/admin/ ' )
2010-12-04 07:28:12 +00:00
self . assertFalse ( login . context )
2008-07-18 23:54:34 +00:00
self . client . get ( ' /test_admin/admin/logout/ ' )
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
# Change User
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/ ' )
self . assertEqual ( response . status_code , 200 )
2008-07-18 23:54:34 +00:00
login = self . client . post ( ' /test_admin/admin/ ' , self . changeuser_login )
self . assertRedirects ( login , ' /test_admin/admin/ ' )
2010-12-04 07:28:12 +00:00
self . assertFalse ( login . context )
2008-07-18 23:54:34 +00:00
self . client . get ( ' /test_admin/admin/logout/ ' )
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
# Delete User
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/ ' )
self . assertEqual ( response . status_code , 200 )
2008-07-18 23:54:34 +00:00
login = self . client . post ( ' /test_admin/admin/ ' , self . deleteuser_login )
self . assertRedirects ( login , ' /test_admin/admin/ ' )
2010-12-04 07:28:12 +00:00
self . assertFalse ( login . context )
2008-07-18 23:54:34 +00:00
self . client . get ( ' /test_admin/admin/logout/ ' )
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
# Regular User should not be able to login.
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/ ' )
self . assertEqual ( response . status_code , 200 )
2008-07-18 23:54:34 +00:00
login = self . client . post ( ' /test_admin/admin/ ' , self . joepublic_login )
2010-12-04 07:28:12 +00:00
self . assertEqual ( login . status_code , 200 )
2011-09-22 04:16:21 +00:00
self . assertContains ( login , ERROR_MESSAGE )
2008-07-18 23:54:34 +00:00
2009-09-10 16:50:57 +00:00
# Requests without username should not return 500 errors.
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/ ' )
self . assertEqual ( response . status_code , 200 )
2009-09-10 16:50:57 +00:00
login = self . client . post ( ' /test_admin/admin/ ' , self . no_username_login )
2010-12-04 07:28:12 +00:00
self . assertEqual ( login . status_code , 200 )
2010-12-02 00:44:35 +00:00
form = login . context [ 0 ] . get ( ' form ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( form . errors [ ' username ' ] [ 0 ] , ' This field is required. ' )
2009-09-10 16:50:57 +00:00
2008-08-09 17:35:19 +00:00
def testLoginSuccessfullyRedirectsToOriginalUrl ( self ) :
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/ ' )
self . assertEqual ( response . status_code , 200 )
2010-12-02 00:44:35 +00:00
query_string = ' the-answer=42 '
redirect_url = ' /test_admin/admin/? %s ' % query_string
new_next = { REDIRECT_FIELD_NAME : redirect_url }
login = self . client . post ( ' /test_admin/admin/ ' , dict ( self . super_login , * * new_next ) , QUERY_STRING = query_string )
self . assertRedirects ( login , redirect_url )
2008-08-09 17:35:19 +00:00
2013-03-18 23:58:33 +00:00
def testDoubleLoginIsNotAllowed ( self ) :
""" Regression test for #19327 """
response = self . client . get ( ' /test_admin/admin/ ' )
self . assertEqual ( response . status_code , 200 )
# Establish a valid admin session
login = self . client . post ( ' /test_admin/admin/ ' , self . super_login )
self . assertRedirects ( login , ' /test_admin/admin/ ' )
self . assertFalse ( login . context )
# Logging in with non-admin user fails
login = self . client . post ( ' /test_admin/admin/ ' , self . joepublic_login )
self . assertEqual ( login . status_code , 200 )
self . assertContains ( login , ERROR_MESSAGE )
# Establish a valid admin session
login = self . client . post ( ' /test_admin/admin/ ' , self . super_login )
self . assertRedirects ( login , ' /test_admin/admin/ ' )
self . assertFalse ( login . context )
# Logging in with admin user while already logged in
login = self . client . post ( ' /test_admin/admin/ ' , self . super_login )
self . assertRedirects ( login , ' /test_admin/admin/ ' )
self . assertFalse ( login . context )
self . client . get ( ' /test_admin/admin/logout/ ' )
2008-07-18 23:54:34 +00:00
def testAddView ( self ) :
""" Test add view restricts access and actually adds items. """
2008-08-08 18:07:33 +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
add_dict = { ' title ' : ' Døm ikke ' ,
2008-08-08 18:07:33 +00:00
' content ' : ' <p>great article</p> ' ,
2008-07-18 23:54:34 +00:00
' date_0 ' : ' 2008-03-18 ' , ' date_1 ' : ' 10:54:39 ' ,
' section ' : 1 }
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
# Change User should not have access to add articles
self . client . get ( ' /test_admin/admin/ ' )
self . client . post ( ' /test_admin/admin/ ' , self . changeuser_login )
2008-08-23 14:12:58 +00:00
# make sure the view removes test cookie
2010-12-04 07:28:12 +00:00
self . assertEqual ( self . client . session . test_cookie_worked ( ) , False )
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/article/add/ ' )
self . assertEqual ( response . status_code , 403 )
2008-07-18 23:54:34 +00:00
# Try POST just to make sure
post = self . client . post ( ' /test_admin/admin/admin_views/article/add/ ' , add_dict )
2010-12-04 07:28:12 +00:00
self . assertEqual ( post . status_code , 403 )
self . assertEqual ( Article . objects . all ( ) . count ( ) , 3 )
2008-07-18 23:54:34 +00:00
self . client . get ( ' /test_admin/admin/logout/ ' )
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
# Add user may login and POST to add view, then redirect to admin root
self . client . get ( ' /test_admin/admin/ ' )
self . client . post ( ' /test_admin/admin/ ' , self . adduser_login )
2008-10-24 19:14:24 +00:00
addpage = self . client . get ( ' /test_admin/admin/admin_views/article/add/ ' )
2011-09-20 18:30:06 +00:00
change_list_link = ' › <a href= " /test_admin/admin/admin_views/article/ " >Articles</a> '
2012-08-14 12:36:11 +00:00
self . assertNotContains ( addpage , change_list_link ,
msg_prefix = ' User restricted to add permission is given link to change list view in breadcrumbs. ' )
2008-07-18 23:54:34 +00:00
post = self . client . post ( ' /test_admin/admin/admin_views/article/add/ ' , add_dict )
self . assertRedirects ( post , ' /test_admin/admin/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( Article . objects . all ( ) . count ( ) , 4 )
2011-03-03 15:04:39 +00:00
self . assertEqual ( len ( mail . outbox ) , 1 )
self . assertEqual ( mail . outbox [ 0 ] . subject , ' Greetings from a created object ' )
2008-07-18 23:54:34 +00:00
self . client . get ( ' /test_admin/admin/logout/ ' )
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
# Super can add too, but is redirected to the change list view
self . client . get ( ' /test_admin/admin/ ' )
self . client . post ( ' /test_admin/admin/ ' , self . super_login )
2008-10-24 19:14:24 +00:00
addpage = self . client . get ( ' /test_admin/admin/admin_views/article/add/ ' )
2012-08-14 12:36:11 +00:00
self . assertContains ( addpage , change_list_link ,
msg_prefix = ' Unrestricted user is not given link to change list view in breadcrumbs. ' )
2008-07-18 23:54:34 +00:00
post = self . client . post ( ' /test_admin/admin/admin_views/article/add/ ' , add_dict )
self . assertRedirects ( post , ' /test_admin/admin/admin_views/article/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( Article . objects . all ( ) . count ( ) , 5 )
2008-07-18 23:54:34 +00:00
self . client . get ( ' /test_admin/admin/logout/ ' )
2008-08-08 18:07:33 +00:00
2008-08-24 06:34:18 +00:00
# 8509 - if a normal user is already logged in, it is possible
# to change user into the superuser without error
2013-09-08 15:05:16 +00:00
self . client . login ( username = ' joepublic ' , password = ' secret ' )
2008-08-24 06:34:18 +00:00
# Check and make sure that if user expires, data still persists
self . client . get ( ' /test_admin/admin/ ' )
self . client . post ( ' /test_admin/admin/ ' , self . super_login )
# make sure the view removes test cookie
2010-12-04 07:28:12 +00:00
self . assertEqual ( self . client . session . test_cookie_worked ( ) , False )
2008-08-24 06:34:18 +00:00
2008-07-18 23:54:34 +00:00
def testChangeView ( self ) :
""" Change view should restrict access and allow users to edit items. """
2008-08-08 18:07:33 +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
change_dict = { ' title ' : ' Ikke fordømt ' ,
2008-08-08 18:07:33 +00:00
' content ' : ' <p>edited article</p> ' ,
' date_0 ' : ' 2008-03-18 ' , ' date_1 ' : ' 10:54:39 ' ,
' section ' : 1 }
2008-07-18 23:54:34 +00:00
# add user shoud not be able to view the list of article or change any of them
self . client . get ( ' /test_admin/admin/ ' )
self . client . post ( ' /test_admin/admin/ ' , self . adduser_login )
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/article/ ' )
self . assertEqual ( response . status_code , 403 )
response = self . client . get ( ' /test_admin/admin/admin_views/article/1/ ' )
self . assertEqual ( response . status_code , 403 )
2008-07-18 23:54:34 +00:00
post = self . client . post ( ' /test_admin/admin/admin_views/article/1/ ' , change_dict )
2010-12-04 07:28:12 +00:00
self . assertEqual ( post . status_code , 403 )
2008-07-18 23:54:34 +00:00
self . client . get ( ' /test_admin/admin/logout/ ' )
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
# change user can view all items and edit them
self . client . get ( ' /test_admin/admin/ ' )
self . client . post ( ' /test_admin/admin/ ' , self . changeuser_login )
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/article/ ' )
self . assertEqual ( response . status_code , 200 )
response = self . client . get ( ' /test_admin/admin/admin_views/article/1/ ' )
self . assertEqual ( response . status_code , 200 )
2008-07-18 23:54:34 +00:00
post = self . client . post ( ' /test_admin/admin/admin_views/article/1/ ' , change_dict )
self . assertRedirects ( post , ' /test_admin/admin/admin_views/article/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( Article . objects . get ( pk = 1 ) . content , ' <p>edited article</p> ' )
2009-03-10 11:19:26 +00:00
2008-11-09 18:51:28 +00:00
# one error in form should produce singular error message, multiple errors plural
change_dict [ ' title ' ] = ' '
post = self . client . post ( ' /test_admin/admin/admin_views/article/1/ ' , change_dict )
2012-06-07 16:08:47 +00:00
self . assertContains ( post , ' Please correct the error below. ' ,
msg_prefix = ' Singular error message not found in response to post with one error ' )
2008-11-09 18:51:28 +00:00
change_dict [ ' content ' ] = ' '
post = self . client . post ( ' /test_admin/admin/admin_views/article/1/ ' , change_dict )
2012-06-07 16:08:47 +00:00
self . assertContains ( post , ' Please correct the errors below. ' ,
msg_prefix = ' Plural error message not found in response to post with multiple errors ' )
2008-07-18 23:54:34 +00:00
self . client . get ( ' /test_admin/admin/logout/ ' )
2011-02-19 14:05:07 +00:00
# Test redirection when using row-level change permissions. Refs #11513.
2011-03-09 00:39:35 +00:00
RowLevelChangePermissionModel . objects . create ( id = 1 , name = " odd id " )
RowLevelChangePermissionModel . objects . create ( id = 2 , name = " even id " )
2011-02-19 14:05:07 +00:00
for login_dict in [ self . super_login , self . changeuser_login , self . adduser_login , self . deleteuser_login ] :
self . client . post ( ' /test_admin/admin/ ' , login_dict )
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/rowlevelchangepermissionmodel/1/ ' )
self . assertEqual ( response . status_code , 403 )
response = self . client . post ( ' /test_admin/admin/admin_views/rowlevelchangepermissionmodel/1/ ' , { ' name ' : ' changed ' } )
2011-03-03 15:04:39 +00:00
self . assertEqual ( RowLevelChangePermissionModel . objects . get ( id = 1 ) . name , ' odd id ' )
2012-08-14 12:36:11 +00:00
self . assertEqual ( response . status_code , 403 )
response = self . client . get ( ' /test_admin/admin/admin_views/rowlevelchangepermissionmodel/2/ ' )
self . assertEqual ( response . status_code , 200 )
response = self . client . post ( ' /test_admin/admin/admin_views/rowlevelchangepermissionmodel/2/ ' , { ' name ' : ' changed ' } )
2011-03-03 15:04:39 +00:00
self . assertEqual ( RowLevelChangePermissionModel . objects . get ( id = 2 ) . name , ' changed ' )
2012-08-14 12:36:11 +00:00
self . assertRedirects ( response , ' /test_admin/admin/ ' )
2011-02-19 14:05:07 +00:00
self . client . get ( ' /test_admin/admin/logout/ ' )
for login_dict in [ self . joepublic_login , self . no_username_login ] :
self . client . post ( ' /test_admin/admin/ ' , login_dict )
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/rowlevelchangepermissionmodel/1/ ' )
self . assertEqual ( response . status_code , 200 )
self . assertContains ( response , ' login-form ' )
response = self . client . post ( ' /test_admin/admin/admin_views/rowlevelchangepermissionmodel/1/ ' , { ' name ' : ' changed ' } )
2011-03-03 15:04:39 +00:00
self . assertEqual ( RowLevelChangePermissionModel . objects . get ( id = 1 ) . name , ' odd id ' )
2012-08-14 12:36:11 +00:00
self . assertEqual ( response . status_code , 200 )
self . assertContains ( response , ' login-form ' )
response = self . client . get ( ' /test_admin/admin/admin_views/rowlevelchangepermissionmodel/2/ ' )
self . assertEqual ( response . status_code , 200 )
self . assertContains ( response , ' login-form ' )
response = self . client . post ( ' /test_admin/admin/admin_views/rowlevelchangepermissionmodel/2/ ' , { ' name ' : ' changed again ' } )
2011-03-03 15:04:39 +00:00
self . assertEqual ( RowLevelChangePermissionModel . objects . get ( id = 2 ) . name , ' changed ' )
2012-08-14 12:36:11 +00:00
self . assertEqual ( response . status_code , 200 )
self . assertContains ( response , ' login-form ' )
2011-02-19 14:05:07 +00:00
self . client . get ( ' /test_admin/admin/logout/ ' )
2013-02-04 23:57:59 +00:00
def testHistoryView ( self ) :
""" History view should restrict access. """
# add user shoud not be able to view the list of article or change any of them
self . client . get ( ' /test_admin/admin/ ' )
self . client . post ( ' /test_admin/admin/ ' , self . adduser_login )
response = self . client . get ( ' /test_admin/admin/admin_views/article/1/history/ ' )
self . assertEqual ( response . status_code , 403 )
self . client . get ( ' /test_admin/admin/logout/ ' )
# change user can view all items and edit them
self . client . get ( ' /test_admin/admin/ ' )
self . client . post ( ' /test_admin/admin/ ' , self . changeuser_login )
response = self . client . get ( ' /test_admin/admin/admin_views/article/1/history/ ' )
self . assertEqual ( response . status_code , 200 )
# Test redirection when using row-level change permissions. Refs #11513.
RowLevelChangePermissionModel . objects . create ( id = 1 , name = " odd id " )
RowLevelChangePermissionModel . objects . create ( id = 2 , name = " even id " )
for login_dict in [ self . super_login , self . changeuser_login , self . adduser_login , self . deleteuser_login ] :
self . client . post ( ' /test_admin/admin/ ' , login_dict )
response = self . client . get ( ' /test_admin/admin/admin_views/rowlevelchangepermissionmodel/1/history/ ' )
self . assertEqual ( response . status_code , 403 )
response = self . client . get ( ' /test_admin/admin/admin_views/rowlevelchangepermissionmodel/2/history/ ' )
self . assertEqual ( response . status_code , 200 )
self . client . get ( ' /test_admin/admin/logout/ ' )
for login_dict in [ self . joepublic_login , self . no_username_login ] :
self . client . post ( ' /test_admin/admin/ ' , login_dict )
response = self . client . get ( ' /test_admin/admin/admin_views/rowlevelchangepermissionmodel/1/history/ ' )
self . assertEqual ( response . status_code , 200 )
self . assertContains ( response , ' login-form ' )
response = self . client . get ( ' /test_admin/admin/admin_views/rowlevelchangepermissionmodel/2/history/ ' )
self . assertEqual ( response . status_code , 200 )
self . assertContains ( response , ' login-form ' )
self . client . get ( ' /test_admin/admin/logout/ ' )
2010-09-10 16:56:36 +00:00
def testConditionallyShowAddSectionLink ( self ) :
"""
The foreign key widget should only show the " add related " button if the
user has permission to add that related item .
"""
# Set up and log in user.
url = ' /test_admin/admin/admin_views/article/add/ '
add_link_text = ' class= " add-another " '
self . client . get ( ' /test_admin/admin/ ' )
self . client . post ( ' /test_admin/admin/ ' , self . adduser_login )
# The add user can't add sections yet, so they shouldn't see the "add
# section" link.
response = self . client . get ( url )
self . assertNotContains ( response , add_link_text )
# Allow the add user to add sections too. Now they can see the "add
# section" link.
add_user = User . objects . get ( username = ' adduser ' )
2013-07-01 13:19:55 +00:00
perm = get_perm ( Section , get_permission_codename ( ' add ' , Section . _meta ) )
2010-09-10 16:56:36 +00:00
add_user . user_permissions . add ( perm )
response = self . client . get ( url )
self . assertContains ( response , add_link_text )
2008-07-18 23:54:34 +00:00
def testCustomModelAdminTemplates ( self ) :
self . client . get ( ' /test_admin/admin/ ' )
self . client . post ( ' /test_admin/admin/ ' , self . super_login )
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
# Test custom change list template with custom extra context
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/customarticle/ ' )
self . assertContains ( response , " var hello = ' Hello! ' ; " )
self . assertTemplateUsed ( response , ' custom_admin/change_list.html ' )
2008-08-08 18:07:33 +00:00
2010-01-12 23:34:03 +00:00
# Test custom add form template
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/customarticle/add/ ' )
self . assertTemplateUsed ( response , ' custom_admin/add_form.html ' )
2008-08-08 18:07:33 +00:00
2010-01-12 23:34:03 +00:00
# Add an article so we can test delete, change, and history views
2008-07-18 23:54:34 +00:00
post = self . client . post ( ' /test_admin/admin/admin_views/customarticle/add/ ' , {
' content ' : ' <p>great article</p> ' ,
' date_0 ' : ' 2008-03-18 ' ,
' date_1 ' : ' 10:54:39 '
} )
self . assertRedirects ( post , ' /test_admin/admin/admin_views/customarticle/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( CustomArticle . objects . all ( ) . count ( ) , 1 )
2011-03-09 00:39:35 +00:00
article_pk = CustomArticle . objects . all ( ) [ 0 ] . pk
2008-08-08 18:07:33 +00:00
2010-01-12 23:34:03 +00:00
# Test custom delete, change, and object history templates
# Test custom change form template
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/customarticle/ %d / ' % article_pk )
self . assertTemplateUsed ( response , ' custom_admin/change_form.html ' )
response = self . client . get ( ' /test_admin/admin/admin_views/customarticle/ %d /delete/ ' % article_pk )
self . assertTemplateUsed ( response , ' custom_admin/delete_confirmation.html ' )
response = self . client . post ( ' /test_admin/admin/admin_views/customarticle/ ' , data = {
2013-10-19 23:33:10 +00:00
' index ' : 0 ,
' action ' : [ ' delete_selected ' ] ,
' _selected_action ' : [ ' 1 ' ] ,
2013-10-18 09:02:43 +00:00
} )
2012-08-14 12:36:11 +00:00
self . assertTemplateUsed ( response , ' custom_admin/delete_selected_confirmation.html ' )
response = self . client . get ( ' /test_admin/admin/admin_views/customarticle/ %d /history/ ' % article_pk )
self . assertTemplateUsed ( response , ' custom_admin/object_history.html ' )
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
self . client . get ( ' /test_admin/admin/logout/ ' )
def testDeleteView ( self ) :
""" Delete view should restrict access and actually delete items. """
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
delete_dict = { ' post ' : ' yes ' }
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
# add user shoud not be able to delete articles
self . client . get ( ' /test_admin/admin/ ' )
self . client . post ( ' /test_admin/admin/ ' , self . adduser_login )
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/article/1/delete/ ' )
self . assertEqual ( response . status_code , 403 )
2008-07-18 23:54:34 +00:00
post = self . client . post ( ' /test_admin/admin/admin_views/article/1/delete/ ' , delete_dict )
2010-12-04 07:28:12 +00:00
self . assertEqual ( post . status_code , 403 )
self . assertEqual ( Article . objects . all ( ) . count ( ) , 3 )
2008-07-18 23:54:34 +00:00
self . client . get ( ' /test_admin/admin/logout/ ' )
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
# Delete user can delete
self . client . get ( ' /test_admin/admin/ ' )
self . client . post ( ' /test_admin/admin/ ' , self . deleteuser_login )
response = self . client . get ( ' /test_admin/admin/admin_views/section/1/delete/ ' )
# test response contains link to related Article
self . assertContains ( response , " admin_views/article/1/ " )
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/article/1/delete/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 200 )
2008-07-18 23:54:34 +00:00
post = self . client . post ( ' /test_admin/admin/admin_views/article/1/delete/ ' , delete_dict )
self . assertRedirects ( post , ' /test_admin/admin/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( Article . objects . all ( ) . count ( ) , 2 )
2011-03-03 15:04:39 +00:00
self . assertEqual ( len ( mail . outbox ) , 1 )
self . assertEqual ( mail . outbox [ 0 ] . subject , ' Greetings from a deleted object ' )
2009-05-07 13:10:59 +00:00
article_ct = ContentType . objects . get_for_model ( Article )
logged = LogEntry . objects . get ( content_type = article_ct , action_flag = DELETION )
2012-06-07 16:08:47 +00:00
self . assertEqual ( logged . object_id , ' 1 ' )
2008-07-18 23:54:34 +00:00
self . client . get ( ' /test_admin/admin/logout/ ' )
2010-01-10 16:51:13 +00:00
def testDisabledPermissionsWhenLoggedIn ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
superuser = User . objects . get ( username = ' super ' )
superuser . is_active = False
superuser . save ( )
response = self . client . get ( ' /test_admin/admin/ ' )
self . assertContains ( response , ' id= " login-form " ' )
self . assertNotContains ( response , ' Log out ' )
response = self . client . get ( ' /test_admin/admin/secure-view/ ' )
self . assertContains ( response , ' id= " login-form " ' )
2013-09-09 11:59:35 +00:00
def testDisabledStaffPermissionsWhenLoggedIn ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
superuser = User . objects . get ( username = ' super ' )
superuser . is_staff = False
superuser . save ( )
response = self . client . get ( ' /test_admin/admin/ ' )
self . assertContains ( response , ' id= " login-form " ' )
self . assertNotContains ( response , ' Log out ' )
response = self . client . get ( ' /test_admin/admin/secure-view/ ' )
self . assertContains ( response , ' id= " login-form " ' )
2013-09-07 12:32:12 +00:00
def testAppIndexFailEarly ( self ) :
"""
If a user has no module perms , avoid iterating over all the modeladmins
in the registry .
"""
opts = Article . _meta
change_user = User . objects . get ( username = ' changeuser ' )
permission = get_perm ( Article , get_permission_codename ( ' change ' , opts ) )
self . client . post ( ' /test_admin/admin/ ' , self . changeuser_login )
# the user has no module permissions, because this module doesn't exist
change_user . user_permissions . remove ( permission )
response = self . client . get ( ' /test_admin/admin/admin_views/ ' )
self . assertEqual ( response . status_code , 403 )
# the user now has module permissions
change_user . user_permissions . add ( permission )
response = self . client . get ( ' /test_admin/admin/admin_views/ ' )
self . assertEqual ( response . status_code , 200 )
2010-02-26 13:17:43 +00:00
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2011-12-19 14:59:14 +00:00
class AdminViewsNoUrlTest ( TestCase ) :
""" Regression test for #17333 """
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2011-12-19 14:59:14 +00:00
fixtures = [ ' admin-views-users.xml ' ]
def setUp ( self ) :
opts = Report . _meta
# User who can change Reports
change_user = User . objects . get ( username = ' changeuser ' )
change_user . user_permissions . add ( get_perm ( Report ,
2013-07-01 13:19:55 +00:00
get_permission_codename ( ' change ' , opts ) ) )
2011-12-19 14:59:14 +00:00
# login POST dict
self . changeuser_login = {
REDIRECT_FIELD_NAME : ' /test_admin/admin/ ' ,
LOGIN_FORM_KEY : 1 ,
' username ' : ' changeuser ' ,
' password ' : ' secret ' ,
}
def test_no_standard_modeladmin_urls ( self ) :
""" Admin index views don ' t break when user ' s ModelAdmin removes standard urls """
self . client . get ( ' /test_admin/admin/ ' )
self . client . post ( ' /test_admin/admin/ ' , self . changeuser_login )
r = self . client . get ( ' /test_admin/admin/ ' )
# we shouldn' get an 500 error caused by a NoReverseMatch
self . assertEqual ( r . status_code , 200 )
self . client . get ( ' /test_admin/admin/logout/ ' )
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2010-02-26 13:17:43 +00:00
class AdminViewDeletedObjectsTest ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2010-02-26 13:17:43 +00:00
fixtures = [ ' admin-views-users.xml ' , ' deleted-objects.xml ' ]
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
def test_nesting ( self ) :
"""
Objects should be nested to display the relationships that
cause them to be scheduled for deletion .
"""
2012-08-14 12:36:11 +00:00
pattern = re . compile ( br """ <li>Plot: <a href= " .+/admin_views/plot/1/ " >World Domination</a> \ s*<ul> \ s*<li>Plot details: <a href= " .+/admin_views/plotdetails/1/ " >almost finished</a> """ )
2010-02-26 13:17:43 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/villain/ %s /delete/ ' % quote ( 1 ) )
2013-01-26 12:47:11 +00:00
six . assertRegex ( self , response . content , pattern )
2010-02-26 13:17:43 +00:00
def test_cyclic ( self ) :
"""
Cyclic relationships should still cause each object to only be
listed once .
"""
one = """ <li>Cyclic one: <a href= " /test_admin/admin/admin_views/cyclicone/1/ " >I am recursive</a> """
two = """ <li>Cyclic two: <a href= " /test_admin/admin/admin_views/cyclictwo/1/ " >I am recursive too</a> """
response = self . client . get ( ' /test_admin/admin/admin_views/cyclicone/ %s /delete/ ' % quote ( 1 ) )
self . assertContains ( response , one , 1 )
self . assertContains ( response , two , 1 )
def test_perms_needed ( self ) :
self . client . logout ( )
delete_user = User . objects . get ( username = ' deleteuser ' )
delete_user . user_permissions . add ( get_perm ( Plot ,
2013-07-01 13:19:55 +00:00
get_permission_codename ( ' delete ' , Plot . _meta ) ) )
2010-02-26 13:17:43 +00:00
2010-12-04 07:28:12 +00:00
self . assertTrue ( self . client . login ( username = ' deleteuser ' ,
2010-02-26 13:17:43 +00:00
password = ' secret ' ) )
response = self . client . get ( ' /test_admin/admin/admin_views/plot/ %s /delete/ ' % quote ( 1 ) )
self . assertContains ( response , " your account doesn ' t have permission to delete the following types of objects " )
self . assertContains ( response , " <li>plot details</li> " )
2011-01-20 00:33:32 +00:00
def test_protected ( self ) :
q = Question . objects . create ( question = " Why? " )
a1 = Answer . objects . create ( question = q , answer = " Because. " )
a2 = Answer . objects . create ( question = q , answer = " Yes. " )
response = self . client . get ( " /test_admin/admin/admin_views/question/ %s /delete/ " % quote ( q . pk ) )
self . assertContains ( response , " would require deleting the following protected related objects " )
self . assertContains ( response , ' <li>Answer: <a href= " /test_admin/admin/admin_views/answer/ %s / " >Because.</a></li> ' % a1 . pk )
self . assertContains ( response , ' <li>Answer: <a href= " /test_admin/admin/admin_views/answer/ %s / " >Yes.</a></li> ' % a2 . pk )
2010-02-26 13:17:43 +00:00
def test_not_registered ( self ) :
should_contain = """ <li>Secret hideout: underground bunker """
response = self . client . get ( ' /test_admin/admin/admin_views/villain/ %s /delete/ ' % quote ( 1 ) )
self . assertContains ( response , should_contain , 1 )
def test_multiple_fkeys_to_same_model ( self ) :
"""
If a deleted object has two relationships from another model ,
both of those should be followed in looking for related
objects to delete .
"""
should_contain = """ <li>Plot: <a href= " /test_admin/admin/admin_views/plot/1/ " >World Domination</a> """
response = self . client . get ( ' /test_admin/admin/admin_views/villain/ %s /delete/ ' % quote ( 1 ) )
self . assertContains ( response , should_contain )
response = self . client . get ( ' /test_admin/admin/admin_views/villain/ %s /delete/ ' % quote ( 2 ) )
self . assertContains ( response , should_contain )
def test_multiple_fkeys_to_same_instance ( self ) :
"""
If a deleted object has two relationships pointing to it from
another object , the other object should still only be listed
once .
"""
should_contain = """ <li>Plot: <a href= " /test_admin/admin/admin_views/plot/2/ " >World Peace</a></li> """
response = self . client . get ( ' /test_admin/admin/admin_views/villain/ %s /delete/ ' % quote ( 2 ) )
self . assertContains ( response , should_contain , 1 )
def test_inheritance ( self ) :
"""
In the case of an inherited model , if either the child or
parent - model instance is deleted , both instances are listed
for deletion , as well as any relationships they have .
"""
should_contain = [
""" <li>Villain: <a href= " /test_admin/admin/admin_views/villain/3/ " >Bob</a> """ ,
""" <li>Super villain: <a href= " /test_admin/admin/admin_views/supervillain/3/ " >Bob</a> """ ,
""" <li>Secret hideout: floating castle """ ,
""" <li>Super secret hideout: super floating castle! """
2013-10-18 09:02:43 +00:00
]
2010-02-26 13:17:43 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/villain/ %s /delete/ ' % quote ( 3 ) )
for should in should_contain :
self . assertContains ( response , should , 1 )
response = self . client . get ( ' /test_admin/admin/admin_views/supervillain/ %s /delete/ ' % quote ( 3 ) )
for should in should_contain :
self . assertContains ( response , should , 1 )
def test_generic_relations ( self ) :
"""
If a deleted object has GenericForeignKeys pointing to it ,
those objects should be listed for deletion .
"""
plot = Plot . objects . get ( pk = 3 )
2013-09-08 15:05:16 +00:00
FunkyTag . objects . create ( content_object = plot , name = ' hott ' )
2010-02-26 13:17:43 +00:00
should_contain = """ <li>Funky tag: hott """
response = self . client . get ( ' /test_admin/admin/admin_views/plot/ %s /delete/ ' % quote ( 3 ) )
self . assertContains ( response , should_contain )
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
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2008-07-18 23:54:34 +00:00
class AdminViewStringPrimaryKeyTest ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2008-07-18 23:54:34 +00:00
fixtures = [ ' admin-views-users.xml ' , ' string-primary-key.xml ' ]
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
def __init__ ( self , * args ) :
super ( AdminViewStringPrimaryKeyTest , self ) . __init__ ( * args )
self . pk = """ abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 -_.!~* ' () ;/?:@&=+$, <># % " {} | \ ^[]` """
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
content_type_pk = ContentType . objects . get_for_model ( ModelWithStringPrimaryKey ) . pk
2012-07-02 01:40:50 +00:00
LogEntry . objects . log_action ( 100 , content_type_pk , self . pk , self . pk , 2 , change_message = ' Changed something ' )
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
def tearDown ( self ) :
self . client . logout ( )
2008-08-08 18:07:33 +00:00
2009-12-10 19:58:20 +00:00
def test_get_history_view ( self ) :
2012-07-02 01:40:50 +00:00
"""
Retrieving the history for an object using urlencoded form of primary
key should work .
Refs #12349, #18550.
"""
2009-12-10 19:58:20 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/modelwithstringprimarykey/ %s /history/ ' % quote ( self . pk ) )
self . assertContains ( response , escape ( self . pk ) )
2012-07-02 01:40:50 +00:00
self . assertContains ( response , ' Changed something ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 200 )
2010-01-10 16:51:13 +00:00
2008-07-18 23:54:34 +00:00
def test_get_change_view ( self ) :
" Retrieving the object using urlencoded form of primary key should work "
response = self . client . get ( ' /test_admin/admin/admin_views/modelwithstringprimarykey/ %s / ' % quote ( self . pk ) )
self . assertContains ( response , escape ( self . pk ) )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 200 )
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
def test_changelist_to_changeform_link ( self ) :
2012-09-25 01:02:59 +00:00
" Link to the changeform of the object in changelist should use reverse() and be quoted -- #18072 "
prefix = ' /test_admin/admin/admin_views/modelwithstringprimarykey/ '
response = self . client . get ( prefix )
2013-03-18 20:52:16 +00:00
# this URL now comes through reverse(), thus url quoting and iri_to_uri encoding
pk_final_url = escape ( iri_to_uri ( urlquote ( quote ( self . pk ) ) ) )
2013-07-28 02:50:02 +00:00
should_contain = """ <th class= " field-__str__ " ><a href= " %s %s / " > %s </a></th> """ % ( prefix , pk_final_url , escape ( self . pk ) )
2008-07-18 23:54:34 +00:00
self . assertContains ( response , should_contain )
2008-08-08 18:07:33 +00:00
2008-07-18 23:54:34 +00:00
def test_recentactions_link ( self ) :
" The link from the recent actions list referring to the changeform of the object should be quoted "
response = self . client . get ( ' /test_admin/admin/ ' )
2013-03-24 02:11:55 +00:00
link = reverse ( ' admin:admin_views_modelwithstringprimarykey_change ' , args = ( quote ( self . pk ) , ) )
should_contain = """ <a href= " %s " > %s </a> """ % ( link , escape ( self . pk ) )
2008-07-18 23:54:34 +00:00
self . assertContains ( response , should_contain )
2008-08-08 18:07:33 +00:00
2009-05-05 11:52:03 +00:00
def test_recentactions_without_content_type ( self ) :
" If a LogEntry is missing content_type it will not display it in span tag under the hyperlink. "
response = self . client . get ( ' /test_admin/admin/ ' )
2013-03-24 02:11:55 +00:00
link = reverse ( ' admin:admin_views_modelwithstringprimarykey_change ' , args = ( quote ( self . pk ) , ) )
should_contain = """ <a href= " %s " > %s </a> """ % ( link , escape ( self . pk ) )
2009-05-05 11:52:03 +00:00
self . assertContains ( response , should_contain )
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
should_contain = " Model with string primary key " # capitalized in Recent Actions
2009-05-05 11:52:03 +00:00
self . assertContains ( response , should_contain )
logentry = LogEntry . objects . get ( content_type__name__iexact = should_contain )
# http://code.djangoproject.com/ticket/10275
# if the log entry doesn't have a content type it should still be
# possible to view the Recent Actions part
logentry . content_type = None
logentry . save ( )
2012-08-28 18:59:56 +00:00
counted_presence_before = response . content . count ( force_bytes ( should_contain ) )
2009-05-05 11:52:03 +00:00
response = self . client . get ( ' /test_admin/admin/ ' )
2012-08-28 18:59:56 +00:00
counted_presence_after = response . content . count ( force_bytes ( should_contain ) )
2011-03-03 15:04:39 +00:00
self . assertEqual ( counted_presence_before - 1 ,
2009-05-05 11:52:03 +00:00
counted_presence_after )
2013-08-01 07:51:01 +00:00
def test_logentry_get_admin_url ( self ) :
" LogEntry.get_admin_url returns a URL to edit the entry ' s object or None for non-existent (possibly deleted) models "
log_entry_name = " Model with string primary key " # capitalized in Recent Actions
logentry = LogEntry . objects . get ( content_type__name__iexact = log_entry_name )
model = " modelwithstringprimarykey "
desired_admin_url = " /test_admin/admin/admin_views/ %s / %s / " % ( model , escape ( iri_to_uri ( urlquote ( quote ( self . pk ) ) ) ) )
self . assertEqual ( logentry . get_admin_url ( ) , desired_admin_url )
logentry . content_type . model = " non-existent "
self . assertEqual ( logentry . get_admin_url ( ) , None )
2008-07-18 23:54:34 +00:00
def test_deleteconfirmation_link ( self ) :
" The link from the delete confirmation page referring back to the changeform of the object should be quoted "
response = self . client . get ( ' /test_admin/admin/admin_views/modelwithstringprimarykey/ %s /delete/ ' % quote ( self . pk ) )
2013-03-18 20:52:16 +00:00
# this URL now comes through reverse(), thus url quoting and iri_to_uri encoding
should_contain = """ / %s / " > %s </a> """ % ( escape ( iri_to_uri ( urlquote ( quote ( self . pk ) ) ) ) , escape ( self . pk ) )
2008-07-18 23:54:34 +00:00
self . assertContains ( response , should_contain )
2009-03-10 11:19:26 +00:00
2008-08-29 16:46:46 +00:00
def test_url_conflicts_with_add ( self ) :
" A model with a primary key that ends with add should be visible "
2012-06-07 15:34:25 +00:00
add_model = ModelWithStringPrimaryKey ( pk = " i have something to add " )
2008-08-29 16:46:46 +00:00
add_model . save ( )
response = self . client . get ( ' /test_admin/admin/admin_views/modelwithstringprimarykey/ %s / ' % quote ( add_model . pk ) )
should_contain = """ <h1>Change model with string primary key</h1> """
self . assertContains ( response , should_contain )
2009-03-10 11:19:26 +00:00
2008-08-29 16:46:46 +00:00
def test_url_conflicts_with_delete ( self ) :
" A model with a primary key that ends with delete should be visible "
2012-06-07 15:34:25 +00:00
delete_model = ModelWithStringPrimaryKey ( pk = " delete " )
2008-08-29 16:46:46 +00:00
delete_model . save ( )
response = self . client . get ( ' /test_admin/admin/admin_views/modelwithstringprimarykey/ %s / ' % quote ( delete_model . pk ) )
should_contain = """ <h1>Change model with string primary key</h1> """
self . assertContains ( response , should_contain )
2009-03-10 11:19:26 +00:00
2008-08-29 16:46:46 +00:00
def test_url_conflicts_with_history ( self ) :
" A model with a primary key that ends with history should be visible "
2012-06-07 15:34:25 +00:00
history_model = ModelWithStringPrimaryKey ( pk = " history " )
2008-08-29 16:46:46 +00:00
history_model . save ( )
response = self . client . get ( ' /test_admin/admin/admin_views/modelwithstringprimarykey/ %s / ' % quote ( history_model . pk ) )
should_contain = """ <h1>Change model with string primary key</h1> """
self . assertContains ( response , should_contain )
2009-03-10 11:19:26 +00:00
2012-06-07 15:34:25 +00:00
def test_shortcut_view_with_escaping ( self ) :
" ' View on site should ' work properly with char fields "
model = ModelWithStringPrimaryKey ( pk = ' abc_123 ' )
model . save ( )
response = self . client . get ( ' /test_admin/admin/admin_views/modelwithstringprimarykey/ %s / ' % quote ( model . pk ) )
should_contain = ' / %s / " class= " viewsitelink " > ' % model . pk
self . assertContains ( response , should_contain )
2009-03-10 11:19:26 +00:00
2012-09-25 01:02:59 +00:00
def test_change_view_history_link ( self ) :
""" Object history button link should work and contain the pk value quoted. """
url = reverse ( ' admin: %s _modelwithstringprimarykey_change ' %
ModelWithStringPrimaryKey . _meta . app_label ,
args = ( quote ( self . pk ) , ) )
response = self . client . get ( url )
self . assertEqual ( response . status_code , 200 )
expected_link = reverse ( ' admin: %s _modelwithstringprimarykey_history ' %
ModelWithStringPrimaryKey . _meta . app_label ,
args = ( quote ( self . pk ) , ) )
self . assertContains ( response , ' <a href= " %s " class= " historylink " ' % expected_link )
2008-08-09 17:35:19 +00:00
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2011-02-24 13:34:51 +00:00
class SecureViewTests ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2008-08-09 17:35:19 +00:00
fixtures = [ ' admin-views-users.xml ' ]
def setUp ( self ) :
# login POST dicts
2008-09-02 21:10:00 +00:00
self . super_login = {
2010-12-02 00:44:35 +00:00
LOGIN_FORM_KEY : 1 ,
REDIRECT_FIELD_NAME : ' /test_admin/admin/secure-view/ ' ,
' username ' : ' super ' ,
' password ' : ' secret ' ,
}
2008-09-02 21:10:00 +00:00
self . super_email_login = {
2010-12-02 00:44:35 +00:00
LOGIN_FORM_KEY : 1 ,
REDIRECT_FIELD_NAME : ' /test_admin/admin/secure-view/ ' ,
' username ' : ' super@example.com ' ,
' password ' : ' secret ' ,
}
2008-09-02 21:10:00 +00:00
self . super_email_bad_login = {
2010-12-02 00:44:35 +00:00
LOGIN_FORM_KEY : 1 ,
REDIRECT_FIELD_NAME : ' /test_admin/admin/secure-view/ ' ,
' username ' : ' super@example.com ' ,
' password ' : ' notsecret ' ,
}
2008-09-02 21:10:00 +00:00
self . adduser_login = {
2010-12-02 00:44:35 +00:00
LOGIN_FORM_KEY : 1 ,
REDIRECT_FIELD_NAME : ' /test_admin/admin/secure-view/ ' ,
' username ' : ' adduser ' ,
' password ' : ' secret ' ,
}
2008-09-02 21:10:00 +00:00
self . changeuser_login = {
2010-12-02 00:44:35 +00:00
LOGIN_FORM_KEY : 1 ,
REDIRECT_FIELD_NAME : ' /test_admin/admin/secure-view/ ' ,
' username ' : ' changeuser ' ,
' password ' : ' secret ' ,
}
2008-09-02 21:10:00 +00:00
self . deleteuser_login = {
2010-12-02 00:44:35 +00:00
LOGIN_FORM_KEY : 1 ,
REDIRECT_FIELD_NAME : ' /test_admin/admin/secure-view/ ' ,
' username ' : ' deleteuser ' ,
' password ' : ' secret ' ,
}
2008-09-02 21:10:00 +00:00
self . joepublic_login = {
2010-12-02 00:44:35 +00:00
LOGIN_FORM_KEY : 1 ,
REDIRECT_FIELD_NAME : ' /test_admin/admin/secure-view/ ' ,
' username ' : ' joepublic ' ,
' password ' : ' secret ' ,
}
2009-03-10 11:19:26 +00:00
2008-08-09 17:35:19 +00:00
def tearDown ( self ) :
self . client . logout ( )
2009-03-10 11:19:26 +00:00
2008-08-09 17:35:19 +00:00
def test_secure_view_shows_login_if_not_logged_in ( self ) :
" Ensure that we see the login form "
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
response = self . client . get ( ' /test_admin/admin/secure-view/ ' )
2008-08-09 17:35:19 +00:00
self . assertTemplateUsed ( response , ' admin/login.html ' )
2009-03-10 11:19:26 +00:00
2008-08-09 17:35:19 +00:00
def test_secure_view_login_successfully_redirects_to_original_url ( self ) :
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/secure-view/ ' )
self . assertEqual ( response . status_code , 200 )
2010-12-02 00:44:35 +00:00
query_string = ' the-answer=42 '
redirect_url = ' /test_admin/admin/secure-view/? %s ' % query_string
new_next = { REDIRECT_FIELD_NAME : redirect_url }
login = self . client . post ( ' /test_admin/admin/secure-view/ ' , dict ( self . super_login , * * new_next ) , QUERY_STRING = query_string )
self . assertRedirects ( login , redirect_url )
2009-03-10 11:19:26 +00:00
2008-08-09 17:35:19 +00:00
def test_staff_member_required_decorator_works_as_per_admin_login ( self ) :
"""
Make sure only staff members can log in .
Successful posts to the login page will redirect to the orignal url .
2009-03-10 11:19:26 +00:00
Unsuccessfull attempts will continue to render the login page with
2008-08-09 17:35:19 +00:00
a 200 status code .
"""
# Super User
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/secure-view/ ' )
self . assertEqual ( response . status_code , 200 )
2008-08-09 17:35:19 +00:00
login = self . client . post ( ' /test_admin/admin/secure-view/ ' , self . super_login )
self . assertRedirects ( login , ' /test_admin/admin/secure-view/ ' )
2010-12-04 07:28:12 +00:00
self . assertFalse ( login . context )
2008-08-09 17:35:19 +00:00
self . client . get ( ' /test_admin/admin/logout/ ' )
2008-08-24 06:34:18 +00:00
# make sure the view removes test cookie
2010-12-04 07:28:12 +00:00
self . assertEqual ( self . client . session . test_cookie_worked ( ) , False )
2008-08-09 17:35:19 +00:00
2012-09-26 12:14:51 +00:00
# Test if user enters email address
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/secure-view/ ' )
self . assertEqual ( response . status_code , 200 )
2008-08-09 17:35:19 +00:00
login = self . client . post ( ' /test_admin/admin/secure-view/ ' , self . super_email_login )
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
self . assertContains ( login , ERROR_MESSAGE )
2008-08-09 17:35:19 +00:00
# only correct passwords get a username hint
login = self . client . post ( ' /test_admin/admin/secure-view/ ' , self . super_email_bad_login )
2011-09-22 04:16:21 +00:00
self . assertContains ( login , ERROR_MESSAGE )
2008-08-09 17:35:19 +00:00
new_user = User ( username = ' jondoe ' , password = ' secret ' , email = ' super@example.com ' )
new_user . save ( )
2012-09-26 12:14:51 +00:00
# check to ensure if there are multiple email addresses a user doesn't get a 500
2008-08-09 17:35:19 +00:00
login = self . client . post ( ' /test_admin/admin/secure-view/ ' , self . super_email_login )
2011-09-22 04:16:21 +00:00
self . assertContains ( login , ERROR_MESSAGE )
2008-08-09 17:35:19 +00:00
# Add User
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/secure-view/ ' )
self . assertEqual ( response . status_code , 200 )
2008-08-09 17:35:19 +00:00
login = self . client . post ( ' /test_admin/admin/secure-view/ ' , self . adduser_login )
self . assertRedirects ( login , ' /test_admin/admin/secure-view/ ' )
2010-12-04 07:28:12 +00:00
self . assertFalse ( login . context )
2008-08-09 17:35:19 +00:00
self . client . get ( ' /test_admin/admin/logout/ ' )
# Change User
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/secure-view/ ' )
self . assertEqual ( response . status_code , 200 )
2008-08-09 17:35:19 +00:00
login = self . client . post ( ' /test_admin/admin/secure-view/ ' , self . changeuser_login )
self . assertRedirects ( login , ' /test_admin/admin/secure-view/ ' )
2010-12-04 07:28:12 +00:00
self . assertFalse ( login . context )
2008-08-09 17:35:19 +00:00
self . client . get ( ' /test_admin/admin/logout/ ' )
# Delete User
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/secure-view/ ' )
self . assertEqual ( response . status_code , 200 )
2008-08-09 17:35:19 +00:00
login = self . client . post ( ' /test_admin/admin/secure-view/ ' , self . deleteuser_login )
self . assertRedirects ( login , ' /test_admin/admin/secure-view/ ' )
2010-12-04 07:28:12 +00:00
self . assertFalse ( login . context )
2008-08-09 17:35:19 +00:00
self . client . get ( ' /test_admin/admin/logout/ ' )
# Regular User should not be able to login.
2012-08-14 12:36:11 +00:00
response = self . client . get ( ' /test_admin/admin/secure-view/ ' )
self . assertEqual ( response . status_code , 200 )
2008-08-09 17:35:19 +00:00
login = self . client . post ( ' /test_admin/admin/secure-view/ ' , self . joepublic_login )
2010-12-04 07:28:12 +00:00
self . assertEqual ( login . status_code , 200 )
2008-08-09 17:35:19 +00:00
# Login.context is a list of context dicts we just need to check the first one.
2011-09-22 04:16:21 +00:00
self . assertContains ( login , ERROR_MESSAGE )
2008-08-24 06:34:18 +00:00
# 8509 - if a normal user is already logged in, it is possible
# to change user into the superuser without error
login = self . client . login ( username = ' joepublic ' , password = ' secret ' )
# Check and make sure that if user expires, data still persists
self . client . get ( ' /test_admin/admin/secure-view/ ' )
self . client . post ( ' /test_admin/admin/secure-view/ ' , self . super_login )
# make sure the view removes test cookie
2010-12-04 07:28:12 +00:00
self . assertEqual ( self . client . session . test_cookie_worked ( ) , False )
2008-12-16 15:04:47 +00:00
2011-02-24 13:34:51 +00:00
def test_shortcut_view_only_available_to_staff ( self ) :
"""
Only admin users should be able to use the admin shortcut view .
"""
2013-08-29 00:03:21 +00:00
model_ctype = ContentType . objects . get_for_model ( ModelWithStringPrimaryKey )
obj = ModelWithStringPrimaryKey . objects . create ( string_pk = ' foo ' )
shortcut_url = " /test_admin/admin/r/ %s / %s / " % ( model_ctype . pk , obj . pk )
2011-03-01 02:04:35 +00:00
2011-02-24 13:34:51 +00:00
# Not logged in: we should see the login page.
response = self . client . get ( shortcut_url , follow = False )
self . assertTemplateUsed ( response , ' admin/login.html ' )
2011-03-01 02:04:35 +00:00
2011-02-24 13:34:51 +00:00
# Logged in? Redirect.
self . client . login ( username = ' super ' , password = ' secret ' )
response = self . client . get ( shortcut_url , follow = False )
# Can't use self.assertRedirects() because User.get_absolute_url() is silly.
self . assertEqual ( response . status_code , 302 )
2013-08-29 00:03:21 +00:00
self . assertEqual ( response . url , ' http://example.com/dummy/foo/ ' )
2011-02-24 13:34:51 +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
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2008-12-16 15:04:47 +00:00
class AdminViewUnicodeTest ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2008-12-16 15:04:47 +00:00
fixtures = [ ' admin-views-unicode.xml ' ]
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
def testUnicodeEdit ( self ) :
"""
A test to ensure that POST on edit_view handles non - ascii characters .
"""
post_data = {
2012-06-07 16:08:47 +00:00
" name " : " Test lærdommer " ,
2008-12-16 15:04:47 +00:00
# inline data
2012-06-07 16:08:47 +00:00
" chapter_set-TOTAL_FORMS " : " 6 " ,
" chapter_set-INITIAL_FORMS " : " 3 " ,
" chapter_set-MAX_NUM_FORMS " : " 0 " ,
" chapter_set-0-id " : " 1 " ,
" chapter_set-0-title " : " Norske bostaver æøå skaper problemer " ,
" chapter_set-0-content " : " <p>Svært frustrerende med UnicodeDecodeError</p> " ,
" chapter_set-1-id " : " 2 " ,
" chapter_set-1-title " : " Kjærlighet. " ,
" chapter_set-1-content " : " <p>La kjærligheten til de lidende seire.</p> " ,
" chapter_set-2-id " : " 3 " ,
" chapter_set-2-title " : " Need a title. " ,
" chapter_set-2-content " : " <p>Newest content</p> " ,
" chapter_set-3-id " : " " ,
" chapter_set-3-title " : " " ,
" chapter_set-3-content " : " " ,
" chapter_set-4-id " : " " ,
" chapter_set-4-title " : " " ,
" chapter_set-4-content " : " " ,
" chapter_set-5-id " : " " ,
" chapter_set-5-title " : " " ,
" chapter_set-5-content " : " " ,
2008-12-16 15:04:47 +00:00
}
response = self . client . post ( ' /test_admin/admin/admin_views/book/1/ ' , post_data )
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
self . assertEqual ( response . status_code , 302 ) # redirect somewhere
2008-12-16 15:04:47 +00:00
def testUnicodeDelete ( self ) :
"""
Ensure that the delete_view handles non - ascii characters
"""
delete_dict = { ' post ' : ' yes ' }
response = self . client . get ( ' /test_admin/admin/admin_views/book/1/delete/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 200 )
2008-12-16 15:04:47 +00:00
response = self . client . post ( ' /test_admin/admin/admin_views/book/1/delete/ ' , delete_dict )
self . assertRedirects ( response , ' /test_admin/admin/admin_views/book/ ' )
2009-03-10 11:19:26 +00:00
2009-03-17 20:51:47 +00:00
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2009-03-17 20:51:47 +00:00
class AdminViewListEditable ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2009-03-17 20:51:47 +00:00
fixtures = [ ' admin-views-users.xml ' , ' admin-views-person.xml ' ]
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
2009-03-23 20:22:56 +00:00
2009-03-29 18:52:38 +00:00
def test_inheritance ( self ) :
Podcast . objects . create ( name = " This Week in Django " ,
release_date = datetime . date . today ( ) )
response = self . client . get ( ' /test_admin/admin/admin_views/podcast/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 200 )
2009-03-29 18:52:38 +00:00
2009-04-18 21:03:29 +00:00
def test_inheritance_2 ( self ) :
Vodcast . objects . create ( name = " This Week in Django " , released = True )
response = self . client . get ( ' /test_admin/admin/admin_views/vodcast/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 200 )
2009-04-18 21:03:29 +00:00
2009-05-07 11:56:10 +00:00
def test_custom_pk ( self ) :
Language . objects . create ( iso = ' en ' , name = ' English ' , english_name = ' English ' )
response = self . client . get ( ' /test_admin/admin/admin_views/language/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 200 )
2009-05-07 11:56:10 +00:00
2009-03-17 20:51:47 +00:00
def test_changelist_input_html ( self ) :
response = self . client . get ( ' /test_admin/admin/admin_views/person/ ' )
# 2 inputs per object(the field and the hidden id field) = 6
2013-05-24 06:02:07 +00:00
# 4 management hidden fields = 4
2009-03-23 20:22:56 +00:00
# 4 action inputs (3 regular checkboxes, 1 checkbox to select all)
2009-03-17 20:51:47 +00:00
# main form submit button = 1
# search field and search submit button = 2
Fixed #9977 - CsrfMiddleware gets template tag added, session dependency removed, and turned on by default.
This is a large change to CSRF protection for Django. It includes:
* removing the dependency on the session framework.
* deprecating CsrfResponseMiddleware, and replacing with a core template tag.
* turning on CSRF protection by default by adding CsrfViewMiddleware to
the default value of MIDDLEWARE_CLASSES.
* protecting all contrib apps (whatever is in settings.py)
using a decorator.
For existing users of the CSRF functionality, it should be a seamless update,
but please note that it includes DEPRECATION of features in Django 1.1,
and there are upgrade steps which are detailed in the docs.
Many thanks to 'Glenn' and 'bthomas', who did a lot of the thinking and work
on the patch, and to lots of other people including Simon Willison and
Russell Keith-Magee who refined the ideas.
Details of the rationale for these changes is found here:
http://code.djangoproject.com/wiki/CsrfProtection
As of this commit, the CSRF code is mainly in 'contrib'. The code will be
moved to core in a separate commit, to make the changeset as readable as
possible.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11660 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-10-26 23:23:07 +00:00
# CSRF field = 1
2010-01-27 14:18:50 +00:00
# field to track 'select all' across paginated views = 1
2013-05-24 06:02:07 +00:00
# 6 + 4 + 4 + 1 + 2 + 1 + 1 = 19 inputs
self . assertContains ( response , " <input " , count = 19 )
2009-03-17 20:51:47 +00:00
# 1 select per object = 3 selects
2012-04-14 13:35:25 +00:00
self . assertContains ( response , " <select " , count = 4 )
2009-03-23 20:22:56 +00:00
2010-02-23 14:48:15 +00:00
def test_post_messages ( self ) :
# Ticket 12707: Saving inline editable should not show admin
# action warnings
data = {
" form-TOTAL_FORMS " : " 3 " ,
" form-INITIAL_FORMS " : " 3 " ,
" form-MAX_NUM_FORMS " : " 0 " ,
" form-0-gender " : " 1 " ,
" form-0-id " : " 1 " ,
" form-1-gender " : " 2 " ,
" form-1-id " : " 2 " ,
" form-2-alive " : " checked " ,
" form-2-gender " : " 1 " ,
" form-2-id " : " 3 " ,
2010-05-02 23:02:16 +00:00
" _save " : " Save " ,
2010-02-23 14:48:15 +00:00
}
response = self . client . post ( ' /test_admin/admin/admin_views/person/ ' ,
data , follow = True )
self . assertEqual ( len ( response . context [ ' messages ' ] ) , 1 )
2009-03-17 20:51:47 +00:00
def test_post_submission ( self ) :
data = {
" form-TOTAL_FORMS " : " 3 " ,
" form-INITIAL_FORMS " : " 3 " ,
2010-02-01 14:14:56 +00:00
" form-MAX_NUM_FORMS " : " 0 " ,
2009-03-23 20:22:56 +00:00
2009-03-17 20:51:47 +00:00
" form-0-gender " : " 1 " ,
" form-0-id " : " 1 " ,
2009-03-23 20:22:56 +00:00
2009-03-17 20:51:47 +00:00
" form-1-gender " : " 2 " ,
" form-1-id " : " 2 " ,
2009-03-23 20:22:56 +00:00
2009-03-17 20:51:47 +00:00
" form-2-alive " : " checked " ,
" form-2-gender " : " 1 " ,
" form-2-id " : " 3 " ,
2010-05-02 23:02:16 +00:00
" _save " : " Save " ,
2009-03-17 20:51:47 +00:00
}
self . client . post ( ' /test_admin/admin/admin_views/person/ ' , data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( Person . objects . get ( name = " John Mauchly " ) . alive , False )
self . assertEqual ( Person . objects . get ( name = " Grace Hopper " ) . gender , 2 )
2009-03-23 20:22:56 +00:00
2009-03-17 20:51:47 +00:00
# test a filtered page
data = {
" form-TOTAL_FORMS " : " 2 " ,
" form-INITIAL_FORMS " : " 2 " ,
2010-02-01 14:14:56 +00:00
" form-MAX_NUM_FORMS " : " 0 " ,
2009-03-23 20:22:56 +00:00
2009-03-17 20:51:47 +00:00
" form-0-id " : " 1 " ,
" form-0-gender " : " 1 " ,
" form-0-alive " : " checked " ,
2009-03-23 20:22:56 +00:00
2009-03-17 20:51:47 +00:00
" form-1-id " : " 3 " ,
" form-1-gender " : " 1 " ,
" form-1-alive " : " checked " ,
2010-05-02 23:02:16 +00:00
" _save " : " Save " ,
2009-03-17 20:51:47 +00:00
}
self . client . post ( ' /test_admin/admin/admin_views/person/?gender__exact=1 ' , data )
2009-03-23 20:22:56 +00:00
2010-12-04 07:28:12 +00:00
self . assertEqual ( Person . objects . get ( name = " John Mauchly " ) . alive , True )
2009-03-23 20:22:56 +00:00
2009-03-17 20:51:47 +00:00
# test a searched page
data = {
" form-TOTAL_FORMS " : " 1 " ,
" form-INITIAL_FORMS " : " 1 " ,
2010-02-01 14:14:56 +00:00
" form-MAX_NUM_FORMS " : " 0 " ,
2009-03-23 20:22:56 +00:00
2009-03-17 20:51:47 +00:00
" form-0-id " : " 1 " ,
2010-05-02 23:02:16 +00:00
" form-0-gender " : " 1 " ,
" _save " : " Save " ,
2009-03-17 20:51:47 +00:00
}
2011-03-01 02:04:35 +00:00
self . client . post ( ' /test_admin/admin/admin_views/person/?q=john ' , data )
2009-03-23 20:22:56 +00:00
2010-12-04 07:28:12 +00:00
self . assertEqual ( Person . objects . get ( name = " John Mauchly " ) . alive , False )
2009-03-17 20:51:47 +00:00
2011-02-19 11:48:42 +00:00
def test_non_field_errors ( self ) :
''' Ensure that non field errors are displayed for each of the
forms in the changelist ' s formset. Refs #13126.
'''
2011-03-09 00:39:35 +00:00
fd1 = FoodDelivery . objects . create ( reference = ' 123 ' , driver = ' bill ' , restaurant = ' thai ' )
fd2 = FoodDelivery . objects . create ( reference = ' 456 ' , driver = ' bill ' , restaurant = ' india ' )
fd3 = FoodDelivery . objects . create ( reference = ' 789 ' , driver = ' bill ' , restaurant = ' pizza ' )
2011-02-19 11:48:42 +00:00
data = {
" form-TOTAL_FORMS " : " 3 " ,
" form-INITIAL_FORMS " : " 3 " ,
" form-MAX_NUM_FORMS " : " 0 " ,
2011-03-09 00:39:35 +00:00
" form-0-id " : str ( fd1 . id ) ,
2011-02-19 11:48:42 +00:00
" form-0-reference " : " 123 " ,
" form-0-driver " : " bill " ,
" form-0-restaurant " : " thai " ,
# Same data as above: Forbidden because of unique_together!
2011-03-09 00:39:35 +00:00
" form-1-id " : str ( fd2 . id ) ,
2011-02-19 11:48:42 +00:00
" form-1-reference " : " 456 " ,
" form-1-driver " : " bill " ,
" form-1-restaurant " : " thai " ,
2011-03-09 00:39:35 +00:00
" form-2-id " : str ( fd3 . id ) ,
2011-02-19 11:48:42 +00:00
" form-2-reference " : " 789 " ,
" form-2-driver " : " bill " ,
" form-2-restaurant " : " pizza " ,
" _save " : " Save " ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/fooddelivery/ ' , data )
2012-01-31 20:36:11 +00:00
self . assertContains ( response , ' <tr><td colspan= " 4 " ><ul class= " errorlist " ><li>Food delivery with this Driver and Restaurant already exists.</li></ul></td></tr> ' , 1 , html = True )
2011-02-19 11:48:42 +00:00
data = {
" form-TOTAL_FORMS " : " 3 " ,
" form-INITIAL_FORMS " : " 3 " ,
" form-MAX_NUM_FORMS " : " 0 " ,
2011-03-09 00:39:35 +00:00
" form-0-id " : str ( fd1 . id ) ,
2011-02-19 11:48:42 +00:00
" form-0-reference " : " 123 " ,
" form-0-driver " : " bill " ,
" form-0-restaurant " : " thai " ,
# Same data as above: Forbidden because of unique_together!
2011-03-09 00:39:35 +00:00
" form-1-id " : str ( fd2 . id ) ,
2011-02-19 11:48:42 +00:00
" form-1-reference " : " 456 " ,
" form-1-driver " : " bill " ,
" form-1-restaurant " : " thai " ,
# Same data also.
2011-03-09 00:39:35 +00:00
" form-2-id " : str ( fd3 . id ) ,
2011-02-19 11:48:42 +00:00
" form-2-reference " : " 789 " ,
" form-2-driver " : " bill " ,
" form-2-restaurant " : " thai " ,
" _save " : " Save " ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/fooddelivery/ ' , data )
2012-01-31 20:36:11 +00:00
self . assertContains ( response , ' <tr><td colspan= " 4 " ><ul class= " errorlist " ><li>Food delivery with this Driver and Restaurant already exists.</li></ul></td></tr> ' , 2 , html = True )
2011-02-19 11:48:42 +00:00
2010-02-16 12:17:37 +00:00
def test_non_form_errors ( self ) :
# test if non-form errors are handled; ticket #12716
data = {
" form-TOTAL_FORMS " : " 1 " ,
" form-INITIAL_FORMS " : " 1 " ,
" form-MAX_NUM_FORMS " : " 0 " ,
" form-0-id " : " 2 " ,
" form-0-alive " : " 1 " ,
" form-0-gender " : " 2 " ,
2010-05-02 23:02:16 +00:00
# Ensure that the form processing understands this as a list_editable "Save"
# and not an action "Go".
" _save " : " Save " ,
2010-02-16 12:17:37 +00:00
}
response = self . client . post ( ' /test_admin/admin/admin_views/person/ ' , data )
self . assertContains ( response , " Grace is not a Zombie " )
2010-02-23 20:55:42 +00:00
def test_non_form_errors_is_errorlist ( self ) :
# test if non-form errors are correctly handled; ticket #12878
data = {
" form-TOTAL_FORMS " : " 1 " ,
" form-INITIAL_FORMS " : " 1 " ,
" form-MAX_NUM_FORMS " : " 0 " ,
" form-0-id " : " 2 " ,
" form-0-alive " : " 1 " ,
" form-0-gender " : " 2 " ,
2010-05-02 23:02:16 +00:00
" _save " : " Save " ,
2010-02-23 20:55:42 +00:00
}
response = self . client . post ( ' /test_admin/admin/admin_views/person/ ' , data )
non_form_errors = response . context [ ' cl ' ] . formset . non_form_errors ( )
2013-05-21 09:42:15 +00:00
self . assertIsInstance ( non_form_errors , ErrorList )
2010-02-23 20:55:42 +00:00
self . assertEqual ( str ( non_form_errors ) , str ( ErrorList ( [ " Grace is not a Zombie " ] ) ) )
2009-07-03 03:05:17 +00:00
def test_list_editable_ordering ( self ) :
collector = Collector . objects . create ( id = 1 , name = " Frederick Clegg " )
Category . objects . create ( id = 1 , order = 1 , collector = collector )
Category . objects . create ( id = 2 , order = 2 , collector = collector )
Category . objects . create ( id = 3 , order = 0 , collector = collector )
Category . objects . create ( id = 4 , order = 0 , collector = collector )
# NB: The order values must be changed so that the items are reordered.
data = {
" form-TOTAL_FORMS " : " 4 " ,
" form-INITIAL_FORMS " : " 4 " ,
2010-02-01 14:14:56 +00:00
" form-MAX_NUM_FORMS " : " 0 " ,
2009-07-03 03:05:17 +00:00
" form-0-order " : " 14 " ,
" form-0-id " : " 1 " ,
" form-0-collector " : " 1 " ,
" form-1-order " : " 13 " ,
" form-1-id " : " 2 " ,
" form-1-collector " : " 1 " ,
" form-2-order " : " 1 " ,
" form-2-id " : " 3 " ,
" form-2-collector " : " 1 " ,
" form-3-order " : " 0 " ,
" form-3-id " : " 4 " ,
" form-3-collector " : " 1 " ,
2010-05-02 23:02:16 +00:00
# Ensure that the form processing understands this as a list_editable "Save"
# and not an action "Go".
" _save " : " Save " ,
2009-07-03 03:05:17 +00:00
}
response = self . client . post ( ' /test_admin/admin/admin_views/category/ ' , data )
# Successful post will redirect
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
2009-07-03 03:05:17 +00:00
# Check that the order values have been applied to the right objects
2010-12-04 07:28:12 +00:00
self . assertEqual ( Category . objects . get ( id = 1 ) . order , 14 )
self . assertEqual ( Category . objects . get ( id = 2 ) . order , 13 )
self . assertEqual ( Category . objects . get ( id = 3 ) . order , 1 )
self . assertEqual ( Category . objects . get ( id = 4 ) . order , 0 )
2009-07-03 03:05:17 +00:00
2012-03-03 02:13:35 +00:00
def test_list_editable_pagination ( self ) :
"""
Ensure that pagination works for list_editable items .
Refs #16819.
"""
UnorderedObject . objects . create ( id = 1 , name = ' Unordered object #1 ' )
UnorderedObject . objects . create ( id = 2 , name = ' Unordered object #2 ' )
UnorderedObject . objects . create ( id = 3 , name = ' Unordered object #3 ' )
response = self . client . get ( ' /test_admin/admin/admin_views/unorderedobject/ ' )
2012-04-09 04:28:32 +00:00
self . assertContains ( response , ' Unordered object #3 ' )
2012-03-03 02:13:35 +00:00
self . assertContains ( response , ' Unordered object #2 ' )
self . assertNotContains ( response , ' Unordered object #1 ' )
2012-04-09 04:28:32 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/unorderedobject/?p=1 ' )
self . assertNotContains ( response , ' Unordered object #3 ' )
2012-03-03 02:13:35 +00:00
self . assertNotContains ( response , ' Unordered object #2 ' )
2012-04-09 04:28:32 +00:00
self . assertContains ( response , ' Unordered object #1 ' )
2012-03-03 02:13:35 +00:00
2010-05-02 23:02:16 +00:00
def test_list_editable_action_submit ( self ) :
# List editable changes should not be executed if the action "Go" button is
# used to submit the form.
data = {
" form-TOTAL_FORMS " : " 3 " ,
" form-INITIAL_FORMS " : " 3 " ,
" form-MAX_NUM_FORMS " : " 0 " ,
" form-0-gender " : " 1 " ,
" form-0-id " : " 1 " ,
" form-1-gender " : " 2 " ,
" form-1-id " : " 2 " ,
" form-2-alive " : " checked " ,
" form-2-gender " : " 1 " ,
" form-2-id " : " 3 " ,
" index " : " 0 " ,
2012-06-07 16:08:47 +00:00
" _selected_action " : [ ' 3 ' ] ,
" action " : [ ' ' , ' delete_selected ' ] ,
2010-05-02 23:02:16 +00:00
}
self . client . post ( ' /test_admin/admin/admin_views/person/ ' , data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( Person . objects . get ( name = " John Mauchly " ) . alive , True )
self . assertEqual ( Person . objects . get ( name = " Grace Hopper " ) . gender , 1 )
2010-05-02 23:02:16 +00:00
def test_list_editable_action_choices ( self ) :
# List editable changes should be executed if the "Save" button is
# used to submit the form - any action choices should be ignored.
data = {
" form-TOTAL_FORMS " : " 3 " ,
" form-INITIAL_FORMS " : " 3 " ,
" form-MAX_NUM_FORMS " : " 0 " ,
" form-0-gender " : " 1 " ,
" form-0-id " : " 1 " ,
" form-1-gender " : " 2 " ,
" form-1-id " : " 2 " ,
" form-2-alive " : " checked " ,
" form-2-gender " : " 1 " ,
" form-2-id " : " 3 " ,
" _save " : " Save " ,
2012-06-07 16:08:47 +00:00
" _selected_action " : [ ' 1 ' ] ,
" action " : [ ' ' , ' delete_selected ' ] ,
2010-05-02 23:02:16 +00:00
}
self . client . post ( ' /test_admin/admin/admin_views/person/ ' , data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( Person . objects . get ( name = " John Mauchly " ) . alive , False )
self . assertEqual ( Person . objects . get ( name = " Grace Hopper " ) . gender , 2 )
2010-05-02 23:02:16 +00:00
2011-01-02 01:32:40 +00:00
def test_list_editable_popup ( self ) :
"""
Fields should not be list - editable in popups .
"""
response = self . client . get ( ' /test_admin/admin/admin_views/person/ ' )
self . assertNotEqual ( response . context [ ' cl ' ] . list_editable , ( ) )
response = self . client . get ( ' /test_admin/admin/admin_views/person/? %s ' % IS_POPUP_VAR )
self . assertEqual ( response . context [ ' cl ' ] . list_editable , ( ) )
2010-05-02 23:02:16 +00:00
2011-03-03 13:20:45 +00:00
def test_pk_hidden_fields ( self ) :
""" Ensure that hidden pk fields aren ' t displayed in the table body and
that their corresponding human - readable value is displayed instead .
Note that the hidden pk fields are in fact be displayed but
separately ( not in the table ) , and only once .
Refs #12475.
"""
2011-03-09 00:39:35 +00:00
story1 = Story . objects . create ( title = ' The adventures of Guido ' , content = ' Once upon a time in Djangoland... ' )
story2 = Story . objects . create ( title = ' Crouching Tiger, Hidden Python ' , content = ' The Python was sneaking into... ' )
2011-03-03 13:20:45 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/story/ ' )
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
self . assertContains ( response , ' id= " id_form-0-id " ' , 1 ) # Only one hidden field, in a separate place than the table.
2011-03-03 13:20:45 +00:00
self . assertContains ( response , ' id= " id_form-1-id " ' , 1 )
2012-01-31 20:36:11 +00:00
self . assertContains ( response , ' <div class= " hiddenfields " > \n <input type= " hidden " name= " form-0-id " value= " %d " id= " id_form-0-id " /><input type= " hidden " name= " form-1-id " value= " %d " id= " id_form-1-id " /> \n </div> ' % ( story2 . id , story1 . id ) , html = True )
2013-07-28 02:50:02 +00:00
self . assertContains ( response , ' <td class= " field-id " > %d </td> ' % story1 . id , 1 )
self . assertContains ( response , ' <td class= " field-id " > %d </td> ' % story2 . id , 1 )
2011-03-03 13:20:45 +00:00
def test_pk_hidden_fields_with_list_display_links ( self ) :
""" Similarly as test_pk_hidden_fields, but when the hidden pk fields are
referenced in list_display_links .
Refs #12475.
"""
2011-03-09 00:39:35 +00:00
story1 = OtherStory . objects . create ( title = ' The adventures of Guido ' , content = ' Once upon a time in Djangoland... ' )
story2 = OtherStory . objects . create ( title = ' Crouching Tiger, Hidden Python ' , content = ' The Python was sneaking into... ' )
2012-09-25 01:02:59 +00:00
link1 = reverse ( ' admin:admin_views_otherstory_change ' , args = ( story1 . pk , ) )
link2 = reverse ( ' admin:admin_views_otherstory_change ' , args = ( story2 . pk , ) )
2011-03-03 13:20:45 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/otherstory/ ' )
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
self . assertContains ( response , ' id= " id_form-0-id " ' , 1 ) # Only one hidden field, in a separate place than the table.
2011-03-03 13:20:45 +00:00
self . assertContains ( response , ' id= " id_form-1-id " ' , 1 )
2012-01-31 20:36:11 +00:00
self . assertContains ( response , ' <div class= " hiddenfields " > \n <input type= " hidden " name= " form-0-id " value= " %d " id= " id_form-0-id " /><input type= " hidden " name= " form-1-id " value= " %d " id= " id_form-1-id " /> \n </div> ' % ( story2 . id , story1 . id ) , html = True )
2013-07-28 02:50:02 +00:00
self . assertContains ( response , ' <th class= " field-id " ><a href= " %s " > %d </a></th> ' % ( link1 , story1 . id ) , 1 )
self . assertContains ( response , ' <th class= " field-id " ><a href= " %s " > %d </a></th> ' % ( link2 , story2 . id ) , 1 )
2011-03-03 13:20:45 +00:00
2010-05-02 23:02:16 +00:00
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2009-05-07 12:52:43 +00:00
class AdminSearchTest ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2011-03-01 02:04:35 +00:00
fixtures = [ ' admin-views-users ' , ' multiple-child-classes ' ,
' admin-views-person ' ]
2009-05-07 12:52:43 +00:00
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
def test_search_on_sibling_models ( self ) :
" Check that a search that mentions sibling models "
response = self . client . get ( ' /test_admin/admin/admin_views/recommendation/?q=bar ' )
# confirm the search returned 1 object
self . assertContains ( response , " \n 1 recommendation \n " )
2011-02-26 12:44:25 +00:00
def test_with_fk_to_field ( self ) :
""" Ensure that the to_field GET parameter is preserved when a search
is performed . Refs #10918.
"""
from django . contrib . admin . views . main import TO_FIELD_VAR
response = self . client . get ( ' /test_admin/admin/auth/user/?q=joe& %s =username ' % TO_FIELD_VAR )
self . assertContains ( response , " \n 1 user \n " )
2013-09-07 17:41:33 +00:00
self . assertContains ( response , ' <input type= " hidden " name= " _to_field " value= " username " /> ' , html = True )
2011-02-26 12:44:25 +00:00
2011-03-01 02:04:35 +00:00
def test_exact_matches ( self ) :
response = self . client . get ( ' /test_admin/admin/admin_views/recommendation/?q=bar ' )
# confirm the search returned one object
self . assertContains ( response , " \n 1 recommendation \n " )
response = self . client . get ( ' /test_admin/admin/admin_views/recommendation/?q=ba ' )
# confirm the search returned zero objects
self . assertContains ( response , " \n 0 recommendations \n " )
def test_beginning_matches ( self ) :
response = self . client . get ( ' /test_admin/admin/admin_views/person/?q=Gui ' )
# confirm the search returned one object
self . assertContains ( response , " \n 1 person \n " )
self . assertContains ( response , " Guido " )
response = self . client . get ( ' /test_admin/admin/admin_views/person/?q=uido ' )
# confirm the search returned zero objects
self . assertContains ( response , " \n 0 persons \n " )
self . assertNotContains ( response , " Guido " )
2013-05-19 08:52:29 +00:00
def test_pluggable_search ( self ) :
2013-09-08 15:05:16 +00:00
PluggableSearchPerson . objects . create ( name = " Bob " , age = 10 )
PluggableSearchPerson . objects . create ( name = " Amy " , age = 20 )
2013-05-19 08:52:29 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/pluggablesearchperson/?q=Bob ' )
# confirm the search returned one object
self . assertContains ( response , " \n 1 pluggable search person \n " )
self . assertContains ( response , " Bob " )
response = self . client . get ( ' /test_admin/admin/admin_views/pluggablesearchperson/?q=20 ' )
# confirm the search returned one object
self . assertContains ( response , " \n 1 pluggable search person \n " )
self . assertContains ( response , " Amy " )
2011-02-26 12:44:25 +00:00
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2009-03-10 11:19:26 +00:00
class AdminInheritedInlinesTest ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
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
fixtures = [ ' admin-views-users.xml ' ]
2009-03-10 11:19:26 +00:00
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
def testInline ( self ) :
" Ensure that inline models which inherit from a common parent are correctly handled by admin. "
2012-06-07 16:08:47 +00:00
foo_user = " foo username "
bar_user = " bar username "
2009-03-10 11:19:26 +00:00
2012-08-14 12:36:11 +00:00
name_re = re . compile ( b ' name= " (.*?) " ' )
2009-03-10 11:19:26 +00:00
# test the add case
response = self . client . get ( ' /test_admin/admin/admin_views/persona/add/ ' )
names = name_re . findall ( response . content )
# make sure we have no duplicate HTML names
2010-12-04 07:28:12 +00:00
self . assertEqual ( len ( names ) , len ( set ( names ) ) )
2009-03-10 11:19:26 +00:00
# test the add case
post_data = {
2012-06-07 16:08:47 +00:00
" name " : " Test Name " ,
2009-03-10 11:19:26 +00:00
# inline data
2012-06-07 16:08:47 +00:00
" accounts-TOTAL_FORMS " : " 1 " ,
" accounts-INITIAL_FORMS " : " 0 " ,
" accounts-MAX_NUM_FORMS " : " 0 " ,
2009-03-10 11:19:26 +00:00
" accounts-0-username " : foo_user ,
2012-06-07 16:08:47 +00:00
" accounts-2-TOTAL_FORMS " : " 1 " ,
" accounts-2-INITIAL_FORMS " : " 0 " ,
" accounts-2-MAX_NUM_FORMS " : " 0 " ,
2009-03-10 11:19:26 +00:00
" accounts-2-0-username " : bar_user ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/persona/add/ ' , post_data )
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
self . assertEqual ( response . status_code , 302 ) # redirect somewhere
2010-12-04 07:28:12 +00:00
self . assertEqual ( Persona . objects . count ( ) , 1 )
self . assertEqual ( FooAccount . objects . count ( ) , 1 )
self . assertEqual ( BarAccount . objects . count ( ) , 1 )
self . assertEqual ( FooAccount . objects . all ( ) [ 0 ] . username , foo_user )
self . assertEqual ( BarAccount . objects . all ( ) [ 0 ] . username , bar_user )
self . assertEqual ( Persona . objects . all ( ) [ 0 ] . accounts . count ( ) , 2 )
2009-03-10 11:19:26 +00:00
2011-03-09 00:39:35 +00:00
persona_id = Persona . objects . all ( ) [ 0 ] . id
foo_id = FooAccount . objects . all ( ) [ 0 ] . id
bar_id = BarAccount . objects . all ( ) [ 0 ] . id
2009-03-10 11:19:26 +00:00
# test the edit case
2011-03-09 00:39:35 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/persona/ %d / ' % persona_id )
2009-03-10 11:19:26 +00:00
names = name_re . findall ( response . content )
# make sure we have no duplicate HTML names
2010-12-04 07:28:12 +00:00
self . assertEqual ( len ( names ) , len ( set ( names ) ) )
2009-03-10 11:19:26 +00:00
post_data = {
2012-06-07 16:08:47 +00:00
" name " : " Test Name " ,
2009-03-10 11:19:26 +00:00
" accounts-TOTAL_FORMS " : " 2 " ,
2012-06-07 16:08:47 +00:00
" accounts-INITIAL_FORMS " : " 1 " ,
" accounts-MAX_NUM_FORMS " : " 0 " ,
2009-03-10 11:19:26 +00:00
" accounts-0-username " : " %s -1 " % foo_user ,
2011-03-09 00:39:35 +00:00
" accounts-0-account_ptr " : str ( foo_id ) ,
" accounts-0-persona " : str ( persona_id ) ,
2009-03-10 11:19:26 +00:00
2012-06-07 16:08:47 +00:00
" accounts-2-TOTAL_FORMS " : " 2 " ,
" accounts-2-INITIAL_FORMS " : " 1 " ,
" accounts-2-MAX_NUM_FORMS " : " 0 " ,
2009-03-10 11:19:26 +00:00
" accounts-2-0-username " : " %s -1 " % bar_user ,
2011-03-09 00:39:35 +00:00
" accounts-2-0-account_ptr " : str ( bar_id ) ,
" accounts-2-0-persona " : str ( persona_id ) ,
2009-03-10 11:19:26 +00:00
}
2011-03-09 00:39:35 +00:00
response = self . client . post ( ' /test_admin/admin/admin_views/persona/ %d / ' % persona_id , post_data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
self . assertEqual ( Persona . objects . count ( ) , 1 )
self . assertEqual ( FooAccount . objects . count ( ) , 1 )
self . assertEqual ( BarAccount . objects . count ( ) , 1 )
self . assertEqual ( FooAccount . objects . all ( ) [ 0 ] . username , " %s -1 " % foo_user )
self . assertEqual ( BarAccount . objects . all ( ) [ 0 ] . username , " %s -1 " % bar_user )
self . assertEqual ( Persona . objects . all ( ) [ 0 ] . accounts . count ( ) , 2 )
2009-03-23 20:22:56 +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
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2009-03-23 20:22:56 +00:00
class AdminActionsTest ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2009-03-23 20:22:56 +00:00
fixtures = [ ' admin-views-users.xml ' , ' admin-views-actions.xml ' ]
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
def test_model_admin_custom_action ( self ) :
" Tests a custom action defined in a ModelAdmin method "
action_data = {
ACTION_CHECKBOX_NAME : [ 1 ] ,
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
' action ' : ' mail_admin ' ,
2009-03-23 20:22:56 +00:00
' index ' : 0 ,
}
2013-09-08 15:05:16 +00:00
self . client . post ( ' /test_admin/admin/admin_views/subscriber/ ' , action_data )
2011-03-03 15:04:39 +00:00
self . assertEqual ( len ( mail . outbox ) , 1 )
self . assertEqual ( mail . outbox [ 0 ] . subject , ' Greetings from a ModelAdmin action ' )
2009-03-23 20:22:56 +00:00
def test_model_admin_default_delete_action ( self ) :
" Tests the default delete action defined as a ModelAdmin method "
action_data = {
ACTION_CHECKBOX_NAME : [ 1 , 2 ] ,
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
' action ' : ' delete_selected ' ,
2009-03-23 20:22:56 +00:00
' index ' : 0 ,
}
delete_confirmation_data = {
ACTION_CHECKBOX_NAME : [ 1 , 2 ] ,
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
' action ' : ' delete_selected ' ,
2009-03-23 20:22:56 +00:00
' post ' : ' yes ' ,
}
confirmation = self . client . post ( ' /test_admin/admin/admin_views/subscriber/ ' , action_data )
2011-04-22 18:17:16 +00:00
self . assertIsInstance ( confirmation , TemplateResponse )
self . assertContains ( confirmation , " Are you sure you want to delete the selected subscribers? " )
2012-08-14 12:36:11 +00:00
self . assertContains ( confirmation , ACTION_CHECKBOX_NAME , count = 2 )
2013-09-08 15:05:16 +00:00
self . client . post ( ' /test_admin/admin/admin_views/subscriber/ ' , delete_confirmation_data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( Subscriber . objects . count ( ) , 0 )
2009-03-23 20:22:56 +00:00
2013-10-14 13:14:17 +00:00
@override_settings ( USE_THOUSAND_SEPARATOR = True , USE_L10N = True )
2011-02-06 06:16:03 +00:00
def test_non_localized_pk ( self ) :
""" If USE_THOUSAND_SEPARATOR is set, make sure that the ids for
the objects selected for deletion are rendered without separators .
Refs #14895.
"""
subscriber = Subscriber . objects . get ( id = 1 )
subscriber . id = 9999
subscriber . save ( )
action_data = {
ACTION_CHECKBOX_NAME : [ 9999 , 2 ] ,
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
' action ' : ' delete_selected ' ,
2011-02-06 06:16:03 +00:00
' index ' : 0 ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/subscriber/ ' , action_data )
self . assertTemplateUsed ( response , ' admin/delete_selected_confirmation.html ' )
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
self . assertContains ( response , ' value= " 9999 " ' ) # Instead of 9,999
2012-04-14 13:35:25 +00:00
self . assertContains ( response , ' value= " 2 " ' )
2011-02-06 06:16:03 +00:00
2011-01-20 00:33:32 +00:00
def test_model_admin_default_delete_action_protected ( self ) :
"""
Tests the default delete action defined as a ModelAdmin method in the
case where some related objects are protected from deletion .
"""
q1 = Question . objects . create ( question = " Why? " )
a1 = Answer . objects . create ( question = q1 , answer = " Because. " )
a2 = Answer . objects . create ( question = q1 , answer = " Yes. " )
q2 = Question . objects . create ( question = " Wherefore? " )
action_data = {
ACTION_CHECKBOX_NAME : [ q1 . pk , q2 . pk ] ,
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
' action ' : ' delete_selected ' ,
2011-01-20 00:33:32 +00:00
' index ' : 0 ,
}
response = self . client . post ( " /test_admin/admin/admin_views/question/ " , action_data )
self . assertContains ( response , " would require deleting the following protected related objects " )
2012-01-31 20:36:11 +00:00
self . assertContains ( response , ' <li>Answer: <a href= " /test_admin/admin/admin_views/answer/ %s / " >Because.</a></li> ' % a1 . pk , html = True )
self . assertContains ( response , ' <li>Answer: <a href= " /test_admin/admin/admin_views/answer/ %s / " >Yes.</a></li> ' % a2 . pk , html = True )
2011-01-20 00:33:32 +00:00
2013-08-17 22:05:13 +00:00
def test_model_admin_default_delete_action_no_change_url ( self ) :
"""
Default delete action shouldn ' t break if a user ' s ModelAdmin removes the url for change_view .
Regression test for #20640
"""
obj = UnchangeableObject . objects . create ( )
action_data = {
ACTION_CHECKBOX_NAME : obj . pk ,
" action " : " delete_selected " ,
" index " : " 0 " ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/unchangeableobject/ ' , action_data )
# No 500 caused by NoReverseMatch
self . assertEqual ( response . status_code , 200 )
# The page shouldn't display a link to the nonexistent change page
self . assertContains ( response , " <li>Unchangeable object: UnchangeableObject object</li> " , 1 , html = True )
2009-03-23 20:22:56 +00:00
def test_custom_function_mail_action ( self ) :
" Tests a custom action defined in a function "
action_data = {
ACTION_CHECKBOX_NAME : [ 1 ] ,
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
' action ' : ' external_mail ' ,
2009-03-23 20:22:56 +00:00
' index ' : 0 ,
}
2013-09-08 19:20:01 +00:00
self . client . post ( ' /test_admin/admin/admin_views/externalsubscriber/ ' , action_data )
2011-03-03 15:04:39 +00:00
self . assertEqual ( len ( mail . outbox ) , 1 )
self . assertEqual ( mail . outbox [ 0 ] . subject , ' Greetings from a function action ' )
2009-03-23 20:22:56 +00:00
def test_custom_function_action_with_redirect ( self ) :
" Tests a custom action defined in a function "
action_data = {
ACTION_CHECKBOX_NAME : [ 1 ] ,
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
' action ' : ' redirect_to ' ,
2009-03-23 20:22:56 +00:00
' index ' : 0 ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/externalsubscriber/ ' , action_data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
2009-05-05 11:52:03 +00:00
2010-09-07 20:55:53 +00:00
def test_default_redirect ( self ) :
"""
Test that actions which don ' t return an HttpResponse are redirected to
the same page , retaining the querystring ( which may contain changelist
information ) .
"""
action_data = {
ACTION_CHECKBOX_NAME : [ 1 ] ,
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
' action ' : ' external_mail ' ,
2010-09-07 20:55:53 +00:00
' index ' : 0 ,
}
2011-06-02 16:18:47 +00:00
url = ' /test_admin/admin/admin_views/externalsubscriber/?o=1 '
2010-09-07 20:55:53 +00:00
response = self . client . post ( url , action_data )
self . assertRedirects ( response , url )
2013-05-29 14:55:56 +00:00
def test_custom_function_action_streaming_response ( self ) :
""" Tests a custom action that returns a StreamingHttpResponse. """
action_data = {
ACTION_CHECKBOX_NAME : [ 1 ] ,
' action ' : ' download ' ,
' index ' : 0 ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/externalsubscriber/ ' , action_data )
content = b ' ' . join ( response . streaming_content )
self . assertEqual ( content , b ' This is the content of the file ' )
self . assertEqual ( response . status_code , 200 )
def test_custom_function_action_no_perm_response ( self ) :
""" Tests a custom action that returns an HttpResponse with 403 code. """
action_data = {
ACTION_CHECKBOX_NAME : [ 1 ] ,
' action ' : ' no_perm ' ,
' index ' : 0 ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/externalsubscriber/ ' , action_data )
self . assertEqual ( response . status_code , 403 )
self . assertEqual ( response . content , b ' No permission to perform this action ' )
2011-05-05 22:03:17 +00:00
def test_actions_ordering ( self ) :
"""
Ensure that actions are ordered as expected .
Refs #15964.
"""
response = self . client . get ( ' /test_admin/admin/admin_views/externalsubscriber/ ' )
2012-01-31 20:36:11 +00:00
self . assertContains ( response , ''' <label>Action: <select name= " action " >
2011-05-05 22:03:17 +00:00
< option value = " " selected = " selected " > - - - - - - - - - < / option >
2013-05-29 14:55:56 +00:00
< option value = " delete_selected " > Delete selected external
subscribers < / option >
2011-05-05 22:03:17 +00:00
< option value = " redirect_to " > Redirect to ( Awesome action ) < / option >
2013-05-29 14:55:56 +00:00
< option value = " external_mail " > External mail ( Another awesome
action ) < / option >
< option value = " download " > Download subscription < / option >
< option value = " no_perm " > No permission to run < / option >
2012-01-31 20:36:11 +00:00
< / select > ''' , html=True)
2011-05-05 22:03:17 +00:00
2009-04-06 20:23:33 +00:00
def test_model_without_action ( self ) :
" Tests a ModelAdmin without any action "
response = self . client . get ( ' /test_admin/admin/admin_views/oldsubscriber/ ' )
2011-03-03 15:04:39 +00:00
self . assertEqual ( response . context [ " action_form " ] , None )
2012-04-14 13:35:25 +00:00
self . assertNotContains ( response , ' <input type= " checkbox " class= " action-select " ' ,
msg_prefix = " Found an unexpected action toggle checkboxbox in response " )
self . assertNotContains ( response , ' <input type= " checkbox " class= " action-select " ' )
2009-10-27 20:56:12 +00:00
2010-04-19 10:16:25 +00:00
def test_model_without_action_still_has_jquery ( self ) :
" Tests that a ModelAdmin without any actions still gets jQuery included in page "
response = self . client . get ( ' /test_admin/admin/admin_views/oldsubscriber/ ' )
2011-03-03 15:04:39 +00:00
self . assertEqual ( response . context [ " action_form " ] , None )
2012-04-14 13:35:25 +00:00
self . assertContains ( response , ' jquery.min.js ' ,
msg_prefix = " jQuery missing from admin pages for model with no admin actions "
2010-04-19 10:16:25 +00:00
)
2009-10-27 20:56:12 +00:00
def test_action_column_class ( self ) :
" Tests that the checkbox column class is present in the response "
response = self . client . get ( ' /test_admin/admin/admin_views/subscriber/ ' )
2010-11-19 22:45:51 +00:00
self . assertNotEqual ( response . context [ " action_form " ] , None )
2012-04-14 13:35:25 +00:00
self . assertContains ( response , ' action-checkbox-column ' )
2009-10-27 20:56:12 +00:00
2009-04-06 20:23:33 +00:00
def test_multiple_actions_form ( self ) :
"""
Test that actions come from the form whose submit button was pressed ( #10618).
"""
action_data = {
ACTION_CHECKBOX_NAME : [ 1 ] ,
# Two different actions selected on the two forms...
' action ' : [ ' external_mail ' , ' delete_selected ' ] ,
# ...but we clicked "go" on the top form.
' index ' : 0
}
2013-09-08 15:05:16 +00:00
self . client . post ( ' /test_admin/admin/admin_views/externalsubscriber/ ' , action_data )
2009-04-06 20:23:33 +00:00
# Send mail, don't delete.
2011-03-03 15:04:39 +00:00
self . assertEqual ( len ( mail . outbox ) , 1 )
self . assertEqual ( mail . outbox [ 0 ] . subject , ' Greetings from a function action ' )
2009-03-31 00:03:34 +00:00
2009-12-12 21:51:47 +00:00
def test_user_message_on_none_selected ( self ) :
"""
User should see a warning when ' Go ' is pressed and no items are selected .
"""
action_data = {
ACTION_CHECKBOX_NAME : [ ] ,
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
' action ' : ' delete_selected ' ,
2009-12-12 21:51:47 +00:00
' index ' : 0 ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/subscriber/ ' , action_data )
msg = """ Items must be selected in order to perform actions on them. No items have been changed. """
self . assertContains ( response , msg )
2010-12-04 07:28:12 +00:00
self . assertEqual ( Subscriber . objects . count ( ) , 2 )
2009-12-12 21:51:47 +00:00
def test_user_message_on_no_action ( self ) :
"""
User should see a warning when ' Go ' is pressed and no action is selected .
"""
action_data = {
ACTION_CHECKBOX_NAME : [ 1 , 2 ] ,
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
' action ' : ' ' ,
2009-12-12 21:51:47 +00:00
' index ' : 0 ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/subscriber/ ' , action_data )
msg = """ No action selected. """
self . assertContains ( response , msg )
2010-12-04 07:28:12 +00:00
self . assertEqual ( Subscriber . objects . count ( ) , 2 )
2009-12-12 21:51:47 +00:00
2010-01-05 18:24:27 +00:00
def test_selection_counter ( self ) :
"""
Check if the selection counter is there .
"""
response = self . client . get ( ' /test_admin/admin/admin_views/subscriber/ ' )
2010-04-13 10:29:19 +00:00
self . assertContains ( response , ' 0 of 2 selected ' )
2010-01-05 18:24:27 +00:00
2011-01-02 01:32:40 +00:00
def test_popup_actions ( self ) :
""" Actions should not be shown in popups. """
response = self . client . get ( ' /test_admin/admin/admin_views/subscriber/ ' )
2012-08-15 08:38:04 +00:00
self . assertNotEqual ( response . context [ " action_form " ] , None )
2011-01-02 01:32:40 +00:00
response = self . client . get (
' /test_admin/admin/admin_views/subscriber/? %s ' % IS_POPUP_VAR )
2011-03-03 15:04:39 +00:00
self . assertEqual ( response . context [ " action_form " ] , None )
2011-01-02 01:32:40 +00:00
2013-02-26 03:27:52 +00:00
def test_popup_template_response ( self ) :
"""
Success on popups shall be rendered from template in order to allow
easy customization .
"""
response = self . client . post (
' /test_admin/admin/admin_views/actor/add/? %s =1 ' % IS_POPUP_VAR ,
{ ' name ' : ' Troy McClure ' , ' age ' : ' 55 ' , IS_POPUP_VAR : ' 1 ' } )
self . assertEqual ( response . status_code , 200 )
self . assertEqual ( response . template_name , ' admin/popup_response.html ' )
2009-12-12 21:51:47 +00:00
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2009-12-18 10:08:05 +00:00
class TestCustomChangeList ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2009-12-18 10:08:05 +00:00
fixtures = [ ' admin-views-users.xml ' ]
urlbit = ' admin '
def setUp ( self ) :
result = self . client . login ( username = ' super ' , password = ' secret ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( result , True )
2009-12-18 10:08:05 +00:00
def tearDown ( self ) :
self . client . logout ( )
def test_custom_changelist ( self ) :
"""
Validate that a custom ChangeList class can be used ( #9749)
"""
# Insert some data
2012-06-07 16:08:47 +00:00
post_data = { " name " : " First Gadget " }
2009-12-18 10:08:05 +00:00
response = self . client . post ( ' /test_admin/ %s /admin_views/gadget/add/ ' % self . urlbit , post_data )
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
self . assertEqual ( response . status_code , 302 ) # redirect somewhere
2009-12-18 10:08:05 +00:00
# Hit the page once to get messages out of the queue message list
response = self . client . get ( ' /test_admin/ %s /admin_views/gadget/ ' % self . urlbit )
2013-01-29 15:45:40 +00:00
# Ensure that data is still not visible on the page
2009-12-18 10:08:05 +00:00
response = self . client . get ( ' /test_admin/ %s /admin_views/gadget/ ' % self . urlbit )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 200 )
2009-12-18 10:08:05 +00:00
self . assertNotContains ( response , ' First Gadget ' )
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2009-03-31 00:03:34 +00:00
class TestInlineNotEditable ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2009-03-31 00:03:34 +00:00
fixtures = [ ' admin-views-users.xml ' ]
def setUp ( self ) :
result = self . client . login ( username = ' super ' , password = ' secret ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( result , True )
2009-03-31 00:03:34 +00:00
def tearDown ( self ) :
self . client . logout ( )
def test ( self ) :
"""
InlineModelAdmin broken ?
"""
response = self . client . get ( ' /test_admin/admin/admin_views/parent/add/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 200 )
2009-04-01 03:11:58 +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
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2009-04-01 03:11:58 +00:00
class AdminCustomQuerysetTest ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2009-04-01 03:11:58 +00:00
fixtures = [ ' admin-views-users.xml ' ]
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
self . pks = [ EmptyModel . objects . create ( ) . id for i in range ( 3 ) ]
2013-09-06 20:28:48 +00:00
self . super_login = {
REDIRECT_FIELD_NAME : ' /test_admin/admin/ ' ,
LOGIN_FORM_KEY : 1 ,
' username ' : ' super ' ,
' password ' : ' secret ' ,
}
2009-04-01 03:11:58 +00:00
def test_changelist_view ( self ) :
response = self . client . get ( ' /test_admin/admin/admin_views/emptymodel/ ' )
for i in self . pks :
if i > 1 :
self . assertContains ( response , ' Primary key = %s ' % i )
else :
self . assertNotContains ( response , ' Primary key = %s ' % i )
2013-02-24 12:18:21 +00:00
def test_changelist_view_count_queries ( self ) :
2013-03-18 23:58:33 +00:00
# create 2 Person objects
2013-02-24 12:18:21 +00:00
Person . objects . create ( name = ' person1 ' , gender = 1 )
Person . objects . create ( name = ' person2 ' , gender = 2 )
# 4 queries are expected: 1 for the session, 1 for the user,
# 1 for the count and 1 for the objects on the page
with self . assertNumQueries ( 4 ) :
resp = self . client . get ( ' /test_admin/admin/admin_views/person/ ' )
self . assertEqual ( resp . context [ ' selection_note ' ] , ' 0 of 2 selected ' )
self . assertEqual ( resp . context [ ' selection_note_all ' ] , ' All 2 selected ' )
with self . assertNumQueries ( 4 ) :
extra = { ' q ' : ' not_in_name ' }
resp = self . client . get ( ' /test_admin/admin/admin_views/person/ ' , extra )
self . assertEqual ( resp . context [ ' selection_note ' ] , ' 0 of 0 selected ' )
self . assertEqual ( resp . context [ ' selection_note_all ' ] , ' All 0 selected ' )
with self . assertNumQueries ( 4 ) :
extra = { ' q ' : ' person ' }
resp = self . client . get ( ' /test_admin/admin/admin_views/person/ ' , extra )
self . assertEqual ( resp . context [ ' selection_note ' ] , ' 0 of 2 selected ' )
self . assertEqual ( resp . context [ ' selection_note_all ' ] , ' All 2 selected ' )
# here one more count(*) query will run, because filters were applied
with self . assertNumQueries ( 5 ) :
extra = { ' gender__exact ' : ' 1 ' }
resp = self . client . get ( ' /test_admin/admin/admin_views/person/ ' , extra )
self . assertEqual ( resp . context [ ' selection_note ' ] , ' 0 of 1 selected ' )
self . assertEqual ( resp . context [ ' selection_note_all ' ] , ' 1 selected ' )
2009-04-01 03:11:58 +00:00
def test_change_view ( self ) :
for i in self . pks :
response = self . client . get ( ' /test_admin/admin/admin_views/emptymodel/ %s / ' % i )
if i > 1 :
self . assertEqual ( response . status_code , 200 )
else :
self . assertEqual ( response . status_code , 404 )
2009-04-18 20:29:55 +00:00
2012-12-24 19:17:16 +00:00
def test_add_model_modeladmin_defer_qs ( self ) :
2013-03-08 14:15:23 +00:00
# Test for #14529. defer() is used in ModelAdmin.get_queryset()
2012-12-24 19:17:16 +00:00
# model has __unicode__ method
self . assertEqual ( CoverLetter . objects . count ( ) , 0 )
# Emulate model instance creation via the admin
post_data = {
" author " : " Candidate, Best " ,
" _save " : " Save " ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/coverletter/add/ ' ,
post_data , follow = True )
self . assertEqual ( response . status_code , 200 )
self . assertEqual ( CoverLetter . objects . count ( ) , 1 )
# Message should contain non-ugly model verbose name
self . assertContains (
response ,
2013-04-08 20:02:18 +00:00
' <li class= " success " >The cover letter "Candidate, Best" was added successfully.</li> ' ,
2012-12-24 19:17:16 +00:00
html = True
)
# model has no __unicode__ method
self . assertEqual ( ShortMessage . objects . count ( ) , 0 )
# Emulate model instance creation via the admin
post_data = {
" content " : " What ' s this SMS thing? " ,
" _save " : " Save " ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/shortmessage/add/ ' ,
post_data , follow = True )
self . assertEqual ( response . status_code , 200 )
self . assertEqual ( ShortMessage . objects . count ( ) , 1 )
# Message should contain non-ugly model verbose name
self . assertContains (
response ,
2013-04-08 20:02:18 +00:00
' <li class= " success " >The short message "ShortMessage object" was added successfully.</li> ' ,
2012-12-24 19:17:16 +00:00
html = True
)
2011-02-20 23:09:25 +00:00
def test_add_model_modeladmin_only_qs ( self ) :
2013-03-08 14:15:23 +00:00
# Test for #14529. only() is used in ModelAdmin.get_queryset()
2012-12-24 19:17:16 +00:00
# model has __unicode__ method
self . assertEqual ( Telegram . objects . count ( ) , 0 )
# Emulate model instance creation via the admin
post_data = {
" title " : " Urgent telegram " ,
" _save " : " Save " ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/telegram/add/ ' ,
post_data , follow = True )
2011-02-20 23:09:25 +00:00
self . assertEqual ( response . status_code , 200 )
2012-12-24 19:17:16 +00:00
self . assertEqual ( Telegram . objects . count ( ) , 1 )
# Message should contain non-ugly model verbose name
self . assertContains (
response ,
2013-04-08 20:02:18 +00:00
' <li class= " success " >The telegram "Urgent telegram" was added successfully.</li> ' ,
2012-12-24 19:17:16 +00:00
html = True
)
# model has no __unicode__ method
self . assertEqual ( Paper . objects . count ( ) , 0 )
# Emulate model instance creation via the admin
2011-02-20 23:09:25 +00:00
post_data = {
2012-06-07 16:08:47 +00:00
" title " : " My Modified Paper Title " ,
2011-02-20 23:09:25 +00:00
" _save " : " Save " ,
}
2012-12-24 19:17:16 +00:00
response = self . client . post ( ' /test_admin/admin/admin_views/paper/add/ ' ,
2011-02-20 23:09:25 +00:00
post_data , follow = True )
self . assertEqual ( response . status_code , 200 )
2012-12-24 19:17:16 +00:00
self . assertEqual ( Paper . objects . count ( ) , 1 )
# Message should contain non-ugly model verbose name
self . assertContains (
response ,
2013-04-08 20:02:18 +00:00
' <li class= " success " >The paper "Paper object" was added successfully.</li> ' ,
2012-12-24 19:17:16 +00:00
html = True
)
def test_edit_model_modeladmin_defer_qs ( self ) :
2013-03-08 14:15:23 +00:00
# Test for #14529. defer() is used in ModelAdmin.get_queryset()
2011-02-20 23:09:25 +00:00
2012-12-24 19:17:16 +00:00
# model has __unicode__ method
2012-06-07 16:08:47 +00:00
cl = CoverLetter . objects . create ( author = " John Doe " )
2011-02-20 23:09:25 +00:00
self . assertEqual ( CoverLetter . objects . count ( ) , 1 )
response = self . client . get ( ' /test_admin/admin/admin_views/coverletter/ %s / ' % cl . pk )
self . assertEqual ( response . status_code , 200 )
2012-12-24 19:17:16 +00:00
# Emulate model instance edit via the admin
2011-02-20 23:09:25 +00:00
post_data = {
2012-06-07 16:08:47 +00:00
" author " : " John Doe II " ,
2011-02-20 23:09:25 +00:00
" _save " : " Save " ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/coverletter/ %s / ' % cl . pk ,
post_data , follow = True )
self . assertEqual ( response . status_code , 200 )
2012-12-24 19:17:16 +00:00
self . assertEqual ( CoverLetter . objects . count ( ) , 1 )
# Message should contain non-ugly model verbose name. Instance
# representation is set by model's __unicode__()
self . assertContains (
response ,
2013-04-08 20:02:18 +00:00
' <li class= " success " >The cover letter "John Doe II" was changed successfully.</li> ' ,
2012-12-24 19:17:16 +00:00
html = True
)
# model has no __unicode__ method
sm = ShortMessage . objects . create ( content = " This is expensive " )
self . assertEqual ( ShortMessage . objects . count ( ) , 1 )
response = self . client . get ( ' /test_admin/admin/admin_views/shortmessage/ %s / ' % sm . pk )
self . assertEqual ( response . status_code , 200 )
# Emulate model instance edit via the admin
post_data = {
" content " : " Too expensive " ,
" _save " : " Save " ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/shortmessage/ %s / ' % sm . pk ,
post_data , follow = True )
self . assertEqual ( response . status_code , 200 )
self . assertEqual ( ShortMessage . objects . count ( ) , 1 )
# Message should contain non-ugly model verbose name. The ugly(!)
# instance representation is set by six.text_type()
self . assertContains (
response ,
2013-04-08 20:02:18 +00:00
' <li class= " success " >The short message "ShortMessage_Deferred_timestamp object" was changed successfully.</li> ' ,
2012-12-24 19:17:16 +00:00
html = True
)
def test_edit_model_modeladmin_only_qs ( self ) :
2013-03-08 14:15:23 +00:00
# Test for #14529. only() is used in ModelAdmin.get_queryset()
2012-12-24 19:17:16 +00:00
# model has __unicode__ method
t = Telegram . objects . create ( title = " Frist Telegram " )
self . assertEqual ( Telegram . objects . count ( ) , 1 )
response = self . client . get ( ' /test_admin/admin/admin_views/telegram/ %s / ' % t . pk )
self . assertEqual ( response . status_code , 200 )
# Emulate model instance edit via the admin
post_data = {
" title " : " Telegram without typo " ,
" _save " : " Save " ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/telegram/ %s / ' % t . pk ,
post_data , follow = True )
self . assertEqual ( response . status_code , 200 )
self . assertEqual ( Telegram . objects . count ( ) , 1 )
# Message should contain non-ugly model verbose name. The instance
# representation is set by model's __unicode__()
self . assertContains (
response ,
2013-04-08 20:02:18 +00:00
' <li class= " success " >The telegram "Telegram without typo" was changed successfully.</li> ' ,
2012-12-24 19:17:16 +00:00
html = True
)
# model has no __unicode__ method
p = Paper . objects . create ( title = " My Paper Title " )
self . assertEqual ( Paper . objects . count ( ) , 1 )
response = self . client . get ( ' /test_admin/admin/admin_views/paper/ %s / ' % p . pk )
self . assertEqual ( response . status_code , 200 )
# Emulate model instance edit via the admin
post_data = {
" title " : " My Modified Paper Title " ,
" _save " : " Save " ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/paper/ %s / ' % p . pk ,
post_data , follow = True )
self . assertEqual ( response . status_code , 200 )
self . assertEqual ( Paper . objects . count ( ) , 1 )
# Message should contain non-ugly model verbose name. The ugly(!)
# instance representation is set by six.text_type()
self . assertContains (
response ,
2013-04-08 20:02:18 +00:00
' <li class= " success " >The paper "Paper_Deferred_author object" was changed successfully.</li> ' ,
2012-12-24 19:17:16 +00:00
html = True
)
2011-02-20 23:09:25 +00:00
2013-09-06 20:28:48 +00:00
def test_history_view_custom_qs ( self ) :
"""
Ensure that custom querysets are considered for the admin history view .
Refs #21013.
"""
self . client . post ( ' /test_admin/admin/ ' , self . super_login )
FilteredManager . objects . create ( pk = 1 )
FilteredManager . objects . create ( pk = 2 )
response = self . client . get ( ' /test_admin/admin/admin_views/filteredmanager/ ' )
self . assertContains ( response , " PK=1 " )
self . assertContains ( response , " PK=2 " )
self . assertEqual ( self . client . get ( ' /test_admin/admin/admin_views/filteredmanager/1/history/ ' ) . status_code , 200 )
self . assertEqual ( self . client . get ( ' /test_admin/admin/admin_views/filteredmanager/2/history/ ' ) . status_code , 200 )
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
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2009-04-18 20:29:55 +00:00
class AdminInlineFileUploadTest ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2009-04-18 20:29:55 +00:00
fixtures = [ ' admin-views-users.xml ' , ' admin-views-actions.xml ' ]
urlbit = ' admin '
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
2009-05-05 11:52:03 +00:00
2009-04-18 20:29:55 +00:00
# Set up test Picture and Gallery.
# These must be set up here instead of in fixtures in order to allow Picture
# to use a NamedTemporaryFile.
tdir = tempfile . gettempdir ( )
file1 = tempfile . NamedTemporaryFile ( suffix = " .file1 " , dir = tdir )
2012-08-14 12:36:11 +00:00
file1 . write ( b ' a ' * ( 2 * * 21 ) )
2009-04-18 20:29:55 +00:00
filename = file1 . name
file1 . close ( )
2011-03-09 00:39:35 +00:00
self . gallery = Gallery ( name = " Test Gallery " )
self . gallery . save ( )
self . picture = Picture ( name = " Test Picture " , image = filename , gallery = self . gallery )
self . picture . save ( )
2009-04-18 20:29:55 +00:00
def tearDown ( self ) :
self . client . logout ( )
def test_inline_file_upload_edit_validation_error_post ( self ) :
"""
2009-05-05 11:52:03 +00:00
Test that inline file uploads correctly display prior data ( #10002).
2009-04-18 20:29:55 +00:00
"""
post_data = {
2012-06-07 16:08:47 +00:00
" name " : " Test Gallery " ,
" pictures-TOTAL_FORMS " : " 2 " ,
" pictures-INITIAL_FORMS " : " 1 " ,
" pictures-MAX_NUM_FORMS " : " 0 " ,
2012-07-20 12:48:51 +00:00
" pictures-0-id " : six . text_type ( self . picture . id ) ,
" pictures-0-gallery " : six . text_type ( self . gallery . id ) ,
2009-04-18 20:29:55 +00:00
" pictures-0-name " : " Test Picture " ,
" pictures-0-image " : " " ,
" pictures-1-id " : " " ,
2011-03-09 00:39:35 +00:00
" pictures-1-gallery " : str ( self . gallery . id ) ,
2009-04-18 20:29:55 +00:00
" pictures-1-name " : " Test Picture 2 " ,
" pictures-1-image " : " " ,
}
2011-03-09 00:39:35 +00:00
response = self . client . post ( ' /test_admin/ %s /admin_views/gallery/ %d / ' % ( self . urlbit , self . gallery . id ) , post_data )
2010-12-04 07:28:12 +00:00
self . assertTrue ( response . _container [ 0 ] . find ( " Currently: " ) > - 1 )
2009-05-09 11:40:13 +00:00
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2009-05-09 11:40:13 +00:00
class AdminInlineTests ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2009-05-09 11:40:13 +00:00
fixtures = [ ' admin-views-users.xml ' ]
def setUp ( self ) :
self . post_data = {
2012-06-07 16:08:47 +00:00
" name " : " Test Name " ,
2009-05-09 11:40:13 +00:00
" widget_set-TOTAL_FORMS " : " 3 " ,
2012-06-07 16:08:47 +00:00
" widget_set-INITIAL_FORMS " : " 0 " ,
" widget_set-MAX_NUM_FORMS " : " 0 " ,
2009-05-09 11:40:13 +00:00
" widget_set-0-id " : " " ,
" widget_set-0-owner " : " 1 " ,
" widget_set-0-name " : " " ,
" widget_set-1-id " : " " ,
" widget_set-1-owner " : " 1 " ,
" widget_set-1-name " : " " ,
" widget_set-2-id " : " " ,
" widget_set-2-owner " : " 1 " ,
" widget_set-2-name " : " " ,
" doohickey_set-TOTAL_FORMS " : " 3 " ,
2012-06-07 16:08:47 +00:00
" doohickey_set-INITIAL_FORMS " : " 0 " ,
" doohickey_set-MAX_NUM_FORMS " : " 0 " ,
2009-05-09 11:40:13 +00:00
" doohickey_set-0-owner " : " 1 " ,
" doohickey_set-0-code " : " " ,
" doohickey_set-0-name " : " " ,
" doohickey_set-1-owner " : " 1 " ,
" doohickey_set-1-code " : " " ,
" doohickey_set-1-name " : " " ,
" doohickey_set-2-owner " : " 1 " ,
" doohickey_set-2-code " : " " ,
" doohickey_set-2-name " : " " ,
" grommet_set-TOTAL_FORMS " : " 3 " ,
2012-06-07 16:08:47 +00:00
" grommet_set-INITIAL_FORMS " : " 0 " ,
" grommet_set-MAX_NUM_FORMS " : " 0 " ,
2009-05-09 11:40:13 +00:00
" grommet_set-0-code " : " " ,
" grommet_set-0-owner " : " 1 " ,
" grommet_set-0-name " : " " ,
" grommet_set-1-code " : " " ,
" grommet_set-1-owner " : " 1 " ,
" grommet_set-1-name " : " " ,
" grommet_set-2-code " : " " ,
" grommet_set-2-owner " : " 1 " ,
" grommet_set-2-name " : " " ,
" whatsit_set-TOTAL_FORMS " : " 3 " ,
2012-06-07 16:08:47 +00:00
" whatsit_set-INITIAL_FORMS " : " 0 " ,
" whatsit_set-MAX_NUM_FORMS " : " 0 " ,
2009-05-09 11:40:13 +00:00
" whatsit_set-0-owner " : " 1 " ,
" whatsit_set-0-index " : " " ,
" whatsit_set-0-name " : " " ,
" whatsit_set-1-owner " : " 1 " ,
" whatsit_set-1-index " : " " ,
" whatsit_set-1-name " : " " ,
" whatsit_set-2-owner " : " 1 " ,
" whatsit_set-2-index " : " " ,
" whatsit_set-2-name " : " " ,
" fancydoodad_set-TOTAL_FORMS " : " 3 " ,
2012-06-07 16:08:47 +00:00
" fancydoodad_set-INITIAL_FORMS " : " 0 " ,
" fancydoodad_set-MAX_NUM_FORMS " : " 0 " ,
2009-05-09 11:40:13 +00:00
" fancydoodad_set-0-doodad_ptr " : " " ,
" fancydoodad_set-0-owner " : " 1 " ,
" fancydoodad_set-0-name " : " " ,
" fancydoodad_set-0-expensive " : " on " ,
" fancydoodad_set-1-doodad_ptr " : " " ,
" fancydoodad_set-1-owner " : " 1 " ,
" fancydoodad_set-1-name " : " " ,
" fancydoodad_set-1-expensive " : " on " ,
" fancydoodad_set-2-doodad_ptr " : " " ,
" fancydoodad_set-2-owner " : " 1 " ,
" fancydoodad_set-2-name " : " " ,
" fancydoodad_set-2-expensive " : " on " ,
2009-07-03 03:05:17 +00:00
" category_set-TOTAL_FORMS " : " 3 " ,
" category_set-INITIAL_FORMS " : " 0 " ,
2010-02-01 14:14:56 +00:00
" category_set-MAX_NUM_FORMS " : " 0 " ,
2009-07-03 03:05:17 +00:00
" category_set-0-order " : " " ,
" category_set-0-id " : " " ,
" category_set-0-collector " : " 1 " ,
" category_set-1-order " : " " ,
" category_set-1-id " : " " ,
" category_set-1-collector " : " 1 " ,
" category_set-2-order " : " " ,
" category_set-2-id " : " " ,
" category_set-2-collector " : " 1 " ,
2009-05-09 11:40:13 +00:00
}
result = self . client . login ( username = ' super ' , password = ' secret ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( result , 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
self . collector = Collector ( pk = 1 , name = ' John Fowles ' )
2009-07-03 03:05:17 +00:00
self . collector . save ( )
2009-05-09 11:40:13 +00:00
def tearDown ( self ) :
self . client . logout ( )
def test_simple_inline ( self ) :
" A simple model can be saved as inlines "
# First add a new inline
self . post_data [ ' widget_set-0-name ' ] = " Widget 1 "
2011-03-09 00:39:35 +00:00
collector_url = ' /test_admin/admin/admin_views/collector/ %d / ' % self . collector . pk
response = self . client . post ( collector_url , self . post_data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
self . assertEqual ( Widget . objects . count ( ) , 1 )
self . assertEqual ( Widget . objects . all ( ) [ 0 ] . name , " Widget 1 " )
2011-03-09 00:39:35 +00:00
widget_id = Widget . objects . all ( ) [ 0 ] . id
2009-05-09 11:40:13 +00:00
# Check that the PK link exists on the rendered form
2011-03-09 00:39:35 +00:00
response = self . client . get ( collector_url )
2009-05-09 11:40:13 +00:00
self . assertContains ( response , ' name= " widget_set-0-id " ' )
# Now resave that inline
self . post_data [ ' widget_set-INITIAL_FORMS ' ] = " 1 "
2011-03-09 00:39:35 +00:00
self . post_data [ ' widget_set-0-id ' ] = str ( widget_id )
2009-05-09 11:40:13 +00:00
self . post_data [ ' widget_set-0-name ' ] = " Widget 1 "
2011-03-09 00:39:35 +00:00
response = self . client . post ( collector_url , self . post_data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
self . assertEqual ( Widget . objects . count ( ) , 1 )
self . assertEqual ( Widget . objects . all ( ) [ 0 ] . name , " Widget 1 " )
2009-05-09 11:40:13 +00:00
# Now modify that inline
self . post_data [ ' widget_set-INITIAL_FORMS ' ] = " 1 "
2011-03-09 00:39:35 +00:00
self . post_data [ ' widget_set-0-id ' ] = str ( widget_id )
2009-05-09 11:40:13 +00:00
self . post_data [ ' widget_set-0-name ' ] = " Widget 1 Updated "
2011-03-09 00:39:35 +00:00
response = self . client . post ( collector_url , self . post_data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
self . assertEqual ( Widget . objects . count ( ) , 1 )
self . assertEqual ( Widget . objects . all ( ) [ 0 ] . name , " Widget 1 Updated " )
2009-05-09 11:40:13 +00:00
def test_explicit_autofield_inline ( self ) :
" A model with an explicit autofield primary key can be saved as inlines. Regression for #8093 "
# First add a new inline
self . post_data [ ' grommet_set-0-name ' ] = " Grommet 1 "
2011-03-09 00:39:35 +00:00
collector_url = ' /test_admin/admin/admin_views/collector/ %d / ' % self . collector . pk
response = self . client . post ( collector_url , self . post_data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
self . assertEqual ( Grommet . objects . count ( ) , 1 )
self . assertEqual ( Grommet . objects . all ( ) [ 0 ] . name , " Grommet 1 " )
2009-05-09 11:40:13 +00:00
# Check that the PK link exists on the rendered form
2011-03-09 00:39:35 +00:00
response = self . client . get ( collector_url )
2009-05-09 11:40:13 +00:00
self . assertContains ( response , ' name= " grommet_set-0-code " ' )
# Now resave that inline
self . post_data [ ' grommet_set-INITIAL_FORMS ' ] = " 1 "
2011-03-09 00:39:35 +00:00
self . post_data [ ' grommet_set-0-code ' ] = str ( Grommet . objects . all ( ) [ 0 ] . code )
2009-05-09 11:40:13 +00:00
self . post_data [ ' grommet_set-0-name ' ] = " Grommet 1 "
2011-03-09 00:39:35 +00:00
response = self . client . post ( collector_url , self . post_data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
self . assertEqual ( Grommet . objects . count ( ) , 1 )
self . assertEqual ( Grommet . objects . all ( ) [ 0 ] . name , " Grommet 1 " )
2009-05-09 11:40:13 +00:00
# Now modify that inline
self . post_data [ ' grommet_set-INITIAL_FORMS ' ] = " 1 "
2011-03-09 00:39:35 +00:00
self . post_data [ ' grommet_set-0-code ' ] = str ( Grommet . objects . all ( ) [ 0 ] . code )
2009-05-09 11:40:13 +00:00
self . post_data [ ' grommet_set-0-name ' ] = " Grommet 1 Updated "
2011-03-09 00:39:35 +00:00
response = self . client . post ( collector_url , self . post_data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
self . assertEqual ( Grommet . objects . count ( ) , 1 )
self . assertEqual ( Grommet . objects . all ( ) [ 0 ] . name , " Grommet 1 Updated " )
2009-05-09 11:40:13 +00:00
2009-05-14 02:23:53 +00:00
def test_char_pk_inline ( self ) :
" A model with a character PK can be saved as inlines. Regression for #10992 "
# First add a new inline
self . post_data [ ' doohickey_set-0-code ' ] = " DH1 "
self . post_data [ ' doohickey_set-0-name ' ] = " Doohickey 1 "
2011-03-09 00:39:35 +00:00
collector_url = ' /test_admin/admin/admin_views/collector/ %d / ' % self . collector . pk
response = self . client . post ( collector_url , self . post_data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
self . assertEqual ( DooHickey . objects . count ( ) , 1 )
self . assertEqual ( DooHickey . objects . all ( ) [ 0 ] . name , " Doohickey 1 " )
2009-05-15 15:01:40 +00:00
2009-05-14 02:23:53 +00:00
# Check that the PK link exists on the rendered form
2011-03-09 00:39:35 +00:00
response = self . client . get ( collector_url )
2009-05-14 02:23:53 +00:00
self . assertContains ( response , ' name= " doohickey_set-0-code " ' )
2009-05-15 15:01:40 +00:00
2009-05-14 02:23:53 +00:00
# Now resave that inline
self . post_data [ ' doohickey_set-INITIAL_FORMS ' ] = " 1 "
self . post_data [ ' doohickey_set-0-code ' ] = " DH1 "
self . post_data [ ' doohickey_set-0-name ' ] = " Doohickey 1 "
2011-03-09 00:39:35 +00:00
response = self . client . post ( collector_url , self . post_data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
self . assertEqual ( DooHickey . objects . count ( ) , 1 )
self . assertEqual ( DooHickey . objects . all ( ) [ 0 ] . name , " Doohickey 1 " )
2009-05-15 15:01:40 +00:00
2009-05-14 02:23:53 +00:00
# Now modify that inline
self . post_data [ ' doohickey_set-INITIAL_FORMS ' ] = " 1 "
self . post_data [ ' doohickey_set-0-code ' ] = " DH1 "
self . post_data [ ' doohickey_set-0-name ' ] = " Doohickey 1 Updated "
2011-03-09 00:39:35 +00:00
response = self . client . post ( collector_url , self . post_data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
self . assertEqual ( DooHickey . objects . count ( ) , 1 )
self . assertEqual ( DooHickey . objects . all ( ) [ 0 ] . name , " Doohickey 1 Updated " )
2009-05-15 15:01:40 +00:00
2009-05-14 02:23:53 +00:00
def test_integer_pk_inline ( self ) :
" A model with an integer PK can be saved as inlines. Regression for #10992 "
# First add a new inline
self . post_data [ ' whatsit_set-0-index ' ] = " 42 "
self . post_data [ ' whatsit_set-0-name ' ] = " Whatsit 1 "
response = self . client . post ( ' /test_admin/admin/admin_views/collector/1/ ' , self . post_data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
self . assertEqual ( Whatsit . objects . count ( ) , 1 )
self . assertEqual ( Whatsit . objects . all ( ) [ 0 ] . name , " Whatsit 1 " )
2009-05-15 15:01:40 +00:00
2009-05-14 02:23:53 +00:00
# Check that the PK link exists on the rendered form
response = self . client . get ( ' /test_admin/admin/admin_views/collector/1/ ' )
self . assertContains ( response , ' name= " whatsit_set-0-index " ' )
2009-05-15 15:01:40 +00:00
2009-05-14 02:23:53 +00:00
# Now resave that inline
self . post_data [ ' whatsit_set-INITIAL_FORMS ' ] = " 1 "
self . post_data [ ' whatsit_set-0-index ' ] = " 42 "
self . post_data [ ' whatsit_set-0-name ' ] = " Whatsit 1 "
response = self . client . post ( ' /test_admin/admin/admin_views/collector/1/ ' , self . post_data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
self . assertEqual ( Whatsit . objects . count ( ) , 1 )
self . assertEqual ( Whatsit . objects . all ( ) [ 0 ] . name , " Whatsit 1 " )
2009-05-15 15:01:40 +00:00
2009-05-14 02:23:53 +00:00
# Now modify that inline
self . post_data [ ' whatsit_set-INITIAL_FORMS ' ] = " 1 "
self . post_data [ ' whatsit_set-0-index ' ] = " 42 "
self . post_data [ ' whatsit_set-0-name ' ] = " Whatsit 1 Updated "
response = self . client . post ( ' /test_admin/admin/admin_views/collector/1/ ' , self . post_data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
self . assertEqual ( Whatsit . objects . count ( ) , 1 )
self . assertEqual ( Whatsit . objects . all ( ) [ 0 ] . name , " Whatsit 1 Updated " )
2009-05-09 11:40:13 +00:00
def test_inherited_inline ( self ) :
" An inherited model can be saved as inlines. Regression for #11042 "
# First add a new inline
self . post_data [ ' fancydoodad_set-0-name ' ] = " Fancy Doodad 1 "
2011-03-09 00:39:35 +00:00
collector_url = ' /test_admin/admin/admin_views/collector/ %d / ' % self . collector . pk
response = self . client . post ( collector_url , self . post_data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
self . assertEqual ( FancyDoodad . objects . count ( ) , 1 )
self . assertEqual ( FancyDoodad . objects . all ( ) [ 0 ] . name , " Fancy Doodad 1 " )
2011-03-09 00:39:35 +00:00
doodad_pk = FancyDoodad . objects . all ( ) [ 0 ] . pk
2009-05-09 11:40:13 +00:00
# Check that the PK link exists on the rendered form
2011-03-09 00:39:35 +00:00
response = self . client . get ( collector_url )
2009-05-09 11:40:13 +00:00
self . assertContains ( response , ' name= " fancydoodad_set-0-doodad_ptr " ' )
# Now resave that inline
self . post_data [ ' fancydoodad_set-INITIAL_FORMS ' ] = " 1 "
2011-03-09 00:39:35 +00:00
self . post_data [ ' fancydoodad_set-0-doodad_ptr ' ] = str ( doodad_pk )
2009-05-09 11:40:13 +00:00
self . post_data [ ' fancydoodad_set-0-name ' ] = " Fancy Doodad 1 "
2011-03-09 00:39:35 +00:00
response = self . client . post ( collector_url , self . post_data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
self . assertEqual ( FancyDoodad . objects . count ( ) , 1 )
self . assertEqual ( FancyDoodad . objects . all ( ) [ 0 ] . name , " Fancy Doodad 1 " )
2009-05-09 11:40:13 +00:00
# Now modify that inline
self . post_data [ ' fancydoodad_set-INITIAL_FORMS ' ] = " 1 "
2011-03-09 00:39:35 +00:00
self . post_data [ ' fancydoodad_set-0-doodad_ptr ' ] = str ( doodad_pk )
2009-05-09 11:40:13 +00:00
self . post_data [ ' fancydoodad_set-0-name ' ] = " Fancy Doodad 1 Updated "
2011-03-09 00:39:35 +00:00
response = self . client . post ( collector_url , self . post_data )
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
self . assertEqual ( FancyDoodad . objects . count ( ) , 1 )
self . assertEqual ( FancyDoodad . objects . all ( ) [ 0 ] . name , " Fancy Doodad 1 Updated " )
2009-07-03 03:05:17 +00:00
def test_ordered_inline ( self ) :
""" Check that an inline with an editable ordering fields is
updated correctly . Regression for #10922"""
# Create some objects with an initial ordering
Category . objects . create ( id = 1 , order = 1 , collector = self . collector )
Category . objects . create ( id = 2 , order = 2 , collector = self . collector )
Category . objects . create ( id = 3 , order = 0 , collector = self . collector )
Category . objects . create ( id = 4 , order = 0 , collector = self . collector )
# NB: The order values must be changed so that the items are reordered.
self . post_data . update ( {
" name " : " Frederick Clegg " ,
" category_set-TOTAL_FORMS " : " 7 " ,
" category_set-INITIAL_FORMS " : " 4 " ,
2010-02-01 14:14:56 +00:00
" category_set-MAX_NUM_FORMS " : " 0 " ,
2009-07-03 03:05:17 +00:00
" category_set-0-order " : " 14 " ,
" category_set-0-id " : " 1 " ,
" category_set-0-collector " : " 1 " ,
" category_set-1-order " : " 13 " ,
" category_set-1-id " : " 2 " ,
" category_set-1-collector " : " 1 " ,
" category_set-2-order " : " 1 " ,
" category_set-2-id " : " 3 " ,
" category_set-2-collector " : " 1 " ,
" category_set-3-order " : " 0 " ,
" category_set-3-id " : " 4 " ,
" category_set-3-collector " : " 1 " ,
" category_set-4-order " : " " ,
" category_set-4-id " : " " ,
" category_set-4-collector " : " 1 " ,
" category_set-5-order " : " " ,
" category_set-5-id " : " " ,
" category_set-5-collector " : " 1 " ,
" category_set-6-order " : " " ,
" category_set-6-id " : " " ,
" category_set-6-collector " : " 1 " ,
} )
response = self . client . post ( ' /test_admin/admin/admin_views/collector/1/ ' , self . post_data )
# Successful post will redirect
2010-12-04 07:28:12 +00:00
self . assertEqual ( response . status_code , 302 )
2009-07-03 03:05:17 +00:00
# Check that the order values have been applied to the right objects
2010-12-04 07:28:12 +00:00
self . assertEqual ( self . collector . category_set . count ( ) , 4 )
self . assertEqual ( Category . objects . get ( id = 1 ) . order , 14 )
self . assertEqual ( Category . objects . get ( id = 2 ) . order , 13 )
self . assertEqual ( Category . objects . get ( id = 3 ) . order , 1 )
self . assertEqual ( Category . objects . get ( id = 4 ) . order , 0 )
2009-07-13 13:46:31 +00:00
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2009-07-13 13:46:31 +00:00
class NeverCacheTests ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2009-07-13 13:46:31 +00:00
fixtures = [ ' admin-views-users.xml ' , ' admin-views-colors.xml ' , ' admin-views-fabrics.xml ' ]
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
def testAdminIndex ( self ) :
" Check the never-cache status of the main index "
response = self . client . get ( ' /test_admin/admin/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( get_max_age ( response ) , 0 )
2009-07-13 13:46:31 +00:00
def testAppIndex ( self ) :
" Check the never-cache status of an application index "
response = self . client . get ( ' /test_admin/admin/admin_views/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( get_max_age ( response ) , 0 )
2009-07-13 13:46:31 +00:00
def testModelIndex ( self ) :
" Check the never-cache status of a model index "
response = self . client . get ( ' /test_admin/admin/admin_views/fabric/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( get_max_age ( response ) , 0 )
2009-07-13 13:46:31 +00:00
def testModelAdd ( self ) :
" Check the never-cache status of a model add page "
response = self . client . get ( ' /test_admin/admin/admin_views/fabric/add/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( get_max_age ( response ) , 0 )
2009-07-13 13:46:31 +00:00
def testModelView ( self ) :
" Check the never-cache status of a model edit page "
response = self . client . get ( ' /test_admin/admin/admin_views/section/1/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( get_max_age ( response ) , 0 )
2009-07-13 13:46:31 +00:00
def testModelHistory ( self ) :
" Check the never-cache status of a model history page "
response = self . client . get ( ' /test_admin/admin/admin_views/section/1/history/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( get_max_age ( response ) , 0 )
2009-07-13 13:46:31 +00:00
def testModelDelete ( self ) :
" Check the never-cache status of a model delete page "
response = self . client . get ( ' /test_admin/admin/admin_views/section/1/delete/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( get_max_age ( response ) , 0 )
2009-07-13 13:46:31 +00:00
def testLogin ( self ) :
" Check the never-cache status of login views "
self . client . logout ( )
response = self . client . get ( ' /test_admin/admin/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( get_max_age ( response ) , 0 )
2009-07-13 13:46:31 +00:00
def testLogout ( self ) :
" Check the never-cache status of logout view "
response = self . client . get ( ' /test_admin/admin/logout/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( get_max_age ( response ) , 0 )
2009-07-13 13:46:31 +00:00
def testPasswordChange ( self ) :
" Check the never-cache status of the password change view "
self . client . logout ( )
response = self . client . get ( ' /test_admin/password_change/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( get_max_age ( response ) , None )
2009-07-13 13:46:31 +00:00
def testPasswordChangeDone ( self ) :
" Check the never-cache status of the password change done view "
response = self . client . get ( ' /test_admin/admin/password_change/done/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( get_max_age ( response ) , None )
2009-07-13 13:46:31 +00:00
def testJsi18n ( self ) :
2012-03-02 17:16:52 +00:00
" Check the never-cache status of the JavaScript i18n view "
2010-05-02 19:46:31 +00:00
response = self . client . get ( ' /test_admin/admin/jsi18n/ ' )
2010-12-04 07:28:12 +00:00
self . assertEqual ( get_max_age ( response ) , None )
2009-12-22 18:29:00 +00:00
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2011-04-22 12:02:25 +00:00
class PrePopulatedTest ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2011-04-22 12:02:25 +00:00
fixtures = [ ' admin-views-users.xml ' ]
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
def test_prepopulated_on ( self ) :
response = self . client . get ( ' /test_admin/admin/admin_views/prepopulatedpost/add/ ' )
self . assertEqual ( response . status_code , 200 )
self . assertContains ( response , " id: ' #id_slug ' , " )
self . assertContains ( response , " field[ ' dependency_ids ' ].push( ' #id_title ' ); " )
self . assertContains ( response , " id: ' #id_prepopulatedsubpost_set-0-subslug ' , " )
def test_prepopulated_off ( self ) :
response = self . client . get ( ' /test_admin/admin/admin_views/prepopulatedpost/1/ ' )
self . assertEqual ( response . status_code , 200 )
self . assertContains ( response , " A Long Title " )
self . assertNotContains ( response , " id: ' #id_slug ' " )
self . assertNotContains ( response , " field[ ' dependency_ids ' ].push( ' #id_title ' ); " )
self . assertNotContains ( response , " id: ' #id_prepopulatedsubpost_set-0-subslug ' , " )
2011-11-22 09:14:09 +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
@override_settings ( USE_THOUSAND_SEPARATOR = True , USE_L10N = True )
2011-10-26 05:33:17 +00:00
def test_prepopulated_maxlength_localized ( self ) :
"""
Regression test for #15938: if USE_THOUSAND_SEPARATOR is set, make sure
2012-03-02 17:16:52 +00:00
that maxLength ( in the JavaScript ) is rendered without separators .
2011-10-26 05:33:17 +00:00
"""
response = self . client . get ( ' /test_admin/admin/admin_views/prepopulatedpostlargeslug/add/ ' )
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
self . assertContains ( response , " maxLength: 1000 " ) # instead of 1,000
2011-04-22 12:02:25 +00:00
2012-02-19 16:42:12 +00:00
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2013-02-19 16:01:29 +00:00
class SeleniumAdminViewsFirefoxTests ( AdminSeleniumWebDriverTestCase ) :
2013-06-10 10:11:46 +00:00
available_apps = [ ' admin_views ' ] + AdminSeleniumWebDriverTestCase . available_apps
2012-02-19 16:42:12 +00:00
fixtures = [ ' admin-views-users.xml ' ]
2013-06-10 10:11:46 +00:00
urls = " admin_views.urls "
webdriver_class = ' selenium.webdriver.firefox.webdriver.WebDriver '
2012-02-19 16:42:12 +00:00
2013-02-19 16:01:29 +00:00
def test_prepopulated_fields ( self ) :
2012-02-19 16:42:12 +00:00
"""
2012-03-02 17:16:52 +00:00
Ensure that the JavaScript - automated prepopulated fields work with the
2012-02-19 16:42:12 +00:00
main form and with stacked and tabular inlines .
Refs #13068, #9264, #9983, #9784.
"""
2012-03-05 08:13:09 +00:00
from selenium . common . exceptions import TimeoutException
2012-02-19 16:42:12 +00:00
self . admin_login ( username = ' super ' , password = ' secret ' , login_url = ' /test_admin/admin/ ' )
self . selenium . get ( ' %s %s ' % ( self . live_server_url ,
' /test_admin/admin/admin_views/mainprepopulated/add/ ' ) )
# Main form ----------------------------------------------------------
self . selenium . find_element_by_css_selector ( ' #id_pubdate ' ) . send_keys ( ' 2012-02-18 ' )
2012-02-23 08:07:07 +00:00
self . get_select_option ( ' #id_status ' , ' option two ' ) . click ( )
2012-06-07 16:08:47 +00:00
self . selenium . find_element_by_css_selector ( ' #id_name ' ) . send_keys ( ' this is the mAin nÀMë and it \' s awεšome ' )
2012-02-19 16:42:12 +00:00
slug1 = self . selenium . find_element_by_css_selector ( ' #id_slug1 ' ) . get_attribute ( ' value ' )
slug2 = self . selenium . find_element_by_css_selector ( ' #id_slug2 ' ) . get_attribute ( ' value ' )
self . assertEqual ( slug1 , ' main-name-and-its-awesome-2012-02-18 ' )
self . assertEqual ( slug2 , ' option-two-main-name-and-its-awesome ' )
# Stacked inlines ----------------------------------------------------
# Initial inline
self . selenium . find_element_by_css_selector ( ' #id_relatedprepopulated_set-0-pubdate ' ) . send_keys ( ' 2011-12-17 ' )
2012-02-23 08:07:07 +00:00
self . get_select_option ( ' #id_relatedprepopulated_set-0-status ' , ' option one ' ) . click ( )
2012-06-07 16:08:47 +00:00
self . selenium . find_element_by_css_selector ( ' #id_relatedprepopulated_set-0-name ' ) . send_keys ( ' here is a sŤāÇkeð inline ! ' )
2012-02-19 16:42:12 +00:00
slug1 = self . selenium . find_element_by_css_selector ( ' #id_relatedprepopulated_set-0-slug1 ' ) . get_attribute ( ' value ' )
slug2 = self . selenium . find_element_by_css_selector ( ' #id_relatedprepopulated_set-0-slug2 ' ) . get_attribute ( ' value ' )
self . assertEqual ( slug1 , ' here-stacked-inline-2011-12-17 ' )
self . assertEqual ( slug2 , ' option-one-here-stacked-inline ' )
# Add an inline
2012-03-05 08:13:09 +00:00
self . selenium . find_elements_by_link_text ( ' Add another Related Prepopulated ' ) [ 0 ] . click ( )
2012-02-19 16:42:12 +00:00
self . selenium . find_element_by_css_selector ( ' #id_relatedprepopulated_set-1-pubdate ' ) . send_keys ( ' 1999-01-25 ' )
2012-02-23 08:07:07 +00:00
self . get_select_option ( ' #id_relatedprepopulated_set-1-status ' , ' option two ' ) . click ( )
2012-06-07 16:08:47 +00:00
self . selenium . find_element_by_css_selector ( ' #id_relatedprepopulated_set-1-name ' ) . send_keys ( ' now you haVe anöther sŤāÇkeð inline with a very ... loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooog text... ' )
2012-02-19 16:42:12 +00:00
slug1 = self . selenium . find_element_by_css_selector ( ' #id_relatedprepopulated_set-1-slug1 ' ) . get_attribute ( ' value ' )
slug2 = self . selenium . find_element_by_css_selector ( ' #id_relatedprepopulated_set-1-slug2 ' ) . get_attribute ( ' value ' )
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
self . assertEqual ( slug1 , ' now-you-have-another-stacked-inline-very-loooooooo ' ) # 50 characters maximum for slug1 field
self . assertEqual ( slug2 , ' option-two-now-you-have-another-stacked-inline-very-looooooo ' ) # 60 characters maximum for slug2 field
2012-02-19 16:42:12 +00:00
# Tabular inlines ----------------------------------------------------
# Initial inline
self . selenium . find_element_by_css_selector ( ' #id_relatedprepopulated_set-2-0-pubdate ' ) . send_keys ( ' 1234-12-07 ' )
2012-02-23 08:07:07 +00:00
self . get_select_option ( ' #id_relatedprepopulated_set-2-0-status ' , ' option two ' ) . click ( )
2012-06-07 16:08:47 +00:00
self . selenium . find_element_by_css_selector ( ' #id_relatedprepopulated_set-2-0-name ' ) . send_keys ( ' And now, with a tÃbűlaŘ inline !!! ' )
2012-02-19 16:42:12 +00:00
slug1 = self . selenium . find_element_by_css_selector ( ' #id_relatedprepopulated_set-2-0-slug1 ' ) . get_attribute ( ' value ' )
slug2 = self . selenium . find_element_by_css_selector ( ' #id_relatedprepopulated_set-2-0-slug2 ' ) . get_attribute ( ' value ' )
self . assertEqual ( slug1 , ' and-now-tabular-inline-1234-12-07 ' )
self . assertEqual ( slug2 , ' option-two-and-now-tabular-inline ' )
# Add an inline
2012-03-05 08:13:09 +00:00
self . selenium . find_elements_by_link_text ( ' Add another Related Prepopulated ' ) [ 1 ] . click ( )
2012-02-19 16:42:12 +00:00
self . selenium . find_element_by_css_selector ( ' #id_relatedprepopulated_set-2-1-pubdate ' ) . send_keys ( ' 1981-08-22 ' )
2012-02-23 08:07:07 +00:00
self . get_select_option ( ' #id_relatedprepopulated_set-2-1-status ' , ' option one ' ) . click ( )
2012-06-07 16:08:47 +00:00
self . selenium . find_element_by_css_selector ( ' #id_relatedprepopulated_set-2-1-name ' ) . send_keys ( ' a tÃbűlaŘ inline with ignored ; " &*^ \ % $#@-/`~ characters ' )
2012-02-19 16:42:12 +00:00
slug1 = self . selenium . find_element_by_css_selector ( ' #id_relatedprepopulated_set-2-1-slug1 ' ) . get_attribute ( ' value ' )
slug2 = self . selenium . find_element_by_css_selector ( ' #id_relatedprepopulated_set-2-1-slug2 ' ) . get_attribute ( ' value ' )
self . assertEqual ( slug1 , ' tabular-inline-ignored-characters-1981-08-22 ' )
self . assertEqual ( slug2 , ' option-one-tabular-inline-ignored-characters ' )
# Save and check that everything is properly stored in the database
self . selenium . find_element_by_xpath ( ' //input[@value= " Save " ] ' ) . click ( )
2013-02-20 01:08:55 +00:00
self . wait_page_loaded ( )
2012-02-19 16:42:12 +00:00
self . assertEqual ( MainPrepopulated . objects . all ( ) . count ( ) , 1 )
MainPrepopulated . objects . get (
2012-06-07 16:08:47 +00:00
name = ' this is the mAin nÀMë and it \' s awεšome ' ,
2012-02-19 16:42:12 +00:00
pubdate = ' 2012-02-18 ' ,
status = ' option two ' ,
slug1 = ' main-name-and-its-awesome-2012-02-18 ' ,
slug2 = ' option-two-main-name-and-its-awesome ' ,
)
self . assertEqual ( RelatedPrepopulated . objects . all ( ) . count ( ) , 4 )
RelatedPrepopulated . objects . get (
2012-06-07 16:08:47 +00:00
name = ' here is a sŤāÇkeð inline ! ' ,
2012-02-19 16:42:12 +00:00
pubdate = ' 2011-12-17 ' ,
status = ' option one ' ,
slug1 = ' here-stacked-inline-2011-12-17 ' ,
slug2 = ' option-one-here-stacked-inline ' ,
)
RelatedPrepopulated . objects . get (
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
name = ' now you haVe anöther sŤāÇkeð inline with a very ... loooooooooooooooooo ' , # 75 characters in name field
2012-02-19 16:42:12 +00:00
pubdate = ' 1999-01-25 ' ,
status = ' option two ' ,
slug1 = ' now-you-have-another-stacked-inline-very-loooooooo ' ,
slug2 = ' option-two-now-you-have-another-stacked-inline-very-looooooo ' ,
)
RelatedPrepopulated . objects . get (
2012-06-07 16:08:47 +00:00
name = ' And now, with a tÃbűlaŘ inline !!! ' ,
2012-02-19 16:42:12 +00:00
pubdate = ' 1234-12-07 ' ,
status = ' option two ' ,
slug1 = ' and-now-tabular-inline-1234-12-07 ' ,
slug2 = ' option-two-and-now-tabular-inline ' ,
)
RelatedPrepopulated . objects . get (
2012-06-07 16:08:47 +00:00
name = ' a tÃbűlaŘ inline with ignored ; " &*^ \ % $#@-/`~ characters ' ,
2012-02-19 16:42:12 +00:00
pubdate = ' 1981-08-22 ' ,
status = ' option one ' ,
slug1 = ' tabular-inline-ignored-characters-1981-08-22 ' ,
slug2 = ' option-one-tabular-inline-ignored-characters ' ,
)
2013-07-30 07:21:08 +00:00
def test_populate_existing_object ( self ) :
"""
Ensure that the prepopulation works for existing objects too , as long
as the original field is empty .
Refs #19082.
"""
# Slugs are empty to start with.
item = MainPrepopulated . objects . create (
name = ' this is the mAin nÀMë ' ,
pubdate = ' 2012-02-18 ' ,
status = ' option two ' ,
slug1 = ' ' ,
slug2 = ' ' ,
)
self . admin_login ( username = ' super ' ,
password = ' secret ' ,
login_url = ' /test_admin/admin/ ' )
object_url = ' %s %s ' % (
self . live_server_url ,
' /test_admin/admin/admin_views/mainprepopulated/ {} / ' . format ( item . id ) )
self . selenium . get ( object_url )
self . selenium . find_element_by_css_selector ( ' #id_name ' ) . send_keys ( ' the best ' )
# The slugs got prepopulated since they were originally empty
slug1 = self . selenium . find_element_by_css_selector ( ' #id_slug1 ' ) . get_attribute ( ' value ' )
slug2 = self . selenium . find_element_by_css_selector ( ' #id_slug2 ' ) . get_attribute ( ' value ' )
self . assertEqual ( slug1 , ' main-name-best-2012-02-18 ' )
self . assertEqual ( slug2 , ' option-two-main-name-best ' )
# Save the object
self . selenium . find_element_by_xpath ( ' //input[@value= " Save " ] ' ) . click ( )
self . wait_page_loaded ( )
self . selenium . get ( object_url )
self . selenium . find_element_by_css_selector ( ' #id_name ' ) . send_keys ( ' hello ' )
# The slugs got prepopulated didn't change since they were originally not empty
slug1 = self . selenium . find_element_by_css_selector ( ' #id_slug1 ' ) . get_attribute ( ' value ' )
slug2 = self . selenium . find_element_by_css_selector ( ' #id_slug2 ' ) . get_attribute ( ' value ' )
self . assertEqual ( slug1 , ' main-name-best-2012-02-18 ' )
self . assertEqual ( slug2 , ' option-two-main-name-best ' )
2013-02-19 16:01:29 +00:00
def test_collapsible_fieldset ( self ) :
"""
Test that the ' collapse ' class in fieldsets definition allows to
show / hide the appropriate field section .
"""
self . admin_login ( username = ' super ' , password = ' secret ' , login_url = ' /test_admin/admin/ ' )
self . selenium . get ( ' %s %s ' % ( self . live_server_url ,
' /test_admin/admin/admin_views/article/add/ ' ) )
self . assertFalse ( self . selenium . find_element_by_id ( ' id_title ' ) . is_displayed ( ) )
self . selenium . find_elements_by_link_text ( ' Show ' ) [ 0 ] . click ( )
self . assertTrue ( self . selenium . find_element_by_id ( ' id_title ' ) . is_displayed ( ) )
self . assertEqual (
self . selenium . find_element_by_id ( ' fieldsetcollapser0 ' ) . text ,
" Hide "
)
2013-09-01 18:02:30 +00:00
def test_first_field_focus ( self ) :
""" JavaScript-assisted auto-focus on first usable form field. """
# First form field has a single widget
self . admin_login ( username = ' super ' , password = ' secret ' , login_url = ' /test_admin/admin/ ' )
self . selenium . get ( ' %s %s ' % ( self . live_server_url ,
' /test_admin/admin/admin_views/picture/add/ ' ) )
self . assertEqual (
self . selenium . switch_to_active_element ( ) ,
self . selenium . find_element_by_id ( ' id_name ' )
)
# First form field has a MultiWidget
self . selenium . get ( ' %s %s ' % ( self . live_server_url ,
' /test_admin/admin/admin_views/reservation/add/ ' ) )
self . assertEqual (
self . selenium . switch_to_active_element ( ) ,
self . selenium . find_element_by_id ( ' id_start_date_0 ' )
)
2012-02-22 07:14:10 +00:00
2013-02-19 16:01:29 +00:00
class SeleniumAdminViewsChromeTests ( SeleniumAdminViewsFirefoxTests ) :
2012-02-22 07:14:10 +00:00
webdriver_class = ' selenium.webdriver.chrome.webdriver.WebDriver '
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
2013-02-19 16:01:29 +00:00
class SeleniumAdminViewsIETests ( SeleniumAdminViewsFirefoxTests ) :
2012-03-05 08:13:09 +00:00
webdriver_class = ' selenium.webdriver.ie.webdriver.WebDriver '
2012-02-22 07:14:10 +00:00
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2009-12-22 18:29:00 +00:00
class ReadonlyTest ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2009-12-22 18:29:00 +00:00
fixtures = [ ' admin-views-users.xml ' ]
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
def test_readonly_get ( self ) :
response = self . client . get ( ' /test_admin/admin/admin_views/post/add/ ' )
self . assertEqual ( response . status_code , 200 )
self . assertNotContains ( response , ' name= " posted " ' )
2013-05-24 06:02:07 +00:00
# 3 fields + 2 submit buttons + 5 inline management form fields, + 2
2010-02-01 14:14:56 +00:00
# hidden fields for inlines + 1 field for the inline + 2 empty form
2013-05-24 06:02:07 +00:00
self . assertContains ( response , " <input " , count = 15 )
2009-12-22 18:29:00 +00:00
self . assertContains ( response , formats . localize ( datetime . date . today ( ) ) )
self . assertContains ( response ,
" <label>Awesomeness level:</label> " )
self . assertContains ( response , " Very awesome. " )
self . assertContains ( response , " Unkown coolness. " )
self . assertContains ( response , " foo " )
2012-11-17 16:06:24 +00:00
# Checks that multiline text in a readonly field gets <br /> tags
self . assertContains ( response , " Multiline<br />test<br />string " )
2012-12-06 08:47:51 +00:00
self . assertContains ( response , " InlineMultiline<br />test<br />string " )
2012-11-17 16:06:24 +00:00
2009-12-22 18:29:00 +00:00
self . assertContains ( response ,
formats . localize ( datetime . date . today ( ) - datetime . timedelta ( days = 7 ) )
)
2011-10-10 12:35:06 +00:00
self . assertContains ( response , ' <div class= " form-row field-coolness " > ' )
self . assertContains ( response , ' <div class= " form-row field-awesomeness_level " > ' )
self . assertContains ( response , ' <div class= " form-row field-posted " > ' )
self . assertContains ( response , ' <div class= " form-row field-value " > ' )
self . assertContains ( response , ' <div class= " form-row " > ' )
2011-02-19 12:55:09 +00:00
self . assertContains ( response , ' <p class= " help " > ' , 3 )
2012-01-31 20:36:11 +00:00
self . assertContains ( response , ' <p class= " help " >Some help text for the title (with unicode ŠĐĆŽćžšđ)</p> ' , html = True )
self . assertContains ( response , ' <p class= " help " >Some help text for the content (with unicode ŠĐĆŽćžšđ)</p> ' , html = True )
self . assertContains ( response , ' <p class= " help " >Some help text for the date (with unicode ŠĐĆŽćžšđ)</p> ' , html = True )
2010-04-05 15:37:43 +00:00
2009-12-22 18:29:00 +00:00
p = Post . objects . create ( title = " I worked on readonly_fields " , content = " Its good stuff " )
response = self . client . get ( ' /test_admin/admin/admin_views/post/ %d / ' % p . pk )
self . assertContains ( response , " %d amount of cool " % p . pk )
def test_readonly_post ( self ) :
data = {
" title " : " Django Got Readonly Fields " ,
" content " : " This is an incredible development. " ,
" link_set-TOTAL_FORMS " : " 1 " ,
" link_set-INITIAL_FORMS " : " 0 " ,
2010-02-01 14:14:56 +00:00
" link_set-MAX_NUM_FORMS " : " 0 " ,
2009-12-22 18:29:00 +00:00
}
response = self . client . post ( ' /test_admin/admin/admin_views/post/add/ ' , data )
self . assertEqual ( response . status_code , 302 )
self . assertEqual ( Post . objects . count ( ) , 1 )
p = Post . objects . get ( )
self . assertEqual ( p . posted , datetime . date . today ( ) )
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
data [ " posted " ] = " 10-8-1990 " # some date that's not today
2009-12-22 18:29:00 +00:00
response = self . client . post ( ' /test_admin/admin/admin_views/post/add/ ' , data )
self . assertEqual ( response . status_code , 302 )
self . assertEqual ( Post . objects . count ( ) , 2 )
p = Post . objects . order_by ( ' -id ' ) [ 0 ]
self . assertEqual ( p . posted , datetime . date . today ( ) )
2010-01-12 02:29:45 +00:00
2010-03-21 14:23:25 +00:00
def test_readonly_manytomany ( self ) :
" Regression test for #13004 "
response = self . client . get ( ' /test_admin/admin/admin_views/pizza/add/ ' )
self . assertEqual ( response . status_code , 200 )
2012-02-09 18:57:40 +00:00
def test_user_password_change_limited_queryset ( self ) :
su = User . objects . filter ( is_superuser = True ) [ 0 ]
response = self . client . get ( ' /test_admin/admin2/auth/user/ %s /password/ ' % su . pk )
2012-05-03 14:39:16 +00:00
self . assertEqual ( response . status_code , 404 )
2012-02-09 18:57:40 +00:00
2012-11-25 22:13:22 +00:00
def test_change_form_renders_correct_null_choice_value ( self ) :
"""
Regression test for #17911.
"""
choice = Choice . objects . create ( choice = None )
response = self . client . get ( ' /test_admin/admin/admin_views/choice/ %s / ' % choice . pk )
self . assertContains ( response , ' <p>No opinion</p> ' , html = True )
self . assertNotContains ( response , ' <p>(None)</p> ' )
2013-08-29 13:39:31 +00:00
def test_readonly_backwards_ref ( self ) :
"""
Regression test for #16433 - backwards references for related objects
broke if the related field is read - only due to the help_text attribute
"""
topping = Topping . objects . create ( name = ' Salami ' )
pizza = Pizza . objects . create ( name = ' Americano ' )
pizza . toppings . add ( topping )
response = self . client . get ( ' /test_admin/admin/admin_views/topping/add/ ' )
self . assertEqual ( response . status_code , 200 )
2011-01-28 14:08:42 +00:00
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2011-01-28 14:08:42 +00:00
class RawIdFieldsTest ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2011-01-28 14:08:42 +00:00
fixtures = [ ' admin-views-users.xml ' ]
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
def test_limit_choices_to ( self ) :
""" Regression test for 14880 """
actor = Actor . objects . create ( name = " Palin " , age = 27 )
2013-09-08 19:20:01 +00:00
Inquisition . objects . create ( expected = True ,
leader = actor ,
country = " England " )
Inquisition . objects . create ( expected = False ,
leader = actor ,
country = " Spain " )
2011-01-28 14:08:42 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/sketch/add/ ' )
# Find the link
2012-08-14 12:36:11 +00:00
m = re . search ( br ' <a href= " ([^ " ]*) " [^>]* id= " lookup_id_inquisition " ' , response . content )
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
self . assertTrue ( m ) # Got a match
2012-08-14 12:36:11 +00:00
popup_url = m . groups ( ) [ 0 ] . decode ( ) . replace ( " & " , " & " )
2011-01-28 14:08:42 +00:00
# Handle relative links
2012-07-20 13:36:52 +00:00
popup_url = urljoin ( response . request [ ' PATH_INFO ' ] , popup_url )
2013-05-27 16:31:49 +00:00
# Get the popup and verify the correct objects show up in the resulting
# page. This step also tests integers, strings and booleans in the
# lookup query string; in model we define inquisition field to have a
# limit_choices_to option that includes a filter on a string field
# (inquisition__actor__name), a filter on an integer field
# (inquisition__actor__age), and a filter on a boolean field
# (inquisition__expected).
2011-01-28 14:08:42 +00:00
response2 = self . client . get ( popup_url )
self . assertContains ( response2 , " Spain " )
self . assertNotContains ( response2 , " England " )
2013-05-27 16:31:49 +00:00
def test_limit_choices_to_isnull_false ( self ) :
""" Regression test for 20182 """
Actor . objects . create ( name = " Palin " , age = 27 )
Actor . objects . create ( name = " Kilbraken " , age = 50 , title = " Judge " )
response = self . client . get ( ' /test_admin/admin/admin_views/sketch/add/ ' )
# Find the link
m = re . search ( br ' <a href= " ([^ " ]*) " [^>]* id= " lookup_id_defendant0 " ' , response . content )
self . assertTrue ( m ) # Got a match
popup_url = m . groups ( ) [ 0 ] . decode ( ) . replace ( " & " , " & " )
# Handle relative links
popup_url = urljoin ( response . request [ ' PATH_INFO ' ] , popup_url )
# Get the popup and verify the correct objects show up in the resulting
# page. This step tests field__isnull=0 gets parsed correctly from the
# lookup query string; in model we define defendant0 field to have a
# limit_choices_to option that includes "actor__title__isnull=False".
response2 = self . client . get ( popup_url )
self . assertContains ( response2 , " Kilbraken " )
self . assertNotContains ( response2 , " Palin " )
def test_limit_choices_to_isnull_true ( self ) :
""" Regression test for 20182 """
Actor . objects . create ( name = " Palin " , age = 27 )
Actor . objects . create ( name = " Kilbraken " , age = 50 , title = " Judge " )
response = self . client . get ( ' /test_admin/admin/admin_views/sketch/add/ ' )
# Find the link
m = re . search ( br ' <a href= " ([^ " ]*) " [^>]* id= " lookup_id_defendant1 " ' , response . content )
self . assertTrue ( m ) # Got a match
popup_url = m . groups ( ) [ 0 ] . decode ( ) . replace ( " & " , " & " )
# Handle relative links
popup_url = urljoin ( response . request [ ' PATH_INFO ' ] , popup_url )
# Get the popup and verify the correct objects show up in the resulting
# page. This step tests field__isnull=1 gets parsed correctly from the
# lookup query string; in model we define defendant1 field to have a
# limit_choices_to option that includes "actor__title__isnull=True".
response2 = self . client . get ( popup_url )
self . assertNotContains ( response2 , " Kilbraken " )
self . assertContains ( response2 , " Palin " )
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
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2010-08-06 14:58:05 +00:00
class UserAdminTest ( TestCase ) :
2010-01-12 02:29:45 +00:00
"""
2010-08-06 14:58:05 +00:00
Tests user CRUD functionality .
2010-01-12 02:29:45 +00:00
"""
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2010-01-12 02:29:45 +00:00
fixtures = [ ' admin-views-users.xml ' ]
def setUp ( self ) :
2010-01-12 23:35:29 +00:00
self . client . login ( username = ' super ' , password = ' secret ' )
2010-01-12 02:29:45 +00:00
def tearDown ( self ) :
2010-01-12 23:35:29 +00:00
self . client . logout ( )
2010-01-12 02:29:45 +00:00
2010-11-19 22:45:51 +00:00
def test_save_button ( self ) :
user_count = User . objects . count ( )
response = self . client . post ( ' /test_admin/admin/auth/user/add/ ' , {
' username ' : ' newuser ' ,
' password1 ' : ' newpassword ' ,
' password2 ' : ' newpassword ' ,
} )
new_user = User . objects . order_by ( ' -id ' ) [ 0 ]
self . assertRedirects ( response , ' /test_admin/admin/auth/user/ %s / ' % new_user . pk )
self . assertEqual ( User . objects . count ( ) , user_count + 1 )
2013-06-18 18:02:00 +00:00
self . assertTrue ( new_user . has_usable_password ( ) )
2010-11-19 22:45:51 +00:00
def test_save_continue_editing_button ( self ) :
2010-08-06 16:08:40 +00:00
user_count = User . objects . count ( )
2010-01-12 23:35:29 +00:00
response = self . client . post ( ' /test_admin/admin/auth/user/add/ ' , {
' username ' : ' newuser ' ,
' password1 ' : ' newpassword ' ,
' password2 ' : ' newpassword ' ,
' _continue ' : ' 1 ' ,
} )
new_user = User . objects . order_by ( ' -id ' ) [ 0 ]
self . assertRedirects ( response , ' /test_admin/admin/auth/user/ %s / ' % new_user . pk )
2010-11-19 22:45:51 +00:00
self . assertEqual ( User . objects . count ( ) , user_count + 1 )
2013-06-18 18:02:00 +00:00
self . assertTrue ( new_user . has_usable_password ( ) )
2010-01-12 02:29:45 +00:00
def test_password_mismatch ( self ) :
2010-01-12 23:35:29 +00:00
response = self . client . post ( ' /test_admin/admin/auth/user/add/ ' , {
' username ' : ' newuser ' ,
' password1 ' : ' newpassword ' ,
' password2 ' : ' mismatch ' ,
} )
2010-11-19 22:45:51 +00:00
self . assertEqual ( response . status_code , 200 )
2010-01-12 23:35:29 +00:00
adminform = response . context [ ' adminform ' ]
2010-11-19 22:45:51 +00:00
self . assertTrue ( ' password ' not in adminform . form . errors )
self . assertEqual ( adminform . form . errors [ ' password2 ' ] ,
2012-06-07 16:08:47 +00:00
[ " The two password fields didn ' t match. " ] )
2010-08-06 14:58:05 +00:00
def test_user_fk_popup ( self ) :
2011-02-24 01:00:57 +00:00
""" Quick user addition in a FK popup shouldn ' t invoke view for further user customization """
2010-08-06 14:58:05 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/album/add/ ' )
2010-11-19 22:45:51 +00:00
self . assertEqual ( response . status_code , 200 )
2010-08-06 14:58:05 +00:00
self . assertContains ( response , ' /test_admin/admin/auth/user/add ' )
self . assertContains ( response , ' class= " add-another " id= " add_id_owner " onclick= " return showAddAnotherPopup(this); " ' )
response = self . client . get ( ' /test_admin/admin/auth/user/add/?_popup=1 ' )
2011-02-24 01:00:57 +00:00
self . assertEqual ( response . status_code , 200 )
2010-08-06 14:58:05 +00:00
self . assertNotContains ( response , ' name= " _continue " ' )
2010-11-19 22:45:51 +00:00
self . assertNotContains ( response , ' name= " _addanother " ' )
2011-02-24 01:00:57 +00:00
data = {
' username ' : ' newuser ' ,
' password1 ' : ' newpassword ' ,
' password2 ' : ' newpassword ' ,
' _popup ' : ' 1 ' ,
' _save ' : ' 1 ' ,
}
response = self . client . post ( ' /test_admin/admin/auth/user/add/?_popup=1 ' , data , follow = True )
self . assertEqual ( response . status_code , 200 )
self . assertContains ( response , ' dismissAddAnotherPopup ' )
2010-08-06 16:08:40 +00:00
2010-11-19 22:45:51 +00:00
def test_save_add_another_button ( self ) :
2010-08-06 16:08:40 +00:00
user_count = User . objects . count ( )
response = self . client . post ( ' /test_admin/admin/auth/user/add/ ' , {
' username ' : ' newuser ' ,
' password1 ' : ' newpassword ' ,
' password2 ' : ' newpassword ' ,
' _addanother ' : ' 1 ' ,
} )
new_user = User . objects . order_by ( ' -id ' ) [ 0 ]
self . assertRedirects ( response , ' /test_admin/admin/auth/user/add/ ' )
2010-11-19 22:45:51 +00:00
self . assertEqual ( User . objects . count ( ) , user_count + 1 )
2013-06-18 18:02:00 +00:00
self . assertTrue ( new_user . has_usable_password ( ) )
2010-08-14 13:41:56 +00:00
2011-08-15 09:01:12 +00:00
def test_user_permission_performance ( self ) :
u = User . objects . all ( ) [ 0 ]
2011-12-11 12:04:37 +00:00
# Don't depend on a warm cache, see #17377.
ContentType . objects . clear_cache ( )
2013-05-10 14:56:42 +00:00
expected_queries = 10
# Oracle doesn't implement "RELEASE SAVPOINT", see #20387.
if connection . vendor == ' oracle ' :
expected_queries - = 1
2013-05-10 15:56:39 +00:00
with self . assertNumQueries ( expected_queries ) :
2011-08-15 09:01:12 +00:00
response = self . client . get ( ' /test_admin/admin/auth/user/ %s / ' % u . pk )
self . assertEqual ( response . status_code , 200 )
2012-02-09 18:56:32 +00:00
def test_form_url_present_in_context ( self ) :
u = User . objects . all ( ) [ 0 ]
response = self . client . get ( ' /test_admin/admin3/auth/user/ %s /password/ ' % u . pk )
self . assertEqual ( response . status_code , 200 )
self . assertEqual ( response . context [ ' form_url ' ] , ' pony ' )
2011-08-15 09:01:12 +00:00
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2011-08-15 09:01:12 +00:00
class GroupAdminTest ( TestCase ) :
"""
Tests group CRUD functionality .
"""
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2011-08-15 09:01:12 +00:00
fixtures = [ ' admin-views-users.xml ' ]
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
def test_save_button ( self ) :
group_count = Group . objects . count ( )
response = self . client . post ( ' /test_admin/admin/auth/group/add/ ' , {
' name ' : ' newgroup ' ,
} )
2013-09-08 19:20:01 +00:00
Group . objects . order_by ( ' -id ' ) [ 0 ]
2011-08-15 09:01:12 +00:00
self . assertRedirects ( response , ' /test_admin/admin/auth/group/ ' )
self . assertEqual ( Group . objects . count ( ) , group_count + 1 )
def test_group_permission_performance ( self ) :
g = Group . objects . create ( name = " test_group " )
2013-05-10 14:56:42 +00:00
expected_queries = 8
# Oracle doesn't implement "RELEASE SAVPOINT", see #20387.
if connection . vendor == ' oracle ' :
expected_queries - = 1
with self . assertNumQueries ( expected_queries ) :
2011-08-15 09:01:12 +00:00
response = self . client . get ( ' /test_admin/admin/auth/group/ %s / ' % g . pk )
self . assertEqual ( response . status_code , 200 )
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2011-10-10 12:35:06 +00:00
class CSSTest ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2011-10-10 12:35:06 +00:00
fixtures = [ ' admin-views-users.xml ' ]
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
2012-12-03 04:54:34 +00:00
def test_field_prefix_css_classes ( self ) :
"""
Ensure that fields have a CSS class name with a ' field- ' prefix .
Refs #16371.
"""
2011-10-10 12:35:06 +00:00
response = self . client . get ( ' /test_admin/admin/admin_views/post/add/ ' )
# The main form
self . assertContains ( response , ' class= " form-row field-title " ' )
self . assertContains ( response , ' class= " form-row field-content " ' )
self . assertContains ( response , ' class= " form-row field-public " ' )
self . assertContains ( response , ' class= " form-row field-awesomeness_level " ' )
self . assertContains ( response , ' class= " form-row field-coolness " ' )
self . assertContains ( response , ' class= " form-row field-value " ' )
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
self . assertContains ( response , ' class= " form-row " ' ) # The lambda function
2011-10-10 12:35:06 +00:00
# The tabular inline
self . assertContains ( response , ' <td class= " field-url " > ' )
self . assertContains ( response , ' <td class= " field-posted " > ' )
2012-12-03 04:54:34 +00:00
def test_index_css_classes ( self ) :
"""
Ensure that CSS class names are used for each app and model on the
admin index pages .
Refs #17050.
"""
# General index page
response = self . client . get ( " /test_admin/admin/ " )
self . assertContains ( response , ' <div class= " app-admin_views module " > ' )
self . assertContains ( response , ' <tr class= " model-actor " > ' )
self . assertContains ( response , ' <tr class= " model-album " > ' )
# App index page
response = self . client . get ( " /test_admin/admin/admin_views/ " )
self . assertContains ( response , ' <div class= " app-admin_views module " > ' )
self . assertContains ( response , ' <tr class= " model-actor " > ' )
self . assertContains ( response , ' <tr class= " model-album " > ' )
2011-10-10 12:35:06 +00:00
2013-07-21 09:02:36 +00:00
def testAppModelInFormBodyClass ( self ) :
"""
Ensure app and model tag are correcly read by change_form template
"""
response = self . client . get ( ' /test_admin/admin/admin_views/section/add/ ' )
self . assertEqual ( response . status_code , 200 )
self . assertContains ( response ,
' <body class= " app-admin_views model-section ' )
def testAppModelInListBodyClass ( self ) :
"""
Ensure app and model tag are correcly read by change_list template
"""
response = self . client . get ( ' /test_admin/admin/admin_views/section/ ' )
self . assertEqual ( response . status_code , 200 )
self . assertContains ( response ,
' <body class= " app-admin_views model-section ' )
def testAppModelInDeleteConfirmationBodyClass ( self ) :
"""
Ensure app and model tag are correcly read by delete_confirmation
template
"""
response = self . client . get (
' /test_admin/admin/admin_views/section/1/delete/ ' )
self . assertEqual ( response . status_code , 200 )
self . assertContains ( response ,
' <body class= " app-admin_views model-section ' )
def testAppModelInAppIndexBodyClass ( self ) :
"""
Ensure app and model tag are correcly read by app_index template
"""
response = self . client . get ( ' /test_admin/admin/admin_views/ ' )
self . assertEqual ( response . status_code , 200 )
self . assertContains ( response , ' <body class= " app-admin_views ' )
def testAppModelInDeleteSelectedConfirmationBodyClass ( self ) :
"""
Ensure app and model tag are correcly read by
delete_selected_confirmation template
"""
action_data = {
ACTION_CHECKBOX_NAME : [ 1 ] ,
' action ' : ' delete_selected ' ,
' index ' : 0 ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/section/ ' ,
action_data )
self . assertEqual ( response . status_code , 200 )
self . assertContains ( response ,
' <body class= " app-admin_views model-section ' )
2013-07-28 02:50:02 +00:00
def test_changelist_field_classes ( self ) :
"""
Cells of the change list table should contain the field name in their class attribute
Refs #11195.
"""
Podcast . objects . create ( name = " Django Dose " ,
release_date = datetime . date . today ( ) )
response = self . client . get ( ' /test_admin/admin/admin_views/podcast/ ' )
self . assertContains (
response , ' <th class= " field-name " > ' )
self . assertContains (
response , ' <td class= " field-release_date nowrap " > ' )
self . assertContains (
response , ' <td class= " action-checkbox " > ' )
2010-08-19 13:11:24 +00:00
try :
import docutils
2010-10-11 12:55:17 +00:00
except ImportError :
docutils = None
2010-08-14 13:41:56 +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
2012-03-30 09:08:29 +00:00
@unittest.skipUnless ( docutils , " no docutils installed. " )
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2010-10-11 12:55:17 +00:00
class AdminDocsTest ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2010-10-11 12:55:17 +00:00
fixtures = [ ' admin-views-users.xml ' ]
2010-08-14 13:41:56 +00:00
2010-10-11 12:55:17 +00:00
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
2010-08-19 13:11:24 +00:00
2010-10-11 12:55:17 +00:00
def tearDown ( self ) :
self . client . logout ( )
2010-08-19 13:11:24 +00:00
2010-10-11 12:55:17 +00:00
def test_tags ( self ) :
response = self . client . get ( ' /test_admin/admin/doc/tags/ ' )
2010-08-14 13:41:56 +00:00
2010-10-11 12:55:17 +00:00
# The builtin tag group exists
2012-01-31 20:36:11 +00:00
self . assertContains ( response , " <h2>Built-in tags</h2> " , count = 2 , html = True )
2010-08-14 13:41:56 +00:00
2010-10-11 12:55:17 +00:00
# A builtin tag exists in both the index and detail
2012-01-31 20:36:11 +00:00
self . assertContains ( response , ' <h3 id= " built_in-autoescape " >autoescape</h3> ' , html = True )
self . assertContains ( response , ' <li><a href= " #built_in-autoescape " >autoescape</a></li> ' , html = True )
2010-08-14 13:41:56 +00:00
2010-10-11 12:55:17 +00:00
# An app tag exists in both the index and detail
2012-01-31 20:36:11 +00:00
self . assertContains ( response , ' <h3 id= " flatpages-get_flatpages " >get_flatpages</h3> ' , html = True )
self . assertContains ( response , ' <li><a href= " #flatpages-get_flatpages " >get_flatpages</a></li> ' , html = True )
2010-09-11 00:02:33 +00:00
2010-10-11 12:55:17 +00:00
# The admin list tag group exists
2012-01-31 20:36:11 +00:00
self . assertContains ( response , " <h2>admin_list</h2> " , count = 2 , html = True )
2010-08-14 13:41:56 +00:00
2010-10-11 12:55:17 +00:00
# An admin list tag exists in both the index and detail
2012-01-31 20:36:11 +00:00
self . assertContains ( response , ' <h3 id= " admin_list-admin_actions " >admin_actions</h3> ' , html = True )
self . assertContains ( response , ' <li><a href= " #admin_list-admin_actions " >admin_actions</a></li> ' , html = True )
2010-08-14 13:41:56 +00:00
2010-10-11 12:55:17 +00:00
def test_filters ( self ) :
response = self . client . get ( ' /test_admin/admin/doc/filters/ ' )
2010-08-14 13:41:56 +00:00
2010-10-11 12:55:17 +00:00
# The builtin filter group exists
2012-01-31 20:36:11 +00:00
self . assertContains ( response , " <h2>Built-in filters</h2> " , count = 2 , html = True )
2010-08-14 13:41:56 +00:00
2010-10-11 12:55:17 +00:00
# A builtin filter exists in both the index and detail
2012-01-31 20:36:11 +00:00
self . assertContains ( response , ' <h3 id= " built_in-add " >add</h3> ' , html = True )
self . assertContains ( response , ' <li><a href= " #built_in-add " >add</a></li> ' , html = True )
2010-08-14 13:41:56 +00:00
2010-10-10 01:57:56 +00:00
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2010-10-10 01:57:56 +00:00
class ValidXHTMLTests ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2010-10-10 01:57:56 +00:00
fixtures = [ ' admin-views-users.xml ' ]
urlbit = ' admin '
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
2012-04-09 13:24:57 +00:00
@override_settings (
TEMPLATE_CONTEXT_PROCESSORS = filter (
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
lambda t : t != ' django.core.context_processors.i18n ' ,
2012-04-09 13:24:57 +00:00
global_settings . TEMPLATE_CONTEXT_PROCESSORS ) ,
USE_I18N = False ,
)
2010-10-10 01:57:56 +00:00
def testLangNamePresent ( self ) :
response = self . client . get ( ' /test_admin/ %s /admin_views/ ' % self . urlbit )
2012-04-14 13:35:25 +00:00
self . assertNotContains ( response , ' lang= " " ' )
self . assertNotContains ( response , ' xml:lang= " " ' )
2010-12-12 22:54:50 +00:00
2013-10-14 13:14:17 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) ,
USE_THOUSAND_SEPARATOR = True , USE_L10N = True )
2010-12-12 22:54:50 +00:00
class DateHierarchyTests ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2010-12-12 22:54:50 +00:00
fixtures = [ ' admin-views-users.xml ' ]
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
2011-02-08 12:00:01 +00:00
def tearDown ( self ) :
2011-02-09 00:09:54 +00:00
formats . reset_format_cache ( )
2011-02-08 12:00:01 +00:00
2011-02-08 12:20:18 +00:00
def assert_non_localized_year ( self , response , year ) :
2011-02-08 12:00:01 +00:00
""" Ensure that the year is not localized with
USE_THOUSAND_SEPARATOR . Refs #15234.
"""
self . assertNotContains ( response , formats . number_format ( year ) )
2010-12-12 22:54:50 +00:00
def assert_contains_year_link ( self , response , date ) :
self . assertContains ( response , ' ?release_date__year= %d " ' % ( date . year , ) )
def assert_contains_month_link ( self , response , date ) :
self . assertContains (
2012-12-24 01:32:04 +00:00
response , ' ?release_date__month= %d &release_date__year= %d " ' % (
date . month , date . year ) )
2010-12-12 22:54:50 +00:00
def assert_contains_day_link ( self , response , date ) :
self . assertContains (
2012-12-24 01:32:04 +00:00
response , ' ?release_date__day= %d & '
' release_date__month= %d &release_date__year= %d " ' % (
date . day , date . month , date . year ) )
2010-12-12 22:54:50 +00:00
def test_empty ( self ) :
"""
Ensure that no date hierarchy links display with empty changelist .
"""
response = self . client . get (
reverse ( ' admin:admin_views_podcast_changelist ' ) )
self . assertNotContains ( response , ' release_date__year= ' )
self . assertNotContains ( response , ' release_date__month= ' )
self . assertNotContains ( response , ' release_date__day= ' )
def test_single ( self ) :
"""
Ensure that single day - level date hierarchy appears for single object .
"""
DATE = datetime . date ( 2000 , 6 , 30 )
Podcast . objects . create ( release_date = DATE )
2011-02-08 12:00:01 +00:00
url = reverse ( ' admin:admin_views_podcast_changelist ' )
response = self . client . get ( url )
2010-12-12 22:54:50 +00:00
self . assert_contains_day_link ( response , DATE )
2011-02-08 12:20:18 +00:00
self . assert_non_localized_year ( response , 2000 )
2010-12-12 22:54:50 +00:00
def test_within_month ( self ) :
"""
Ensure that day - level links appear for changelist within single month .
"""
DATES = ( datetime . date ( 2000 , 6 , 30 ) ,
datetime . date ( 2000 , 6 , 15 ) ,
datetime . date ( 2000 , 6 , 3 ) )
for date in DATES :
Podcast . objects . create ( release_date = date )
2011-02-08 12:00:01 +00:00
url = reverse ( ' admin:admin_views_podcast_changelist ' )
response = self . client . get ( url )
2010-12-12 22:54:50 +00:00
for date in DATES :
self . assert_contains_day_link ( response , date )
2011-02-08 12:20:18 +00:00
self . assert_non_localized_year ( response , 2000 )
2010-12-12 22:54:50 +00:00
def test_within_year ( self ) :
"""
Ensure that month - level links appear for changelist within single year .
"""
DATES = ( datetime . date ( 2000 , 1 , 30 ) ,
datetime . date ( 2000 , 3 , 15 ) ,
datetime . date ( 2000 , 5 , 3 ) )
for date in DATES :
Podcast . objects . create ( release_date = date )
2011-02-08 12:00:01 +00:00
url = reverse ( ' admin:admin_views_podcast_changelist ' )
response = self . client . get ( url )
2010-12-12 22:54:50 +00:00
# no day-level links
self . assertNotContains ( response , ' release_date__day= ' )
for date in DATES :
self . assert_contains_month_link ( response , date )
2011-02-08 12:20:18 +00:00
self . assert_non_localized_year ( response , 2000 )
2010-12-12 22:54:50 +00:00
def test_multiple_years ( self ) :
"""
Ensure that year - level links appear for year - spanning changelist .
"""
DATES = ( datetime . date ( 2001 , 1 , 30 ) ,
datetime . date ( 2003 , 3 , 15 ) ,
datetime . date ( 2005 , 5 , 3 ) )
for date in DATES :
Podcast . objects . create ( release_date = date )
response = self . client . get (
reverse ( ' admin:admin_views_podcast_changelist ' ) )
# no day/month-level links
self . assertNotContains ( response , ' release_date__day= ' )
self . assertNotContains ( response , ' release_date__month= ' )
for date in DATES :
self . assert_contains_year_link ( response , date )
# and make sure GET parameters still behave correctly
for date in DATES :
2011-02-08 12:00:01 +00:00
url = ' %s ?release_date__year= %d ' % (
reverse ( ' admin:admin_views_podcast_changelist ' ) ,
date . year )
response = self . client . get ( url )
2010-12-12 22:54:50 +00:00
self . assert_contains_month_link ( response , date )
2011-02-08 12:20:18 +00:00
self . assert_non_localized_year ( response , 2000 )
self . assert_non_localized_year ( response , 2003 )
self . assert_non_localized_year ( response , 2005 )
2011-02-08 12:00:01 +00:00
url = ' %s ?release_date__year= %d &release_date__month= %d ' % (
reverse ( ' admin:admin_views_podcast_changelist ' ) ,
date . year , date . month )
response = self . client . get ( url )
2010-12-12 22:54:50 +00:00
self . assert_contains_day_link ( response , date )
2011-02-08 12:20:18 +00:00
self . assert_non_localized_year ( response , 2000 )
self . assert_non_localized_year ( response , 2003 )
self . assert_non_localized_year ( response , 2005 )
2011-07-03 17:56:43 +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
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2011-07-03 17:56:43 +00:00
class AdminCustomSaveRelatedTests ( TestCase ) :
"""
Ensure that one can easily customize the way related objects are saved .
Refs #16115.
"""
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2011-07-03 17:56:43 +00:00
fixtures = [ ' admin-views-users.xml ' ]
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def test_should_be_able_to_edit_related_objects_on_add_view ( self ) :
post = {
' child_set-TOTAL_FORMS ' : ' 3 ' ,
' child_set-INITIAL_FORMS ' : ' 0 ' ,
' name ' : ' Josh Stone ' ,
' child_set-0-name ' : ' Paul ' ,
' child_set-1-name ' : ' Catherine ' ,
}
2013-09-08 19:20:01 +00:00
self . client . post ( ' /test_admin/admin/admin_views/parent/add/ ' , post )
2011-07-03 17:56:43 +00:00
self . assertEqual ( 1 , Parent . objects . count ( ) )
self . assertEqual ( 2 , Child . objects . count ( ) )
children_names = list ( Child . objects . order_by ( ' name ' ) . values_list ( ' name ' , flat = True ) )
self . assertEqual ( ' Josh Stone ' , Parent . objects . latest ( ' id ' ) . name )
2012-06-07 16:08:47 +00:00
self . assertEqual ( [ ' Catherine Stone ' , ' Paul Stone ' ] , children_names )
2011-07-03 17:56:43 +00:00
def test_should_be_able_to_edit_related_objects_on_change_view ( self ) :
parent = Parent . objects . create ( name = ' Josh Stone ' )
paul = Child . objects . create ( parent = parent , name = ' Paul ' )
catherine = Child . objects . create ( parent = parent , name = ' Catherine ' )
post = {
' child_set-TOTAL_FORMS ' : ' 5 ' ,
' child_set-INITIAL_FORMS ' : ' 2 ' ,
' name ' : ' Josh Stone ' ,
' child_set-0-name ' : ' Paul ' ,
' child_set-0-id ' : paul . id ,
' child_set-1-name ' : ' Catherine ' ,
' child_set-1-id ' : catherine . id ,
}
2013-09-08 19:20:01 +00:00
self . client . post ( ' /test_admin/admin/admin_views/parent/ %s / ' % parent . id , post )
2011-07-03 17:56:43 +00:00
children_names = list ( Child . objects . order_by ( ' name ' ) . values_list ( ' name ' , flat = True ) )
self . assertEqual ( ' Josh Stone ' , Parent . objects . latest ( ' id ' ) . name )
2012-06-07 16:08:47 +00:00
self . assertEqual ( [ ' Catherine Stone ' , ' Paul Stone ' ] , children_names )
2011-08-12 14:14:24 +00:00
def test_should_be_able_to_edit_related_objects_on_changelist_view ( self ) :
parent = Parent . objects . create ( name = ' Josh Rock ' )
2013-09-08 19:20:01 +00:00
Child . objects . create ( parent = parent , name = ' Paul ' )
Child . objects . create ( parent = parent , name = ' Catherine ' )
2011-08-12 14:14:24 +00:00
post = {
' form-TOTAL_FORMS ' : ' 1 ' ,
' form-INITIAL_FORMS ' : ' 1 ' ,
' form-MAX_NUM_FORMS ' : ' 0 ' ,
' form-0-id ' : parent . id ,
' form-0-name ' : ' Josh Stone ' ,
' _save ' : ' Save '
}
2013-09-08 19:20:01 +00:00
self . client . post ( ' /test_admin/admin/admin_views/parent/ ' , post )
2011-08-12 14:14:24 +00:00
children_names = list ( Child . objects . order_by ( ' name ' ) . values_list ( ' name ' , flat = True ) )
self . assertEqual ( ' Josh Stone ' , Parent . objects . latest ( ' id ' ) . name )
2012-06-07 16:08:47 +00:00
self . assertEqual ( [ ' Catherine Stone ' , ' Paul Stone ' ] , children_names )
2012-02-09 18:56:23 +00:00
2012-04-30 18:38:44 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
2012-02-09 18:56:23 +00:00
class AdminViewLogoutTest ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2012-02-09 18:56:23 +00:00
fixtures = [ ' admin-views-users.xml ' ]
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
def test_client_logout_url_can_be_used_to_login ( self ) :
response = self . client . get ( ' /test_admin/admin/logout/ ' )
self . assertEqual ( response . status_code , 200 )
2013-04-10 08:16:15 +00:00
self . assertTemplateUsed ( response , ' registration/logged_out.html ' )
2012-02-09 18:56:23 +00:00
self . assertEqual ( response . request [ ' PATH_INFO ' ] , ' /test_admin/admin/logout/ ' )
# we are now logged out
response = self . client . get ( ' /test_admin/admin/logout/ ' )
self . assertEqual ( response . status_code , 302 ) # we should be redirected to the login page.
# follow the redirect and test results.
response = self . client . get ( ' /test_admin/admin/logout/ ' , follow = True )
self . assertEqual ( response . status_code , 200 )
2013-04-10 08:16:15 +00:00
self . assertTemplateUsed ( response , ' admin/login.html ' )
2012-02-09 18:56:23 +00:00
self . assertEqual ( response . request [ ' PATH_INFO ' ] , ' /test_admin/admin/ ' )
self . assertContains ( response , ' <input type= " hidden " name= " next " value= " /test_admin/admin/ " /> ' )
2012-11-17 21:53:31 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
class AdminUserMessageTest ( TestCase ) :
2013-02-26 12:19:18 +00:00
urls = " admin_views.urls "
2012-11-17 21:53:31 +00:00
fixtures = [ ' admin-views-users.xml ' ]
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
def send_message ( self , level ) :
"""
Helper that sends a post to the dummy test methods and asserts that a
message with the level has appeared in the response .
"""
action_data = {
ACTION_CHECKBOX_NAME : [ 1 ] ,
' action ' : ' message_ %s ' % level ,
' index ' : 0 ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/usermessenger/ ' ,
action_data , follow = True )
self . assertContains ( response ,
' <li class= " %s " >Test %s </li> ' % ( level , level ) ,
html = True )
@override_settings ( MESSAGE_LEVEL = 10 ) # Set to DEBUG for this request
def test_message_debug ( self ) :
self . send_message ( ' debug ' )
def test_message_info ( self ) :
self . send_message ( ' info ' )
def test_message_success ( self ) :
self . send_message ( ' success ' )
def test_message_warning ( self ) :
self . send_message ( ' warning ' )
def test_message_error ( self ) :
self . send_message ( ' error ' )
def test_message_extra_tags ( self ) :
action_data = {
ACTION_CHECKBOX_NAME : [ 1 ] ,
' action ' : ' message_extra_tags ' ,
' index ' : 0 ,
}
response = self . client . post ( ' /test_admin/admin/admin_views/usermessenger/ ' ,
action_data , follow = True )
self . assertContains ( response ,
' <li class= " extra_tag info " >Test tags</li> ' ,
html = True )
2013-06-18 19:41:36 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
class AdminKeepChangeListFiltersTests ( TestCase ) :
urls = " admin_views.urls "
fixtures = [ ' admin-views-users.xml ' ]
2013-07-18 19:17:40 +00:00
admin_site = site
2013-06-18 19:41:36 +00:00
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def tearDown ( self ) :
self . client . logout ( )
def get_changelist_filters_querystring ( self ) :
return urlencode ( {
' is_superuser__exact ' : 0 ,
' is_staff__exact ' : 0 ,
} )
def get_preserved_filters_querystring ( self ) :
return urlencode ( {
' _changelist_filters ' : self . get_changelist_filters_querystring ( )
} )
def get_sample_user_id ( self ) :
return 104
def get_changelist_url ( self ) :
return ' %s ? %s ' % (
2013-07-18 19:17:40 +00:00
reverse ( ' admin:auth_user_changelist ' ,
current_app = self . admin_site . name ) ,
2013-06-18 19:41:36 +00:00
self . get_changelist_filters_querystring ( ) ,
)
def get_add_url ( self ) :
return ' %s ? %s ' % (
2013-07-18 19:17:40 +00:00
reverse ( ' admin:auth_user_add ' ,
current_app = self . admin_site . name ) ,
2013-06-18 19:41:36 +00:00
self . get_preserved_filters_querystring ( ) ,
)
def get_change_url ( self , user_id = None ) :
if user_id is None :
user_id = self . get_sample_user_id ( )
return " %s ? %s " % (
2013-07-18 19:17:40 +00:00
reverse ( ' admin:auth_user_change ' , args = ( user_id , ) ,
current_app = self . admin_site . name ) ,
2013-06-18 19:41:36 +00:00
self . get_preserved_filters_querystring ( ) ,
)
def get_history_url ( self , user_id = None ) :
if user_id is None :
user_id = self . get_sample_user_id ( )
return " %s ? %s " % (
2013-07-18 19:17:40 +00:00
reverse ( ' admin:auth_user_history ' , args = ( user_id , ) ,
current_app = self . admin_site . name ) ,
2013-06-18 19:41:36 +00:00
self . get_preserved_filters_querystring ( ) ,
)
def get_delete_url ( self , user_id = None ) :
if user_id is None :
user_id = self . get_sample_user_id ( )
return " %s ? %s " % (
2013-07-18 19:17:40 +00:00
reverse ( ' admin:auth_user_delete ' , args = ( user_id , ) ,
current_app = self . admin_site . name ) ,
2013-06-18 19:41:36 +00:00
self . get_preserved_filters_querystring ( ) ,
)
def test_changelist_view ( self ) :
response = self . client . get ( self . get_changelist_url ( ) )
self . assertEqual ( response . status_code , 200 )
# Check the `change_view` link has the correct querystring.
detail_link = """ <a href= " %s " >joepublic</a> """ % self . get_change_url ( )
self . assertContains ( response , detail_link , count = 1 )
def test_change_view ( self ) :
# Get the `change_view`.
response = self . client . get ( self . get_change_url ( ) )
self . assertEqual ( response . status_code , 200 )
# Check the form action.
form_action = """ <form enctype= " multipart/form-data " action= " ? %s " method= " post " id= " user_form " > """ % self . get_preserved_filters_querystring ( )
self . assertContains ( response , form_action , count = 1 )
# Check the history link.
history_link = """ <a href= " %s " class= " historylink " >History</a> """ % self . get_history_url ( )
self . assertContains ( response , history_link , count = 1 )
# Check the delete link.
delete_link = """ <a href= " %s " class= " deletelink " >Delete</a> """ % ( self . get_delete_url ( ) )
self . assertContains ( response , delete_link , count = 1 )
# Test redirect on "Save".
post_data = {
' username ' : ' joepublic ' ,
' last_login_0 ' : ' 2007-05-30 ' ,
' last_login_1 ' : ' 13:20:10 ' ,
' date_joined_0 ' : ' 2007-05-30 ' ,
' date_joined_1 ' : ' 13:20:10 ' ,
}
post_data [ ' _save ' ] = 1
response = self . client . post ( self . get_change_url ( ) , data = post_data )
self . assertRedirects ( response , self . get_changelist_url ( ) )
post_data . pop ( ' _save ' )
# Test redirect on "Save and continue".
post_data [ ' _continue ' ] = 1
response = self . client . post ( self . get_change_url ( ) , data = post_data )
self . assertRedirects ( response , self . get_change_url ( ) )
post_data . pop ( ' _continue ' )
# Test redirect on "Save and add new".
post_data [ ' _addanother ' ] = 1
response = self . client . post ( self . get_change_url ( ) , data = post_data )
self . assertRedirects ( response , self . get_add_url ( ) )
post_data . pop ( ' _addanother ' )
def test_add_view ( self ) :
# Get the `add_view`.
response = self . client . get ( self . get_add_url ( ) )
self . assertEqual ( response . status_code , 200 )
2013-02-26 03:27:52 +00:00
2013-06-18 19:41:36 +00:00
# Check the form action.
form_action = """ <form enctype= " multipart/form-data " action= " ? %s " method= " post " id= " user_form " > """ % self . get_preserved_filters_querystring ( )
self . assertContains ( response , form_action , count = 1 )
# Test redirect on "Save".
post_data = {
' username ' : ' dummy ' ,
' password1 ' : ' test ' ,
' password2 ' : ' test ' ,
}
post_data [ ' _save ' ] = 1
response = self . client . post ( self . get_add_url ( ) , data = post_data )
2013-06-19 09:13:43 +00:00
self . assertRedirects ( response , self . get_change_url ( User . objects . latest ( ' pk ' ) . pk ) )
2013-06-18 19:41:36 +00:00
post_data . pop ( ' _save ' )
# Test redirect on "Save and continue".
post_data [ ' username ' ] = ' dummy2 '
post_data [ ' _continue ' ] = 1
response = self . client . post ( self . get_add_url ( ) , data = post_data )
2013-06-19 09:13:43 +00:00
self . assertRedirects ( response , self . get_change_url ( User . objects . latest ( ' pk ' ) . pk ) )
2013-06-18 19:41:36 +00:00
post_data . pop ( ' _continue ' )
# Test redirect on "Save and add new".
post_data [ ' username ' ] = ' dummy3 '
post_data [ ' _addanother ' ] = 1
response = self . client . post ( self . get_add_url ( ) , data = post_data )
self . assertRedirects ( response , self . get_add_url ( ) )
post_data . pop ( ' _addanother ' )
def test_delete_view ( self ) :
# Test redirect on "Delete".
response = self . client . post ( self . get_delete_url ( ) , { ' post ' : ' yes ' } )
self . assertRedirects ( response , self . get_changelist_url ( ) )
2013-07-18 19:17:40 +00:00
2013-02-23 17:57:48 +00:00
2013-07-18 19:17:40 +00:00
class NamespacedAdminKeepChangeListFiltersTests ( AdminKeepChangeListFiltersTests ) :
admin_site = site2
2013-02-23 17:57:48 +00:00
@override_settings ( PASSWORD_HASHERS = ( ' django.contrib.auth.hashers.SHA1PasswordHasher ' , ) )
class TestLabelVisibility ( TestCase ) :
""" #11277 -Labels of hidden fields in admin were not hidden. """
urls = " admin_views.urls "
fixtures = [ ' admin-views-users.xml ' ]
def setUp ( self ) :
self . client . login ( username = ' super ' , password = ' secret ' )
def test_all_fields_visible ( self ) :
response = self . client . get ( ' /test_admin/admin/admin_views/emptymodelvisible/add/ ' )
self . assert_fieldline_visible ( response )
self . assert_field_visible ( response , ' first ' )
self . assert_field_visible ( response , ' second ' )
def test_all_fields_hidden ( self ) :
response = self . client . get ( ' /test_admin/admin/admin_views/emptymodelhidden/add/ ' )
self . assert_fieldline_hidden ( response )
self . assert_field_hidden ( response , ' first ' )
self . assert_field_hidden ( response , ' second ' )
def test_mixin ( self ) :
response = self . client . get ( ' /test_admin/admin/admin_views/emptymodelmixin/add/ ' )
self . assert_fieldline_visible ( response )
self . assert_field_hidden ( response , ' first ' )
self . assert_field_visible ( response , ' second ' )
def assert_field_visible ( self , response , field_name ) :
self . assertContains ( response , ' <div class= " field-box field- %s " > ' % field_name )
def assert_field_hidden ( self , response , field_name ) :
self . assertContains ( response , ' <div class= " field-box field- %s hidden " > ' % field_name )
def assert_fieldline_visible ( self , response ) :
self . assertContains ( response , ' <div class= " form-row field-first field-second " > ' )
def assert_fieldline_hidden ( self , response ) :
self . assertContains ( response , ' <div class= " form-row hidden ' )