Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Removed custom profile model functionality as per deprecation TL.

  • Loading branch information...
commit c196564132a351549245a5d795391ad1ea56195c 1 parent 5e08b79
Ramiro Morales authored June 28, 2013
32  django/contrib/auth/models.py
@@ -413,38 +413,6 @@ def email_user(self, subject, message, from_email=None):
413 413
         """
414 414
         send_mail(subject, message, from_email, [self.email])
415 415
 
416  
-    def get_profile(self):
417  
-        """
418  
-        Returns site-specific profile for this user. Raises
419  
-        SiteProfileNotAvailable if this site does not allow profiles.
420  
-        """
421  
-        warnings.warn("The use of AUTH_PROFILE_MODULE to define user profiles has been deprecated.",
422  
-            DeprecationWarning, stacklevel=2)
423  
-        if not hasattr(self, '_profile_cache'):
424  
-            from django.conf import settings
425  
-            if not getattr(settings, 'AUTH_PROFILE_MODULE', False):
426  
-                raise SiteProfileNotAvailable(
427  
-                    'You need to set AUTH_PROFILE_MODULE in your project '
428  
-                    'settings')
429  
-            try:
430  
-                app_label, model_name = settings.AUTH_PROFILE_MODULE.split('.')
431  
-            except ValueError:
432  
-                raise SiteProfileNotAvailable(
433  
-                    'app_label and model_name should be separated by a dot in '
434  
-                    'the AUTH_PROFILE_MODULE setting')
435  
-            try:
436  
-                model = models.get_model(app_label, model_name)
437  
-                if model is None:
438  
-                    raise SiteProfileNotAvailable(
439  
-                        'Unable to load the profile model, check '
440  
-                        'AUTH_PROFILE_MODULE in your project settings')
441  
-                self._profile_cache = model._default_manager.using(
442  
-                                   self._state.db).get(user__id__exact=self.id)
443  
-                self._profile_cache.user = self
444  
-            except (ImportError, ImproperlyConfigured):
445  
-                raise SiteProfileNotAvailable
446  
-        return self._profile_cache
447  
-
448 416
 
449 417
 class User(AbstractUser):
450 418
     """
39  django/contrib/auth/tests/test_models.py
... ...
@@ -1,46 +1,9 @@
1  
-import warnings
2  
-
3  
-from django.conf import settings
4 1
 from django.contrib.auth import get_user_model
5  
-from django.contrib.auth.models import (Group, User, SiteProfileNotAvailable,
6  
-    UserManager)
  2
+from django.contrib.auth.models import (Group, User, UserManager)
7 3
 from django.contrib.auth.tests.utils import skipIfCustomUser
8 4
 from django.db.models.signals import post_save
9 5
 from django.test import TestCase
10 6
 from django.test.utils import override_settings
11  
-from django.utils import six
12  
-
13  
-
14  
-@skipIfCustomUser
15  
-@override_settings(USE_TZ=False, AUTH_PROFILE_MODULE='')
16  
-class ProfileTestCase(TestCase):
17  
-
18  
-    def test_site_profile_not_available(self):
19  
-        user = User.objects.create(username='testclient')
20  
-
21  
-        # calling get_profile without AUTH_PROFILE_MODULE set
22  
-        del settings.AUTH_PROFILE_MODULE
23  
-        with warnings.catch_warnings():
24  
-            warnings.simplefilter("ignore", DeprecationWarning)
25  
-            with six.assertRaisesRegex(self, SiteProfileNotAvailable,
26  
-                    "You need to set AUTH_PROFILE_MODULE in your project"):
27  
-                user.get_profile()
28  
-
29  
-        # Bad syntax in AUTH_PROFILE_MODULE:
30  
-        settings.AUTH_PROFILE_MODULE = 'foobar'
31  
-        with warnings.catch_warnings():
32  
-            warnings.simplefilter("ignore", DeprecationWarning)
33  
-            with six.assertRaisesRegex(self, SiteProfileNotAvailable,
34  
-                    "app_label and model_name should be separated by a dot"):
35  
-                user.get_profile()
36  
-
37  
-        # module that doesn't exist
38  
-        settings.AUTH_PROFILE_MODULE = 'foo.bar'
39  
-        with warnings.catch_warnings():
40  
-            warnings.simplefilter("ignore", DeprecationWarning)
41  
-            with six.assertRaisesRegex(self, SiteProfileNotAvailable,
42  
-                    "Unable to load the profile model"):
43  
-                user.get_profile()
44 7
 
45 8
 
46 9
 @skipIfCustomUser
14  docs/ref/contrib/auth.txt
@@ -218,20 +218,6 @@ Methods
218 218
         Sends an email to the user. If ``from_email`` is ``None``, Django uses
219 219
         the :setting:`DEFAULT_FROM_EMAIL`.
220 220
 
221  
-    .. method:: get_profile()
222  
-
223  
-        .. deprecated:: 1.5
224  
-            With the introduction of :ref:`custom User models <auth-custom-user>`,
225  
-            the use of :setting:`AUTH_PROFILE_MODULE` to define a single profile
226  
-            model is no longer supported. See the
227  
-            :doc:`Django 1.5 release notes</releases/1.5>` for more information.
228  
-
229  
-        Returns a site-specific profile for this user. Raises
230  
-        ``django.contrib.auth.models.SiteProfileNotAvailable`` if the
231  
-        current site doesn't allow profiles, or
232  
-        :exc:`django.core.exceptions.ObjectDoesNotExist` if the user does not
233  
-        have a profile.
234  
-
235 221
 Manager methods
236 222
 ---------------
237 223
 
16  docs/ref/settings.txt
@@ -2049,22 +2049,6 @@ A tuple of authentication backend classes (as strings) to use when attempting to
2049 2049
 authenticate a user. See the :ref:`authentication backends documentation
2050 2050
 <authentication-backends>` for details.
2051 2051
 
2052  
-.. setting:: AUTH_PROFILE_MODULE
2053  
-
2054  
-AUTH_PROFILE_MODULE
2055  
--------------------
2056  
-
2057  
-.. deprecated:: 1.5
2058  
-    With the introduction of :ref:`custom User models <auth-custom-user>`,
2059  
-    the use of :setting:`AUTH_PROFILE_MODULE` to define a single profile
2060  
-    model is no longer supported. See the
2061  
-    :doc:`Django 1.5 release notes</releases/1.5>` for more information.
2062  
-
2063  
-Default: Not defined
2064  
-
2065  
-The site-specific user profile model used by this site. See
2066  
-:ref:`User profiles <auth-profiles>`.
2067  
-
2068 2052
 .. setting:: AUTH_USER_MODEL
2069 2053
 
2070 2054
 AUTH_USER_MODEL
8  docs/releases/1.5-alpha-1.txt
@@ -575,8 +575,8 @@ Miscellaneous
575 575
 Features deprecated in 1.5
576 576
 ==========================
577 577
 
578  
-:setting:`AUTH_PROFILE_MODULE`
579  
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  578
+``AUTH_PROFILE_MODULE`` setting
  579
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
580 580
 
581 581
 With the introduction of :ref:`custom User models <auth-custom-user>`, there is
582 582
 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.
584 584
 You can still define user profiles models that have a one-to-one relation with
585 585
 the User model - in fact, for many applications needing to associate data with
586 586
 a User account, this will be an appropriate design pattern to follow. However,
587  
-the :setting:`AUTH_PROFILE_MODULE` setting, and the
588  
-:meth:`~django.contrib.auth.models.User.get_profile()` method for accessing
  587
+the ``AUTH_PROFILE_MODULE`` setting, and the
  588
+``django.contrib.auth.models.User.get_profile()`` method for accessing
589 589
 the user profile model, should not be used any longer.
590 590
 
591 591
 Streaming behavior of :class:`~django.http.HttpResponse`
8  docs/releases/1.5-beta-1.txt
@@ -627,8 +627,8 @@ Features deprecated in 1.5
627 627
 
628 628
 .. _simplejson-deprecation-beta-1:
629 629
 
630  
-:setting:`AUTH_PROFILE_MODULE`
631  
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  630
+``AUTH_PROFILE_MODULE``
  631
+~~~~~~~~~~~~~~~~~~~~~~~
632 632
 
633 633
 With the introduction of :ref:`custom User models <auth-custom-user>`, there is
634 634
 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.
636 636
 You can still define user profiles models that have a one-to-one relation with
637 637
 the User model - in fact, for many applications needing to associate data with
638 638
 a User account, this will be an appropriate design pattern to follow. However,
639  
-the :setting:`AUTH_PROFILE_MODULE` setting, and the
640  
-:meth:`~django.contrib.auth.models.User.get_profile()` method for accessing
  639
+the ``AUTH_PROFILE_MODULE`` setting, and the
  640
+``django.contrib.auth.models.User.get_profile()`` method for accessing
641 641
 the user profile model, should not be used any longer.
642 642
 
643 643
 Streaming behavior of :class:`~django.http.HttpResponse`
8  docs/releases/1.5.txt
@@ -732,8 +732,8 @@ deprecation schedule. Direct use of python markup libraries or 3rd party tag
732 732
 libraries is preferred to Django maintaining this functionality in the
733 733
 framework.
734 734
 
735  
-:setting:`AUTH_PROFILE_MODULE`
736  
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  735
+``AUTH_PROFILE_MODULE``
  736
+~~~~~~~~~~~~~~~~~~~~~~~
737 737
 
738 738
 With the introduction of :ref:`custom User models <auth-custom-user>`, there is
739 739
 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.
741 741
 You can still define user profiles models that have a one-to-one relation with
742 742
 the User model - in fact, for many applications needing to associate data with
743 743
 a User account, this will be an appropriate design pattern to follow. However,
744  
-the :setting:`AUTH_PROFILE_MODULE` setting, and the
745  
-:meth:`~django.contrib.auth.models.User.get_profile()` method for accessing
  744
+the ``AUTH_PROFILE_MODULE`` setting, and the
  745
+``django.contrib.auth.models.User.get_profile()`` method for accessing
746 746
 the user profile model, should not be used any longer.
747 747
 
748 748
 Streaming behavior of :class:`~django.http.HttpResponse`
34  docs/topics/auth/customizing.txt
@@ -354,40 +354,6 @@ model and adding the related fields may be your better option.  However
354 354
 existing links to the default User model within your project's apps may justify
355 355
 the extra database load.
356 356
 
357  
-.. _auth-profiles:
358  
-
359  
-.. deprecated:: 1.5
360  
-    With the introduction of :ref:`custom User models <auth-custom-user>`,
361  
-    the use of :setting:`AUTH_PROFILE_MODULE` to define a single profile
362  
-    model is no longer supported. See the
363  
-    :doc:`Django 1.5 release notes</releases/1.5>` for more information.
364  
-
365  
-Prior to 1.5, a single profile model could be specified site-wide with the
366  
-setting :setting:`AUTH_PROFILE_MODULE` with a string consisting of the
367  
-following items, separated by a dot:
368  
-
369  
-1. The name of the application (case sensitive) in which the user
370  
-   profile model is defined (in other words, the
371  
-   name which was passed to :djadmin:`manage.py startapp <startapp>` to create
372  
-   the application).
373  
-
374  
-2. The name of the model (not case sensitive) class.
375  
-
376  
-For example, if the profile model was a class named ``UserProfile`` and was
377  
-defined inside an application named ``accounts``, the appropriate setting would
378  
-be::
379  
-
380  
-    AUTH_PROFILE_MODULE = 'accounts.UserProfile'
381  
-
382  
-When a user profile model has been defined and specified in this manner, each
383  
-:class:`~django.contrib.auth.models.User` object will have a method --
384  
-:class:`~django.contrib.auth.models.User.get_profile()` -- which returns the
385  
-instance of the user profile model associated with that
386  
-:class:`~django.contrib.auth.models.User`.
387  
-
388  
-The method :class:`~django.contrib.auth.models.User.get_profile()`
389  
-does not create a profile if one does not exist.
390  
-
391 357
 .. _auth-custom-user:
392 358
 
393 359
 Substituting a custom User model
21  tests/multiple_database/tests.py
@@ -3,9 +3,7 @@
3 3
 import datetime
4 4
 import pickle
5 5
 from operator import attrgetter
6  
-import warnings
7 6
 
8  
-from django.conf import settings
9 7
 from django.contrib.auth.models import User
10 8
 from django.contrib.contenttypes.models import ContentType
11 9
 from django.core import management
@@ -1626,25 +1624,6 @@ def test_dumpdata(self):
1626 1624
         command_output = new_io.getvalue().strip()
1627 1625
         self.assertTrue('"email": "alice@example.com"' in command_output)
1628 1626
 
1629  
-
1630  
-@override_settings(AUTH_PROFILE_MODULE='multiple_database.UserProfile')
1631  
-class UserProfileTestCase(TestCase):
1632  
-
1633  
-    def test_user_profiles(self):
1634  
-        alice = User.objects.create_user('alice', 'alice@example.com')
1635  
-        bob = User.objects.db_manager('other').create_user('bob', 'bob@example.com')
1636  
-
1637  
-        alice_profile = UserProfile(user=alice, flavor='chocolate')
1638  
-        alice_profile.save()
1639  
-
1640  
-        bob_profile = UserProfile(user=bob, flavor='crunchy frog')
1641  
-        bob_profile.save()
1642  
-
1643  
-        with warnings.catch_warnings():
1644  
-            warnings.simplefilter("ignore", DeprecationWarning)
1645  
-            self.assertEqual(alice.get_profile().flavor, 'chocolate')
1646  
-            self.assertEqual(bob.get_profile().flavor, 'crunchy frog')
1647  
-
1648 1627
 class AntiPetRouter(object):
1649 1628
     # A router that only expresses an opinion on syncdb,
1650 1629
     # passing pets to the 'other' database

0 notes on commit c196564

Please sign in to comment.
Something went wrong with that request. Please try again.