Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removed custom profile model functionality as per deprecation TL.

  • Loading branch information...
commit c196564132a351549245a5d795391ad1ea56195c 1 parent 5e08b79
@ramiro ramiro authored
View
32 django/contrib/auth/models.py
@@ -413,38 +413,6 @@ def email_user(self, subject, message, from_email=None):
"""
send_mail(subject, message, from_email, [self.email])
- def get_profile(self):
- """
- Returns site-specific profile for this user. Raises
- SiteProfileNotAvailable if this site does not allow profiles.
- """
- warnings.warn("The use of AUTH_PROFILE_MODULE to define user profiles has been deprecated.",
- DeprecationWarning, stacklevel=2)
- if not hasattr(self, '_profile_cache'):
- from django.conf import settings
- if not getattr(settings, 'AUTH_PROFILE_MODULE', False):
- raise SiteProfileNotAvailable(
- 'You need to set AUTH_PROFILE_MODULE in your project '
- 'settings')
- try:
- app_label, model_name = settings.AUTH_PROFILE_MODULE.split('.')
- except ValueError:
- raise SiteProfileNotAvailable(
- 'app_label and model_name should be separated by a dot in '
- 'the AUTH_PROFILE_MODULE setting')
- try:
- model = models.get_model(app_label, model_name)
- if model is None:
- raise SiteProfileNotAvailable(
- 'Unable to load the profile model, check '
- 'AUTH_PROFILE_MODULE in your project settings')
- self._profile_cache = model._default_manager.using(
- self._state.db).get(user__id__exact=self.id)
- self._profile_cache.user = self
- except (ImportError, ImproperlyConfigured):
- raise SiteProfileNotAvailable
- return self._profile_cache
-
class User(AbstractUser):
"""
View
39 django/contrib/auth/tests/test_models.py
@@ -1,46 +1,9 @@
-import warnings
-
-from django.conf import settings
from django.contrib.auth import get_user_model
-from django.contrib.auth.models import (Group, User, SiteProfileNotAvailable,
- UserManager)
+from django.contrib.auth.models import (Group, User, UserManager)
from django.contrib.auth.tests.utils import skipIfCustomUser
from django.db.models.signals import post_save
from django.test import TestCase
from django.test.utils import override_settings
-from django.utils import six
-
-
-@skipIfCustomUser
-@override_settings(USE_TZ=False, AUTH_PROFILE_MODULE='')
-class ProfileTestCase(TestCase):
-
- def test_site_profile_not_available(self):
- user = User.objects.create(username='testclient')
-
- # calling get_profile without AUTH_PROFILE_MODULE set
- del settings.AUTH_PROFILE_MODULE
- with warnings.catch_warnings():
- warnings.simplefilter("ignore", DeprecationWarning)
- with six.assertRaisesRegex(self, SiteProfileNotAvailable,
- "You need to set AUTH_PROFILE_MODULE in your project"):
- user.get_profile()
-
- # Bad syntax in AUTH_PROFILE_MODULE:
- settings.AUTH_PROFILE_MODULE = 'foobar'
- with warnings.catch_warnings():
- warnings.simplefilter("ignore", DeprecationWarning)
- with six.assertRaisesRegex(self, SiteProfileNotAvailable,
- "app_label and model_name should be separated by a dot"):
- user.get_profile()
-
- # module that doesn't exist
- settings.AUTH_PROFILE_MODULE = 'foo.bar'
- with warnings.catch_warnings():
- warnings.simplefilter("ignore", DeprecationWarning)
- with six.assertRaisesRegex(self, SiteProfileNotAvailable,
- "Unable to load the profile model"):
- user.get_profile()
@skipIfCustomUser
View
14 docs/ref/contrib/auth.txt
@@ -218,20 +218,6 @@ Methods
Sends an email to the user. If ``from_email`` is ``None``, Django uses
the :setting:`DEFAULT_FROM_EMAIL`.
- .. method:: get_profile()
-
- .. deprecated:: 1.5
- With the introduction of :ref:`custom User models <auth-custom-user>`,
- the use of :setting:`AUTH_PROFILE_MODULE` to define a single profile
- model is no longer supported. See the
- :doc:`Django 1.5 release notes</releases/1.5>` for more information.
-
- Returns a site-specific profile for this user. Raises
- ``django.contrib.auth.models.SiteProfileNotAvailable`` if the
- current site doesn't allow profiles, or
- :exc:`django.core.exceptions.ObjectDoesNotExist` if the user does not
- have a profile.
-
Manager methods
---------------
View
16 docs/ref/settings.txt
@@ -2049,22 +2049,6 @@ A tuple of authentication backend classes (as strings) to use when attempting to
authenticate a user. See the :ref:`authentication backends documentation
<authentication-backends>` for details.
-.. setting:: AUTH_PROFILE_MODULE
-
-AUTH_PROFILE_MODULE
--------------------
-
-.. deprecated:: 1.5
- With the introduction of :ref:`custom User models <auth-custom-user>`,
- the use of :setting:`AUTH_PROFILE_MODULE` to define a single profile
- model is no longer supported. See the
- :doc:`Django 1.5 release notes</releases/1.5>` for more information.
-
-Default: Not defined
-
-The site-specific user profile model used by this site. See
-:ref:`User profiles <auth-profiles>`.
-
.. setting:: AUTH_USER_MODEL
AUTH_USER_MODEL
View
8 docs/releases/1.5-alpha-1.txt
@@ -575,8 +575,8 @@ Miscellaneous
Features deprecated in 1.5
==========================
-:setting:`AUTH_PROFILE_MODULE`
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+``AUTH_PROFILE_MODULE`` setting
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
With the introduction of :ref:`custom User models <auth-custom-user>`, there is
no longer any need for a built-in mechanism to store user profile data.
@@ -584,8 +584,8 @@ no longer any need for a built-in mechanism to store user profile data.
You can still define user profiles models that have a one-to-one relation with
the User model - in fact, for many applications needing to associate data with
a User account, this will be an appropriate design pattern to follow. However,
-the :setting:`AUTH_PROFILE_MODULE` setting, and the
-:meth:`~django.contrib.auth.models.User.get_profile()` method for accessing
+the ``AUTH_PROFILE_MODULE`` setting, and the
+``django.contrib.auth.models.User.get_profile()`` method for accessing
the user profile model, should not be used any longer.
Streaming behavior of :class:`~django.http.HttpResponse`
View
8 docs/releases/1.5-beta-1.txt
@@ -627,8 +627,8 @@ Features deprecated in 1.5
.. _simplejson-deprecation-beta-1:
-:setting:`AUTH_PROFILE_MODULE`
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+``AUTH_PROFILE_MODULE``
+~~~~~~~~~~~~~~~~~~~~~~~
With the introduction of :ref:`custom User models <auth-custom-user>`, there is
no longer any need for a built-in mechanism to store user profile data.
@@ -636,8 +636,8 @@ no longer any need for a built-in mechanism to store user profile data.
You can still define user profiles models that have a one-to-one relation with
the User model - in fact, for many applications needing to associate data with
a User account, this will be an appropriate design pattern to follow. However,
-the :setting:`AUTH_PROFILE_MODULE` setting, and the
-:meth:`~django.contrib.auth.models.User.get_profile()` method for accessing
+the ``AUTH_PROFILE_MODULE`` setting, and the
+``django.contrib.auth.models.User.get_profile()`` method for accessing
the user profile model, should not be used any longer.
Streaming behavior of :class:`~django.http.HttpResponse`
View
8 docs/releases/1.5.txt
@@ -732,8 +732,8 @@ deprecation schedule. Direct use of python markup libraries or 3rd party tag
libraries is preferred to Django maintaining this functionality in the
framework.
-:setting:`AUTH_PROFILE_MODULE`
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+``AUTH_PROFILE_MODULE``
+~~~~~~~~~~~~~~~~~~~~~~~
With the introduction of :ref:`custom User models <auth-custom-user>`, there is
no longer any need for a built-in mechanism to store user profile data.
@@ -741,8 +741,8 @@ no longer any need for a built-in mechanism to store user profile data.
You can still define user profiles models that have a one-to-one relation with
the User model - in fact, for many applications needing to associate data with
a User account, this will be an appropriate design pattern to follow. However,
-the :setting:`AUTH_PROFILE_MODULE` setting, and the
-:meth:`~django.contrib.auth.models.User.get_profile()` method for accessing
+the ``AUTH_PROFILE_MODULE`` setting, and the
+``django.contrib.auth.models.User.get_profile()`` method for accessing
the user profile model, should not be used any longer.
Streaming behavior of :class:`~django.http.HttpResponse`
View
34 docs/topics/auth/customizing.txt
@@ -354,40 +354,6 @@ model and adding the related fields may be your better option. However
existing links to the default User model within your project's apps may justify
the extra database load.
-.. _auth-profiles:
-
-.. deprecated:: 1.5
- With the introduction of :ref:`custom User models <auth-custom-user>`,
- the use of :setting:`AUTH_PROFILE_MODULE` to define a single profile
- model is no longer supported. See the
- :doc:`Django 1.5 release notes</releases/1.5>` for more information.
-
-Prior to 1.5, a single profile model could be specified site-wide with the
-setting :setting:`AUTH_PROFILE_MODULE` with a string consisting of the
-following items, separated by a dot:
-
-1. The name of the application (case sensitive) in which the user
- profile model is defined (in other words, the
- name which was passed to :djadmin:`manage.py startapp <startapp>` to create
- the application).
-
-2. The name of the model (not case sensitive) class.
-
-For example, if the profile model was a class named ``UserProfile`` and was
-defined inside an application named ``accounts``, the appropriate setting would
-be::
-
- AUTH_PROFILE_MODULE = 'accounts.UserProfile'
-
-When a user profile model has been defined and specified in this manner, each
-:class:`~django.contrib.auth.models.User` object will have a method --
-:class:`~django.contrib.auth.models.User.get_profile()` -- which returns the
-instance of the user profile model associated with that
-:class:`~django.contrib.auth.models.User`.
-
-The method :class:`~django.contrib.auth.models.User.get_profile()`
-does not create a profile if one does not exist.
-
.. _auth-custom-user:
Substituting a custom User model
View
21 tests/multiple_database/tests.py
@@ -3,9 +3,7 @@
import datetime
import pickle
from operator import attrgetter
-import warnings
-from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.core import management
@@ -1626,25 +1624,6 @@ def test_dumpdata(self):
command_output = new_io.getvalue().strip()
self.assertTrue('"email": "alice@example.com"' in command_output)
-
-@override_settings(AUTH_PROFILE_MODULE='multiple_database.UserProfile')
-class UserProfileTestCase(TestCase):
-
- def test_user_profiles(self):
- alice = User.objects.create_user('alice', 'alice@example.com')
- bob = User.objects.db_manager('other').create_user('bob', 'bob@example.com')
-
- alice_profile = UserProfile(user=alice, flavor='chocolate')
- alice_profile.save()
-
- bob_profile = UserProfile(user=bob, flavor='crunchy frog')
- bob_profile.save()
-
- with warnings.catch_warnings():
- warnings.simplefilter("ignore", DeprecationWarning)
- self.assertEqual(alice.get_profile().flavor, 'chocolate')
- self.assertEqual(bob.get_profile().flavor, 'crunchy frog')
-
class AntiPetRouter(object):
# A router that only expresses an opinion on syncdb,
# passing pets to the 'other' database
Please sign in to comment.
Something went wrong with that request. Please try again.