diff options
Diffstat (limited to 'django')
-rw-r--r-- | django/conf/locale/de/LC_MESSAGES/django.mo | bin | 44060 -> 44063 bytes | |||
-rw-r--r-- | django/conf/locale/de/LC_MESSAGES/django.po | 16 | ||||
-rw-r--r-- | django/contrib/admin/templatetags/log.py | 9 | ||||
-rw-r--r-- | django/contrib/contenttypes/generic.py (renamed from django/db/models/fields/generic.py) | 0 | ||||
-rw-r--r-- | django/core/cache/backends/base.py | 3 | ||||
-rw-r--r-- | django/core/management.py | 4 | ||||
-rw-r--r-- | django/db/models/__init__.py | 1 | ||||
-rw-r--r-- | django/db/models/base.py | 2 | ||||
-rw-r--r-- | django/db/models/query.py | 9 | ||||
-rw-r--r-- | django/template/__init__.py | 9 | ||||
-rw-r--r-- | django/test/testcases.py | 22 | ||||
-rw-r--r-- | django/test/utils.py | 32 |
12 files changed, 77 insertions, 30 deletions
diff --git a/django/conf/locale/de/LC_MESSAGES/django.mo b/django/conf/locale/de/LC_MESSAGES/django.mo Binary files differindex 396fe5a432..5f2eee4f33 100644 --- a/django/conf/locale/de/LC_MESSAGES/django.mo +++ b/django/conf/locale/de/LC_MESSAGES/django.mo diff --git a/django/conf/locale/de/LC_MESSAGES/django.po b/django/conf/locale/de/LC_MESSAGES/django.po index 9237e18b2a..52b70bda00 100644 --- a/django/conf/locale/de/LC_MESSAGES/django.po +++ b/django/conf/locale/de/LC_MESSAGES/django.po @@ -367,11 +367,11 @@ msgstr "Abmelden" #: contrib/admin/templates/admin/base_site.html:4 msgid "Django site admin" -msgstr "Django Systemverwaltung" +msgstr "Django-Systemverwaltung" #: contrib/admin/templates/admin/base_site.html:7 msgid "Django administration" -msgstr "Django Verwaltung" +msgstr "Django-Verwaltung" #: contrib/admin/templates/admin/change_form.html:15 #: contrib/admin/templates/admin/index.html:28 @@ -385,7 +385,7 @@ msgstr "Geschichte" #: contrib/admin/templates/admin/change_form.html:22 msgid "View on site" -msgstr "Im Web Anzeigen" +msgstr "Im Web anzeigen" #: contrib/admin/templates/admin/change_form.html:32 #: contrib/admin/templates/admin/auth/user/change_password.html:24 @@ -614,7 +614,7 @@ msgid "" "your computer is \"internal\").</p>\n" msgstr "" "\n" -"<p class=\"help\">Um Bookmarklets zu installieren müssen diese Links in die\n" +"<p class=\"help\">Um Bookmarklets zu installieren, müssen diese Links in die\n" "Browser-Werkzeugleiste gezogen werden, oder mittels rechter Maustaste in " "die\n" "Bookmarks gespeichert werden. Danach können die Bookmarklets von jeder " @@ -998,7 +998,7 @@ msgstr "%s ist scheinbar kein urlpattern Objekt" #: contrib/admin/views/main.py:223 msgid "Site administration" -msgstr "Website Verwaltung" +msgstr "Website-Verwaltung" #: contrib/admin/views/main.py:271 contrib/admin/views/main.py:356 #, python-format @@ -1023,7 +1023,7 @@ msgstr "und" #: contrib/admin/views/main.py:337 #, python-format msgid "Changed %s." -msgstr "%s geändert" +msgstr "%s geändert." #: contrib/admin/views/main.py:339 #, python-format @@ -1490,8 +1490,8 @@ msgstr "Ihr Name:" msgid "" "This rating is required because you've entered at least one other rating." msgstr "" -"Diese Abstimmung ist zwingend erforderlich, da Du an mindestens einer " -"weiteren Abstimmung teilnimmst." +"Diese Abstimmung ist zwingend erforderlich, da Sie an mindestens einer " +"weiteren Abstimmung teilnehmen." #: contrib/comments/views/comments.py:111 #, python-format diff --git a/django/contrib/admin/templatetags/log.py b/django/contrib/admin/templatetags/log.py index 5caba2b795..8d52d2e944 100644 --- a/django/contrib/admin/templatetags/log.py +++ b/django/contrib/admin/templatetags/log.py @@ -11,9 +11,12 @@ class AdminLogNode(template.Node): return "<GetAdminLog Node>" def render(self, context): - if self.user is not None and not self.user.isdigit(): - self.user = context[self.user].id - context[self.varname] = LogEntry.objects.filter(user__id__exact=self.user).select_related()[:self.limit] + if self.user is None: + context[self.varname] = LogEntry.objects.all().select_related()[:self.limit] + else: + if not self.user.isdigit(): + self.user = context[self.user].id + context[self.varname] = LogEntry.objects.filter(user__id__exact=self.user).select_related()[:self.limit] return '' class DoGetAdminLog: diff --git a/django/db/models/fields/generic.py b/django/contrib/contenttypes/generic.py index f995ab2044..f995ab2044 100644 --- a/django/db/models/fields/generic.py +++ b/django/contrib/contenttypes/generic.py diff --git a/django/core/cache/backends/base.py b/django/core/cache/backends/base.py index ef5f6a6b3e..bb67399f3b 100644 --- a/django/core/cache/backends/base.py +++ b/django/core/cache/backends/base.py @@ -54,3 +54,6 @@ class BaseCache(object): Returns True if the key is in the cache and has not expired. """ return self.get(key) is not None + + __contains__ = has_key + diff --git a/django/core/management.py b/django/core/management.py index 47f44f8c8d..91de11f3b3 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -260,14 +260,14 @@ def _get_sql_for_pending_references(model, pending_references): def _get_many_to_many_sql_for_model(model): from django.db import backend, get_creation_module - from django.db.models import GenericRel + from django.contrib.contenttypes import generic data_types = get_creation_module().DATA_TYPES opts = model._meta final_output = [] for f in opts.many_to_many: - if not isinstance(f.rel, GenericRel): + if not isinstance(f.rel, generic.GenericRel): tablespace = f.db_tablespace or opts.db_tablespace if tablespace and backend.supports_tablespaces and backend.autoindexes_primary_keys: tablespace_sql = ' ' + backend.get_tablespace_sql(tablespace, inline=True) diff --git a/django/db/models/__init__.py b/django/db/models/__init__.py index ccd60023f9..6c3abb6b59 100644 --- a/django/db/models/__init__.py +++ b/django/db/models/__init__.py @@ -8,7 +8,6 @@ from django.db.models.manager import Manager from django.db.models.base import Model, AdminOptions from django.db.models.fields import * from django.db.models.fields.related import ForeignKey, OneToOneField, ManyToManyField, ManyToOneRel, ManyToManyRel, OneToOneRel, TABULAR, STACKED -from django.db.models.fields.generic import GenericRelation, GenericRel, GenericForeignKey from django.db.models import signals from django.utils.functional import curry from django.utils.text import capfirst diff --git a/django/db/models/base.py b/django/db/models/base.py index eb95aae4f2..a567f0ed37 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -42,11 +42,11 @@ class ModelBase(type): new_class._meta.parents.append(base) new_class._meta.parents.extend(base._meta.parents) - model_module = sys.modules[new_class.__module__] if getattr(new_class._meta, 'app_label', None) is None: # Figure out the app_label by looking one level up. # For 'django.contrib.sites.models', this would be 'sites'. + model_module = sys.modules[new_class.__module__] new_class._meta.app_label = model_module.__name__.split('.')[-2] # Bail out early if we have already created this class. diff --git a/django/db/models/query.py b/django/db/models/query.py index d31ccf003e..e3b9c794f8 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -1,10 +1,9 @@ from django.db import backend, connection, transaction from django.db.models.fields import DateField, FieldDoesNotExist -from django.db.models.fields.generic import GenericRelation -from django.db.models import signals +from django.db.models import signals, loading from django.dispatch import dispatcher from django.utils.datastructures import SortedDict -from django.conf import settings +from django.contrib.contenttypes import generic import datetime import operator import re @@ -1091,7 +1090,7 @@ def delete_objects(seen_objs): pk_list = [pk for pk,instance in seen_objs[cls]] for related in cls._meta.get_all_related_many_to_many_objects(): - if not isinstance(related.field, GenericRelation): + if not isinstance(related.field, generic.GenericRelation): for offset in range(0, len(pk_list), GET_ITERATOR_CHUNK_SIZE): cursor.execute("DELETE FROM %s WHERE %s IN (%s)" % \ (qn(related.field.m2m_db_table()), @@ -1099,7 +1098,7 @@ def delete_objects(seen_objs): ','.join(['%s' for pk in pk_list[offset:offset+GET_ITERATOR_CHUNK_SIZE]])), pk_list[offset:offset+GET_ITERATOR_CHUNK_SIZE]) for f in cls._meta.many_to_many: - if isinstance(f, GenericRelation): + if isinstance(f, generic.GenericRelation): from django.contrib.contenttypes.models import ContentType query_extra = 'AND %s=%%s' % f.rel.to._meta.get_field(f.content_type_field_name).column args_extra = [ContentType.objects.get_for_model(cls).id] diff --git a/django/template/__init__.py b/django/template/__init__.py index 4cb4f21156..9811a5649d 100644 --- a/django/template/__init__.py +++ b/django/template/__init__.py @@ -99,6 +99,10 @@ libraries = {} # global list of libraries to load by default for a new parser builtins = [] +# True if TEMPLATE_STRING_IF_INVALID contains a format string (%s). None means +# uninitialised. +invalid_var_format_string = None + class TemplateSyntaxError(Exception): def __str__(self): try: @@ -575,6 +579,11 @@ class FilterExpression(object): obj = None else: if settings.TEMPLATE_STRING_IF_INVALID: + global invalid_var_format_string + if invalid_var_format_string is None: + invalid_var_format_string = '%s' in settings.TEMPLATE_STRING_IF_INVALID + if invalid_var_format_string: + return settings.TEMPLATE_STRING_IF_INVALID % self.var return settings.TEMPLATE_STRING_IF_INVALID else: obj = settings.TEMPLATE_STRING_IF_INVALID diff --git a/django/test/testcases.py b/django/test/testcases.py index 80f55b20d3..153931f42a 100644 --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -1,7 +1,7 @@ import re, doctest, unittest from urlparse import urlparse from django.db import transaction -from django.core import management +from django.core import management, mail from django.db.models import get_apps from django.test.client import Client @@ -33,23 +33,27 @@ class DocTestRunner(doctest.DocTestRunner): transaction.rollback_unless_managed() class TestCase(unittest.TestCase): - def install_fixtures(self): - """If the Test Case class has a 'fixtures' member, clear the database and - install the named fixtures at the start of each test. + def _pre_setup(self): + """Perform any pre-test setup. This includes: + * If the Test Case class has a 'fixtures' member, clearing the + database and installing the named fixtures at the start of each test. + * Clearing the mail test outbox. + """ management.flush(verbosity=0, interactive=False) if hasattr(self, 'fixtures'): management.load_data(self.fixtures, verbosity=0) - + mail.outbox = [] + def run(self, result=None): - """Wrapper around default run method so that user-defined Test Cases - automatically call install_fixtures without having to include a call to - super(). + """Wrapper around default run method to perform common Django test set up. + This means that user-defined Test Cases aren't required to include a call + to super().setUp(). """ self.client = Client() - self.install_fixtures() + self._pre_setup() super(TestCase, self).run(result) def assertRedirects(self, response, expected_path): diff --git a/django/test/utils.py b/django/test/utils.py index 70b7f3cdbe..da339bb808 100644 --- a/django/test/utils.py +++ b/django/test/utils.py @@ -1,7 +1,7 @@ import sys, time from django.conf import settings from django.db import connection, backend, get_creation_module -from django.core import management +from django.core import management, mail from django.dispatch import dispatcher from django.test import signals from django.template import Template @@ -18,24 +18,54 @@ def instrumented_test_render(self, context): dispatcher.send(signal=signals.template_rendered, sender=self, template=self, context=context) return self.nodelist.render(context) +class TestSMTPConnection(object): + """A substitute SMTP connection for use during test sessions. + The test connection stores email messages in a dummy outbox, + rather than sending them out on the wire. + + """ + def __init__(*args, **kwargs): + pass + def open(self): + "Mock the SMTPConnection open() interface" + pass + def close(self): + "Mock the SMTPConnection close() interface" + pass + def send_messages(self, messages): + "Redirect messages to the dummy outbox" + mail.outbox.extend(messages) + def setup_test_environment(): """Perform any global pre-test setup. This involves: - Installing the instrumented test renderer + - Diverting the email sending functions to a test buffer """ Template.original_render = Template.render Template.render = instrumented_test_render + mail.original_SMTPConnection = mail.SMTPConnection + mail.SMTPConnection = TestSMTPConnection + + mail.outbox = [] + def teardown_test_environment(): """Perform any global post-test teardown. This involves: - Restoring the original test renderer + - Restoring the email sending functions """ Template.render = Template.original_render del Template.original_render + mail.SMTPConnection = mail.original_SMTPConnection + del mail.original_SMTPConnection + + del mail.outbox + def _set_autocommit(connection): "Make sure a connection is in autocommit mode." if hasattr(connection.connection, "autocommit"): |