From ffcf24c9ce781a7c194ed8722b850e7873922f6b Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Wed, 19 Jun 2013 17:18:40 +0200 Subject: [PATCH 01/55] Removed several unused imports. --- django/contrib/admin/validation.py | 3 +-- django/contrib/admindocs/views.py | 1 - django/contrib/auth/management/__init__.py | 1 - django/contrib/auth/tests/test_remote_user.py | 2 +- django/contrib/auth/tests/test_views.py | 3 +-- django/contrib/comments/admin.py | 2 +- django/contrib/flatpages/tests/test_csrf.py | 1 - django/contrib/flatpages/tests/test_templatetags.py | 1 - django/contrib/formtools/tests/tests.py | 4 ---- django/contrib/formtools/tests/wizard/test_cookiestorage.py | 2 -- django/contrib/gis/admin/widgets.py | 1 - django/contrib/gis/db/backends/postgis/creation.py | 1 - django/contrib/gis/db/models/aggregates.py | 1 - django/contrib/gis/geos/tests/test_io.py | 1 - django/contrib/gis/management/commands/ogrinspect.py | 1 - django/contrib/gis/tests/relatedapp/tests.py | 2 -- django/contrib/sitemaps/tests/base.py | 1 - django/contrib/sitemaps/tests/urls/http.py | 1 - django/core/exceptions.py | 1 - django/core/management/__init__.py | 2 -- django/core/serializers/base.py | 1 - django/db/backends/postgresql_psycopg2/base.py | 2 -- django/db/backends/postgresql_psycopg2/creation.py | 2 -- django/forms/formsets.py | 2 +- django/forms/util.py | 1 - django/forms/widgets.py | 5 ++--- django/middleware/csrf.py | 2 -- django/template/defaultfilters.py | 1 - django/utils/html.py | 1 - django/utils/text.py | 1 - django/views/debug.py | 1 - django/views/decorators/csrf.py | 2 -- 32 files changed, 7 insertions(+), 46 deletions(-) diff --git a/django/contrib/admin/validation.py b/django/contrib/admin/validation.py index 222d433e53..fb9634d114 100644 --- a/django/contrib/admin/validation.py +++ b/django/contrib/admin/validation.py @@ -1,8 +1,7 @@ from django.core.exceptions import ImproperlyConfigured from django.db import models from django.db.models.fields import FieldDoesNotExist -from django.forms.models import (BaseModelForm, BaseModelFormSet, fields_for_model, - _get_foreign_key) +from django.forms.models import BaseModelForm, BaseModelFormSet, _get_foreign_key from django.contrib.admin.util import get_fields_from_path, NotRelationField """ diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py index c03883def7..b3faf06e25 100644 --- a/django/contrib/admindocs/views.py +++ b/django/contrib/admindocs/views.py @@ -17,7 +17,6 @@ from django.utils.importlib import import_module from django.utils._os import upath from django.utils import six from django.utils.translation import ugettext as _ -from django.utils.safestring import mark_safe # Exclude methods starting with these strings from documentation MODEL_METHODS_EXCLUDE = ('_', 'add_', 'delete', 'save', 'set_') diff --git a/django/contrib/auth/management/__init__.py b/django/contrib/auth/management/__init__.py index ecf6c1b635..5c1bfbc515 100644 --- a/django/contrib/auth/management/__init__.py +++ b/django/contrib/auth/management/__init__.py @@ -4,7 +4,6 @@ Creates permissions for all installed apps that need permissions. from __future__ import unicode_literals import getpass -import locale import unicodedata from django.contrib.auth import models as auth_app, get_user_model diff --git a/django/contrib/auth/tests/test_remote_user.py b/django/contrib/auth/tests/test_remote_user.py index dae61afed5..5c5024eae9 100644 --- a/django/contrib/auth/tests/test_remote_user.py +++ b/django/contrib/auth/tests/test_remote_user.py @@ -3,7 +3,7 @@ from datetime import datetime from django.conf import settings from django.contrib.auth import authenticate from django.contrib.auth.backends import RemoteUserBackend -from django.contrib.auth.models import User, AnonymousUser +from django.contrib.auth.models import User from django.contrib.auth.tests.utils import skipIfCustomUser from django.test import TestCase from django.utils import timezone diff --git a/django/contrib/auth/tests/test_views.py b/django/contrib/auth/tests/test_views.py index ef305ac8f1..3a1be5bb7b 100644 --- a/django/contrib/auth/tests/test_views.py +++ b/django/contrib/auth/tests/test_views.py @@ -13,7 +13,6 @@ from django.core import mail from django.core.urlresolvers import reverse, NoReverseMatch from django.http import QueryDict, HttpRequest from django.utils.encoding import force_text -from django.utils.html import escape from django.utils.http import urlquote from django.utils._os import upath from django.test import TestCase @@ -23,7 +22,7 @@ from django.contrib.sessions.middleware import SessionMiddleware from django.contrib.auth import SESSION_KEY, REDIRECT_FIELD_NAME from django.contrib.auth.forms import (AuthenticationForm, PasswordChangeForm, - SetPasswordForm, PasswordResetForm) + SetPasswordForm) from django.contrib.auth.tests.utils import skipIfCustomUser from django.contrib.auth.views import login as login_view diff --git a/django/contrib/comments/admin.py b/django/contrib/comments/admin.py index bca638182c..391889cd65 100644 --- a/django/contrib/comments/admin.py +++ b/django/contrib/comments/admin.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals from django.contrib import admin from django.contrib.auth import get_user_model from django.contrib.comments.models import Comment -from django.utils.translation import ugettext_lazy as _, ungettext, ungettext_lazy +from django.utils.translation import ugettext_lazy as _, ungettext_lazy from django.contrib.comments import get_model from django.contrib.comments.views.moderation import perform_flag, perform_approve, perform_delete diff --git a/django/contrib/flatpages/tests/test_csrf.py b/django/contrib/flatpages/tests/test_csrf.py index 59996d9824..cb51c124b8 100644 --- a/django/contrib/flatpages/tests/test_csrf.py +++ b/django/contrib/flatpages/tests/test_csrf.py @@ -1,5 +1,4 @@ import os -from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth.tests.utils import skipIfCustomUser from django.test import TestCase, Client diff --git a/django/contrib/flatpages/tests/test_templatetags.py b/django/contrib/flatpages/tests/test_templatetags.py index 1a6f3c2975..23fa8faf2d 100644 --- a/django/contrib/flatpages/tests/test_templatetags.py +++ b/django/contrib/flatpages/tests/test_templatetags.py @@ -1,5 +1,4 @@ import os -from django.conf import settings from django.contrib.auth.models import AnonymousUser, User from django.contrib.auth.tests.utils import skipIfCustomUser from django.template import Template, Context, TemplateSyntaxError diff --git a/django/contrib/formtools/tests/tests.py b/django/contrib/formtools/tests/tests.py index 56ef901127..58c59f4041 100644 --- a/django/contrib/formtools/tests/tests.py +++ b/django/contrib/formtools/tests/tests.py @@ -3,15 +3,11 @@ from __future__ import unicode_literals import datetime import os -import pickle -import re import warnings from django import http -from django.conf import settings from django.contrib.formtools import preview, utils from django.test import TestCase -from django.test.html import parse_html from django.test.utils import override_settings from django.utils._os import upath from django.utils import unittest diff --git a/django/contrib/formtools/tests/wizard/test_cookiestorage.py b/django/contrib/formtools/tests/wizard/test_cookiestorage.py index 060e8260b5..4c1ff97475 100644 --- a/django/contrib/formtools/tests/wizard/test_cookiestorage.py +++ b/django/contrib/formtools/tests/wizard/test_cookiestorage.py @@ -1,5 +1,3 @@ -import json - from django.test import TestCase from django.core import signing from django.core.exceptions import SuspiciousOperation diff --git a/django/contrib/gis/admin/widgets.py b/django/contrib/gis/admin/widgets.py index ceb8e9c9bd..056d25952a 100644 --- a/django/contrib/gis/admin/widgets.py +++ b/django/contrib/gis/admin/widgets.py @@ -2,7 +2,6 @@ import logging from django.forms.widgets import Textarea from django.template import loader, Context -from django.templatetags.static import static from django.utils import six from django.utils import translation diff --git a/django/contrib/gis/db/backends/postgis/creation.py b/django/contrib/gis/db/backends/postgis/creation.py index 43ae9a0331..4f64ecce29 100644 --- a/django/contrib/gis/db/backends/postgis/creation.py +++ b/django/contrib/gis/db/backends/postgis/creation.py @@ -1,5 +1,4 @@ from django.conf import settings -from django.core.exceptions import ImproperlyConfigured from django.db.backends.postgresql_psycopg2.creation import DatabaseCreation from django.utils.functional import cached_property diff --git a/django/contrib/gis/db/models/aggregates.py b/django/contrib/gis/db/models/aggregates.py index cd26839eb5..d0fc6d319d 100644 --- a/django/contrib/gis/db/models/aggregates.py +++ b/django/contrib/gis/db/models/aggregates.py @@ -1,5 +1,4 @@ from django.db.models import Aggregate -from django.contrib.gis.db.models.sql import GeomField class Collect(Aggregate): name = 'Collect' diff --git a/django/contrib/gis/geos/tests/test_io.py b/django/contrib/gis/geos/tests/test_io.py index 38ca2e0923..34eeaf95b9 100644 --- a/django/contrib/gis/geos/tests/test_io.py +++ b/django/contrib/gis/geos/tests/test_io.py @@ -4,7 +4,6 @@ import binascii import unittest from django.contrib.gis import memoryview -from django.utils import six from django.utils.unittest import skipUnless from ..import HAS_GEOS diff --git a/django/contrib/gis/management/commands/ogrinspect.py b/django/contrib/gis/management/commands/ogrinspect.py index 6037cc7ea6..44513e3463 100644 --- a/django/contrib/gis/management/commands/ogrinspect.py +++ b/django/contrib/gis/management/commands/ogrinspect.py @@ -1,4 +1,3 @@ -import os from optparse import make_option from django.contrib.gis import gdal from django.core.management.base import LabelCommand, CommandError diff --git a/django/contrib/gis/tests/relatedapp/tests.py b/django/contrib/gis/tests/relatedapp/tests.py index 6320edcff5..d93adbcd4c 100644 --- a/django/contrib/gis/tests/relatedapp/tests.py +++ b/django/contrib/gis/tests/relatedapp/tests.py @@ -1,7 +1,5 @@ from __future__ import absolute_import -from datetime import date - from django.contrib.gis.geos import HAS_GEOS from django.contrib.gis.tests.utils import HAS_SPATIAL_DB, mysql, oracle, no_mysql, no_oracle, no_spatialite from django.test import TestCase diff --git a/django/contrib/sitemaps/tests/base.py b/django/contrib/sitemaps/tests/base.py index 099dba7256..8e027d491e 100644 --- a/django/contrib/sitemaps/tests/base.py +++ b/django/contrib/sitemaps/tests/base.py @@ -1,4 +1,3 @@ -from django.contrib.auth.models import User from django.contrib.sites.models import Site from django.core.cache import cache from django.db import models diff --git a/django/contrib/sitemaps/tests/urls/http.py b/django/contrib/sitemaps/tests/urls/http.py index 56103f4ec2..a8b804fd4b 100644 --- a/django/contrib/sitemaps/tests/urls/http.py +++ b/django/contrib/sitemaps/tests/urls/http.py @@ -1,7 +1,6 @@ from datetime import datetime from django.conf.urls import patterns, url from django.contrib.sitemaps import Sitemap, GenericSitemap, FlatPageSitemap, views -from django.contrib.auth.models import User from django.views.decorators.cache import cache_page from django.contrib.sitemaps.tests.base import TestModel diff --git a/django/core/exceptions.py b/django/core/exceptions.py index 829d6e774e..efec22850b 100644 --- a/django/core/exceptions.py +++ b/django/core/exceptions.py @@ -1,7 +1,6 @@ """ Global Django exception and warning classes. """ -import logging from functools import reduce import operator diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py index 77d5e1b264..8fd46aa759 100644 --- a/django/core/management/__init__.py +++ b/django/core/management/__init__.py @@ -3,13 +3,11 @@ import os import sys from optparse import OptionParser, NO_DEFAULT import imp -import warnings from django.core.exceptions import ImproperlyConfigured from django.core.management.base import BaseCommand, CommandError, handle_default_options from django.core.management.color import color_style from django.utils.importlib import import_module -from django.utils._os import upath from django.utils import six # For backwards compatibility: get_version() used to be in this module. diff --git a/django/core/serializers/base.py b/django/core/serializers/base.py index 1e78026c40..cd4f7ffb2b 100644 --- a/django/core/serializers/base.py +++ b/django/core/serializers/base.py @@ -3,7 +3,6 @@ Module for abstract serializer/unserializer base classes. """ from django.db import models -from django.utils.encoding import smart_text from django.utils import six class SerializerDoesNotExist(KeyError): diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py index 5c5f5e185a..6ed2cfcc7c 100644 --- a/django/db/backends/postgresql_psycopg2/base.py +++ b/django/db/backends/postgresql_psycopg2/base.py @@ -6,7 +6,6 @@ Requires psycopg 2: http://initd.org/projects/psycopg2 import logging import sys -from django.db import utils from django.db.backends import * from django.db.backends.postgresql_psycopg2.operations import DatabaseOperations from django.db.backends.postgresql_psycopg2.client import DatabaseClient @@ -16,7 +15,6 @@ from django.db.backends.postgresql_psycopg2.introspection import DatabaseIntrosp from django.utils.encoding import force_str from django.utils.functional import cached_property from django.utils.safestring import SafeText, SafeBytes -from django.utils import six from django.utils.timezone import utc try: diff --git a/django/db/backends/postgresql_psycopg2/creation.py b/django/db/backends/postgresql_psycopg2/creation.py index 3ba2158103..d4260e05c4 100644 --- a/django/db/backends/postgresql_psycopg2/creation.py +++ b/django/db/backends/postgresql_psycopg2/creation.py @@ -1,5 +1,3 @@ -import psycopg2.extensions - from django.db.backends.creation import BaseDatabaseCreation from django.db.backends.util import truncate_name diff --git a/django/forms/formsets.py b/django/forms/formsets.py index edd362c595..9c2e88bee7 100644 --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -4,7 +4,7 @@ from django.core.exceptions import ValidationError from django.forms import Form from django.forms.fields import IntegerField, BooleanField from django.forms.util import ErrorList -from django.forms.widgets import Media, HiddenInput +from django.forms.widgets import HiddenInput from django.utils.encoding import python_2_unicode_compatible from django.utils.safestring import mark_safe from django.utils import six diff --git a/django/forms/util.py b/django/forms/util.py index 568cdd1086..0a73320f83 100644 --- a/django/forms/util.py +++ b/django/forms/util.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals from django.conf import settings from django.utils.html import format_html, format_html_join from django.utils.encoding import force_text, python_2_unicode_compatible -from django.utils.safestring import mark_safe from django.utils import timezone from django.utils.translation import ugettext_lazy as _ from django.utils import six diff --git a/django/forms/widgets.py b/django/forms/widgets.py index aca4a457af..38d1b99b0d 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -5,7 +5,6 @@ HTML Widget classes from __future__ import absolute_import, unicode_literals import copy -import datetime from itertools import chain try: from urllib.parse import urljoin @@ -16,8 +15,8 @@ import warnings from django.conf import settings from django.forms.util import flatatt, to_current_timezone from django.utils.datastructures import MultiValueDict, MergeDict -from django.utils.html import conditional_escape, format_html, format_html_join -from django.utils.translation import ugettext, ugettext_lazy +from django.utils.html import conditional_escape, format_html +from django.utils.translation import ugettext_lazy from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.safestring import mark_safe from django.utils import datetime_safe, formats, six diff --git a/django/middleware/csrf.py b/django/middleware/csrf.py index 1b5732fbbf..c13715eeb9 100644 --- a/django/middleware/csrf.py +++ b/django/middleware/csrf.py @@ -6,10 +6,8 @@ against request forgeries from other sites. """ from __future__ import unicode_literals -import hashlib import logging import re -import random from django.conf import settings from django.core.urlresolvers import get_callable diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py index 4201cfeb67..76c0121126 100644 --- a/django/template/defaultfilters.py +++ b/django/template/defaultfilters.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals import re import random as random_module -import unicodedata from decimal import Decimal, InvalidOperation, Context, ROUND_HALF_UP from functools import wraps from pprint import pformat diff --git a/django/utils/html.py b/django/utils/html.py index 0d28c77a61..4893b6b18a 100644 --- a/django/utils/html.py +++ b/django/utils/html.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals import re -import string try: from urllib.parse import quote, urlsplit, urlunsplit except ImportError: # Python 2 diff --git a/django/utils/text.py b/django/utils/text.py index 4fe92ab509..7bb8e7eb3e 100644 --- a/django/utils/text.py +++ b/django/utils/text.py @@ -2,7 +2,6 @@ from __future__ import unicode_literals import re import unicodedata -import warnings from gzip import GzipFile from io import BytesIO diff --git a/django/views/debug.py b/django/views/debug.py index 0458580221..2129a83d67 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -7,7 +7,6 @@ import sys import types from django.conf import settings -from django.core.exceptions import ImproperlyConfigured from django.http import (HttpResponse, HttpResponseServerError, HttpResponseNotFound, HttpRequest, build_request_repr) from django.template import Template, Context, TemplateDoesNotExist diff --git a/django/views/decorators/csrf.py b/django/views/decorators/csrf.py index a6bd7d8526..1ebed2a6a1 100644 --- a/django/views/decorators/csrf.py +++ b/django/views/decorators/csrf.py @@ -1,5 +1,3 @@ -import warnings - from django.middleware.csrf import CsrfViewMiddleware, get_token from django.utils.decorators import decorator_from_middleware, available_attrs from functools import wraps From 7462a78c1bdef2f37ea9aae5ad05170dbd14b34a Mon Sep 17 00:00:00 2001 From: Loic Bistuer Date: Thu, 20 Jun 2013 03:09:40 +0700 Subject: [PATCH 02/55] Fixed #20288 -- Fixed inconsistency in the naming of the popup GET parameter. Thanks to Keryn Knight for the initial report and reviews, and to tomask for the original patch. --- django/contrib/admin/options.py | 12 ++++---- .../admin/js/admin/RelatedObjectLookups.js | 4 +-- .../admin/templates/admin/search_form.html | 2 +- .../contrib/admin/templatetags/admin_urls.py | 6 ++-- django/contrib/admin/views/main.py | 28 +++++++++++++++++-- django/contrib/auth/admin.py | 5 ++-- docs/releases/1.6.txt | 6 ++++ 7 files changed, 47 insertions(+), 16 deletions(-) diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 942385e1c6..e9f4a43185 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -40,6 +40,8 @@ from django.utils.translation import ugettext as _ from django.utils.translation import ungettext from django.utils.encoding import force_text +IS_POPUP_VAR = '_popup' + HORIZONTAL, VERTICAL = 1, 2 # returns the