Skip to content

Commit

Permalink
Merge branch 'master' into schema-alteration
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgodwin committed Jul 2, 2013
2 parents 7a47ba6 + 6c66a41 commit b1e0ec0
Show file tree
Hide file tree
Showing 240 changed files with 694 additions and 4,096 deletions.
3 changes: 1 addition & 2 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Thanks for downloading Django.

To install it, make sure you have Python 2.6 or greater installed. Then run
To install it, make sure you have Python 2.7 or greater installed. Then run
this command from the command prompt:

python setup.py install
Expand All @@ -12,7 +12,6 @@ site-packages directory, which is located wherever your Python installation
lives. Some places you might check are:

/usr/lib/python2.7/site-packages (Unix, Python 2.7)
/usr/lib/python2.6/site-packages (Unix, Python 2.6)
C:\\PYTHON\site-packages (Windows)

For more detailed instructions, see docs/intro/install.txt.
19 changes: 0 additions & 19 deletions django/bin/daily_cleanup.py

This file was deleted.

22 changes: 8 additions & 14 deletions django/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,10 @@ def _configure_logging(self):
Setup logging from LOGGING_CONFIG and LOGGING settings.
"""
if not sys.warnoptions:
try:
# Route warnings through python logging
logging.captureWarnings(True)
# Allow DeprecationWarnings through the warnings filters
warnings.simplefilter("default", DeprecationWarning)
except AttributeError:
# No captureWarnings on Python 2.6, DeprecationWarnings are on anyway
pass
# Route warnings through python logging
logging.captureWarnings(True)
# Allow DeprecationWarnings through the warnings filters
warnings.simplefilter("default", DeprecationWarning)

if self.LOGGING_CONFIG:
from django.utils.log import DEFAULT_LOGGING
Expand Down Expand Up @@ -132,19 +128,17 @@ def __init__(self, settings_module):
% (self.SETTINGS_MODULE, e)
)

# Settings that should be converted into tuples if they're mistakenly entered
# as strings.
tuple_settings = ("INSTALLED_APPS", "TEMPLATE_DIRS")

for setting in dir(mod):
if setting == setting.upper():
setting_value = getattr(mod, setting)

if setting in tuple_settings and \
isinstance(setting_value, six.string_types):
warnings.warn("The %s setting must be a tuple. Please fix your "
"settings, as auto-correction is now deprecated." % setting,
DeprecationWarning, stacklevel=2)
setting_value = (setting_value,) # In case the user forgot the comma.
raise ImproperlyConfigured("The %s setting must be a tuple. "
"Please fix your settings." % setting)

setattr(self, setting, setting_value)

if not self.SECRET_KEY:
Expand Down
2 changes: 1 addition & 1 deletion django/conf/global_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@
###########

# The callable to use to configure logging
LOGGING_CONFIG = 'django.utils.log.dictConfig'
LOGGING_CONFIG = 'logging.config.dictConfig'

# Custom logging configuration.
LOGGING = {}
Expand Down
2 changes: 1 addition & 1 deletion django/conf/urls/shortcut.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.conf.urls import patterns

warnings.warn("django.conf.urls.shortcut will be removed in Django 1.8.",
PendingDeprecationWarning)
DeprecationWarning)

urlpatterns = patterns('django.views',
(r'^(?P<content_type_id>\d+)/(?P<object_id>.*)/$', 'defaults.shortcut'),
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/admin/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class IncorrectLookupParameters(Exception):

class RenameBaseModelAdminMethods(forms.MediaDefiningClass, RenameMethodsBase):
renamed_methods = (
('queryset', 'get_queryset', PendingDeprecationWarning),
('queryset', 'get_queryset', DeprecationWarning),
)


Expand Down
2 changes: 1 addition & 1 deletion django/contrib/admin/tests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
from unittest import SkipTest

from django.test import LiveServerTestCase
from django.utils.module_loading import import_by_path
from django.utils.unittest import SkipTest
from django.utils.translation import ugettext as _


Expand Down
3 changes: 2 additions & 1 deletion django/contrib/admin/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import datetime
import decimal

from django.contrib.auth import get_permission_codename
from django.db import models
from django.db.models.constants import LOOKUP_SEP
from django.db.models.deletion import Collector
Expand Down Expand Up @@ -119,7 +120,7 @@ def format_callback(obj):
opts.model_name),
None, (quote(obj._get_pk_val()),))
p = '%s.%s' % (opts.app_label,
opts.get_delete_permission())
get_permission_codename('delete', opts))
if not user.has_perm(p):
perms_needed.add(opts.verbose_name)
# Display a link to the admin page.
Expand Down
8 changes: 4 additions & 4 deletions django/contrib/admin/views/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ def _is_changelist_popup(request):
warnings.warn(
"The `%s` GET parameter has been renamed to `%s`." %
(IS_LEGACY_POPUP_VAR, IS_POPUP_VAR),
PendingDeprecationWarning, 2)
DeprecationWarning, 2)
return True

return False


class RenameChangeListMethods(RenameMethodsBase):
renamed_methods = (
('get_query_set', 'get_queryset', PendingDeprecationWarning),
('get_query_set', 'get_queryset', DeprecationWarning),
)


Expand Down Expand Up @@ -115,14 +115,14 @@ def __init__(self, request, model, list_display, list_display_links,
def root_query_set(self):
warnings.warn("`ChangeList.root_query_set` is deprecated, "
"use `root_queryset` instead.",
PendingDeprecationWarning, 2)
DeprecationWarning, 2)
return self.root_queryset

@property
def query_set(self):
warnings.warn("`ChangeList.query_set` is deprecated, "
"use `queryset` instead.",
PendingDeprecationWarning, 2)
DeprecationWarning, 2)
return self.queryset

def get_filters_params(self, params=None):
Expand Down
3 changes: 2 additions & 1 deletion django/contrib/admindocs/tests/test_fields.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import absolute_import, unicode_literals

import unittest

from django.contrib.admindocs import views
from django.db import models
from django.db.models import fields
from django.utils import unittest
from django.utils.translation import ugettext as _


Expand Down
6 changes: 0 additions & 6 deletions django/contrib/auth/forms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import unicode_literals

import warnings

from django import forms
from django.forms.util import flatatt
from django.template import loader
Expand Down Expand Up @@ -200,10 +198,6 @@ def clean(self):
)
return self.cleaned_data

def check_for_test_cookie(self):
warnings.warn("check_for_test_cookie is deprecated; ensure your login "
"view is CSRF-protected.", DeprecationWarning)

def get_user_id(self):
if self.user_cache:
return self.user_cache.id
Expand Down
39 changes: 0 additions & 39 deletions django/contrib/auth/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import unicode_literals
import re
import warnings

from django.core.exceptions import ImproperlyConfigured
from django.core.mail import send_mail
from django.core import validators
from django.db import models
Expand All @@ -14,7 +12,6 @@
from django.utils import timezone

from django.contrib import auth
# UNUSABLE_PASSWORD is still imported here for backwards compatibility
from django.contrib.auth.hashers import (
check_password, make_password, is_password_usable)
from django.contrib.auth.signals import user_logged_in
Expand All @@ -32,10 +29,6 @@ def update_last_login(sender, user, **kwargs):
user_logged_in.connect(update_last_login)


class SiteProfileNotAvailable(Exception):
pass


class PermissionManager(models.Manager):
def get_by_natural_key(self, codename, app_label, model):
return self.get(
Expand Down Expand Up @@ -413,38 +406,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):
"""
Expand Down
5 changes: 3 additions & 2 deletions django/contrib/auth/tests/test_hashers.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import unittest
from unittest import skipUnless

from django.conf.global_settings import PASSWORD_HASHERS as default_hashers
from django.contrib.auth.hashers import (is_password_usable, BasePasswordHasher,
check_password, make_password, PBKDF2PasswordHasher, load_hashers, PBKDF2SHA1PasswordHasher,
get_hasher, identify_hasher, UNUSABLE_PASSWORD_PREFIX, UNUSABLE_PASSWORD_SUFFIX_LENGTH)
from django.utils import six
from django.utils import unittest
from django.utils.unittest import skipUnless


try:
Expand Down
39 changes: 1 addition & 38 deletions django/contrib/auth/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions django/contrib/auth/tests/test_tokens.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import sys
from datetime import date, timedelta
import sys
import unittest

from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.contrib.auth.tests.utils import skipIfCustomUser
from django.test import TestCase
from django.utils import unittest


@skipIfCustomUser
Expand Down
22 changes: 1 addition & 21 deletions django/contrib/auth/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.core.urlresolvers import reverse, NoReverseMatch
from django.http import QueryDict, HttpRequest
from django.utils.encoding import force_text
from django.utils.http import int_to_base36, urlsafe_base64_decode, urlquote
from django.utils.http import urlquote
from django.utils._os import upath
from django.test import TestCase
from django.test.utils import override_settings, patch_logger
Expand Down Expand Up @@ -193,16 +193,6 @@ def test_confirm_valid(self):
# redirect to a 'complete' page:
self.assertContains(response, "Please enter your new password")

def test_confirm_valid_base36(self):
# Remove in Django 1.7
url, path = self._test_confirm_start()
path_parts = path.strip("/").split("/")
# construct an old style (base36) URL by converting the base64 ID
path_parts[1] = int_to_base36(int(urlsafe_base64_decode(path_parts[1])))
response = self.client.get("/%s/%s-%s/" % tuple(path_parts))
# redirect to a 'complete' page:
self.assertContains(response, "Please enter your new password")

def test_confirm_invalid(self):
url, path = self._test_confirm_start()
# Let's munge the token in the path, but keep the same length,
Expand All @@ -217,21 +207,11 @@ def test_confirm_invalid_user(self):
response = self.client.get('/reset/123456/1-1/')
self.assertContains(response, "The password reset link was invalid")

def test_confirm_invalid_user_base36(self):
# Remove in Django 1.7
response = self.client.get('/reset/123456-1-1/')
self.assertContains(response, "The password reset link was invalid")

def test_confirm_overflow_user(self):
# Ensure that we get a 200 response for a base36 user id that overflows int
response = self.client.get('/reset/zzzzzzzzzzzzz/1-1/')
self.assertContains(response, "The password reset link was invalid")

def test_confirm_overflow_user_base36(self):
# Remove in Django 1.7
response = self.client.get('/reset/zzzzzzzzzzzzz-1-1/')
self.assertContains(response, "The password reset link was invalid")

def test_confirm_invalid_post(self):
# Same as test_confirm_invalid, but trying
# to do a POST instead.
Expand Down
Loading

0 comments on commit b1e0ec0

Please sign in to comment.