Permalink
Browse files

newforms-admin: Merged to [5983]

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@5984 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 0ae4e10 commit c49f2d21ea055ae3c9b66cfd62a9f527a2f6d3b5 @adrianholovaty adrianholovaty committed Aug 20, 2007
Showing with 2,338 additions and 1,862 deletions.
  1. +2 −0 AUTHORS
  2. +2 −1 django/conf/global_settings.py
  3. BIN django/conf/locale/es/LC_MESSAGES/django.mo
  4. +7 −2 django/conf/locale/es/LC_MESSAGES/django.po
  5. +2 −2 django/conf/project_template/settings.py
  6. +1 −1 django/contrib/admin/templates/admin/index.html
  7. +9 −8 django/contrib/auth/models.py
  8. +6 −4 django/contrib/contenttypes/generic.py
  9. +21 −2 django/contrib/databrowse/datastructures.py
  10. +5 −5 django/contrib/databrowse/plugins/calendars.py
  11. +4 −1 django/contrib/databrowse/templates/databrowse/base.html
  12. +1 −0 django/contrib/databrowse/templates/databrowse/base_site.html
  13. +2 −2 django/contrib/databrowse/templates/databrowse/calendar_day.html
  14. +1 −1 django/contrib/databrowse/templates/databrowse/calendar_homepage.html
  15. +1 −1 django/contrib/databrowse/templates/databrowse/calendar_main.html
  16. +2 −2 django/contrib/databrowse/templates/databrowse/calendar_month.html
  17. +1 −1 django/contrib/databrowse/templates/databrowse/calendar_year.html
  18. +1 −1 django/contrib/databrowse/templates/databrowse/choice_detail.html
  19. +1 −1 django/contrib/databrowse/templates/databrowse/choice_list.html
  20. +2 −2 django/contrib/databrowse/templates/databrowse/fieldchoice_detail.html
  21. +1 −1 django/contrib/databrowse/templates/databrowse/fieldchoice_homepage.html
  22. +1 −1 django/contrib/databrowse/templates/databrowse/fieldchoice_list.html
  23. +1 −1 django/contrib/databrowse/templates/databrowse/homepage.html
  24. +2 −2 django/contrib/databrowse/templates/databrowse/model_detail.html
  25. +1 −1 django/contrib/databrowse/templates/databrowse/object_detail.html
  26. 0 django/contrib/localflavor/pl/__init__.py
  27. +84 −0 django/contrib/localflavor/pl/forms.py
  28. +385 −0 django/contrib/localflavor/pl/pl_administrativeunits.py
  29. +24 −0 django/contrib/localflavor/pl/pl_voivodeships.py
  30. +3 −3 django/core/management/base.py
  31. +6 −5 django/core/management/commands/createcachetable.py
  32. +2 −2 django/core/management/commands/loaddata.py
  33. +2 −2 django/core/management/commands/sqlsequencereset.py
  34. +4 −4 django/core/management/commands/syncdb.py
  35. +71 −63 django/core/management/sql.py
  36. +218 −0 django/db/backends/__init__.py
  37. +56 −139 django/db/backends/ado_mssql/base.py
  38. +9 −26 django/db/backends/dummy/base.py
  39. +94 −158 django/db/backends/mysql/base.py
  40. +2 −1 django/db/backends/mysql/introspection.py
  41. +96 −156 django/db/backends/mysql_old/base.py
  42. +2 −1 django/db/backends/mysql_old/introspection.py
  43. +381 −427 django/db/backends/oracle/base.py
  44. +2 −17 django/db/backends/oracle/creation.py
  45. +2 −2 django/db/backends/oracle/introspection.py
  46. +31 −215 django/db/backends/postgresql/base.py
  47. +3 −1 django/db/backends/postgresql/introspection.py
  48. +109 −0 django/db/backends/postgresql/operations.py
  49. +30 −202 django/db/backends/postgresql_psycopg2/base.py
  50. +3 −1 django/db/backends/postgresql_psycopg2/introspection.py
  51. +68 −142 django/db/backends/sqlite3/base.py
  52. +3 −1 django/db/backends/sqlite3/introspection.py
  53. +0 −27 django/db/backends/util.py
  54. +1 −1 django/db/models/__init__.py
  55. +33 −26 django/db/models/base.py
  56. +3 −6 django/db/models/fields/related.py
  57. +181 −106 django/db/models/loading.py
  58. +5 −5 django/db/models/options.py
  59. +59 −51 django/db/models/query.py
  60. +6 −6 django/template/defaulttags.py
  61. +1 −1 django/template/loader_tags.py
  62. +9 −7 django/test/utils.py
  63. +1 −1 docs/contributing.txt
  64. +2 −2 docs/install.txt
  65. +40 −0 docs/man/compile-messages.1
  66. +34 −0 docs/man/daily_cleanup.1
  67. +26 −0 docs/man/gather_profile_stats.1
  68. +62 −0 docs/man/make-messages.1
  69. +2 −2 docs/newforms.txt
  70. +11 −0 docs/templates.txt
  71. +1 −1 docs/templates_python.txt
  72. +8 −5 docs/tutorial04.txt
  73. +13 −3 docs/url_dispatch.txt
  74. +1 −0 tests/modeltests/test_client/models.py
  75. +56 −1 tests/regressiontests/forms/localflavor.py
  76. +16 −0 tests/regressiontests/string_lookup/models.py
View
@@ -103,6 +103,7 @@ answer newbie questions, and generally made Django that much better:
dusk@woofle.net
Andy Dustman <farcepest@gmail.com>
Clint Ecker
+ Nick Efford <nick@efford.org>
eibaan@gmail.com
enlight
Enrico <rico.bl@gmail.com>
@@ -197,6 +198,7 @@ answer newbie questions, and generally made Django that much better:
mccutchen@gmail.com
michael.mcewan@gmail.com
mikko@sorl.net
+ Slawek Mikula <slawek dot mikula at gmail dot com>
mitakummaa@gmail.com
mmarshall
Andreas Mock <andreas.mock@web.de>
@@ -25,7 +25,8 @@
INTERNAL_IPS = ()
# Local time zone for this installation. All choices can be found here:
-# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name (although not all
+# systems may support all possibilities).
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
Binary file not shown.
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: django\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-08-13 11:29-0400\n"
+"POT-Creation-Date: 2007-08-17 15:35-0400\n"
"PO-Revision-Date: 2007-07-14 13:00-0500\n"
"Last-Translator: Mario Gonzalez <gonzalemario @t gmail.com>\n"
"Language-Team: Castellano <Django-I18N@googlegroups.com>\n"
@@ -22,6 +22,7 @@ msgstr "%(object)s de este %(type)s ya existen en este %(field)s."
#: db/models/manipulators.py:310 contrib/admin/views/main.py:342
#: contrib/admin/views/main.py:344 contrib/admin/views/main.py:346
+#: core/validators.py:275
msgid "and"
msgstr "y"
@@ -510,6 +511,10 @@ msgstr "%(number)d %(type)s"
msgid ", %(number)d %(type)s"
msgstr ", %(number)d %(type)s"
+#: utils/text.py:127
+msgid "or"
+msgstr "o"
+
#: utils/dateformat.py:41
msgid "p.m."
msgstr "p.m"
@@ -765,7 +770,7 @@ msgstr "ocho"
msgid "nine"
msgstr "nueve"
-#: contrib/auth/views.py:41
+#: contrib/auth/views.py:47
msgid "Logged out"
msgstr "Sesión terminada"
@@ -17,8 +17,8 @@
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
# Local time zone for this installation. Choices can be found here:
-# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
-# although not all variations may be possible on all operating systems.
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be avilable on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'
@@ -59,7 +59,7 @@
{% else %}
<ul class="actionlist">
{% for entry in admin_log %}
- <li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}">{% if not entry.is_deletion %}<a href="{{ entry.get_admin_url }}">{% endif %}{{ entry.object_repr|escape }}{% if not entry.is_deletion %}</a>{% endif %}<br /><span class="mini quiet">{{ entry.content_type.name|capfirst|escape }}</span></li>
+ <li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}">{% if not entry.is_deletion %}<a href="{{ entry.get_admin_url }}">{% endif %}{{ entry.object_repr|escape }}{% if not entry.is_deletion %}</a>{% endif %}<br /><span class="mini quiet">{% filter capfirst|escape %}{% trans entry.content_type.name %}{% endfilter %}</span></li>
{% endfor %}
</ul>
{% endif %}
@@ -1,6 +1,6 @@
from django.core import validators
from django.core.exceptions import ImproperlyConfigured
-from django.db import backend, connection, models
+from django.db import connection, models
from django.contrib.contenttypes.models import ContentType
from django.utils.encoding import smart_str
from django.utils.translation import ugettext_lazy as _
@@ -188,20 +188,21 @@ def get_group_permissions(self):
# AND gp."group_id" = ug."group_id"
# AND ct."id" = p."content_type_id"
# AND ug."user_id" = %s, [self.id])
+ qn = connection.ops.quote_name
sql = """
SELECT ct.%s, p.%s
FROM %s p, %s gp, %s ug, %s ct
WHERE p.%s = gp.%s
AND gp.%s = ug.%s
AND ct.%s = p.%s
AND ug.%s = %%s""" % (
- backend.quote_name('app_label'), backend.quote_name('codename'),
- backend.quote_name('auth_permission'), backend.quote_name('auth_group_permissions'),
- backend.quote_name('auth_user_groups'), backend.quote_name('django_content_type'),
- backend.quote_name('id'), backend.quote_name('permission_id'),
- backend.quote_name('group_id'), backend.quote_name('group_id'),
- backend.quote_name('id'), backend.quote_name('content_type_id'),
- backend.quote_name('user_id'),)
+ qn('app_label'), qn('codename'),
+ qn('auth_permission'), qn('auth_group_permissions'),
+ qn('auth_user_groups'), qn('django_content_type'),
+ qn('id'), qn('permission_id'),
+ qn('group_id'), qn('group_id'),
+ qn('id'), qn('content_type_id'),
+ qn('user_id'),)
cursor.execute(sql, [self.id])
self._group_perm_cache = set(["%s.%s" % (row[0], row[1]) for row in cursor.fetchall()])
return self._group_perm_cache
@@ -4,7 +4,7 @@
from django import oldforms
from django.core.exceptions import ObjectDoesNotExist
-from django.db import backend
+from django.db import connection
from django.db.models import signals
from django.db.models.fields.related import RelatedField, Field, ManyToManyRel
from django.db.models.loading import get_model
@@ -163,13 +163,15 @@ def __get__(self, instance, instance_type=None):
superclass = rel_model._default_manager.__class__
RelatedManager = create_generic_related_manager(superclass)
+ qn = connection.ops.quote_name
+
manager = RelatedManager(
model = rel_model,
instance = instance,
symmetrical = (self.field.rel.symmetrical and instance.__class__ == rel_model),
- join_table = backend.quote_name(self.field.m2m_db_table()),
- source_col_name = backend.quote_name(self.field.m2m_column_name()),
- target_col_name = backend.quote_name(self.field.m2m_reverse_name()),
+ join_table = qn(self.field.m2m_db_table()),
+ source_col_name = qn(self.field.m2m_column_name()),
+ target_col_name = qn(self.field.m2m_reverse_name()),
content_type = ContentType.objects.get_for_model(self.field.model),
content_type_field_name = self.field.content_type_field_name,
object_id_field_name = self.field.object_id_field_name
@@ -8,6 +8,7 @@
from django.utils.text import capfirst
from django.utils.translation import get_date_formats
from django.utils.encoding import smart_unicode, smart_str, iri_to_uri
+from django.db.models.query import QuerySet
EMPTY_VALUE = '(None)'
@@ -30,8 +31,12 @@ def url(self):
return '%s%s/%s/' % (self.site.root_url, self.model._meta.app_label, self.model._meta.module_name)
def objects(self, **kwargs):
- for obj in self.model._default_manager.filter(**kwargs):
- yield EasyInstance(self, obj)
+ return self.get_query_set().filter(**kwargs)
+
+ def get_query_set(self):
+ easy_qs = self.model._default_manager.get_query_set()._clone(klass=EasyQuerySet)
+ easy_qs._easymodel = self
+ return easy_qs
def object_by_pk(self, pk):
return EasyInstance(self, self.model._default_manager.get(pk=pk))
@@ -194,3 +199,17 @@ def urls(self):
else:
lst = [(self.values()[0], None)]
return lst
+
+class EasyQuerySet(QuerySet):
+ """
+ When creating (or cloning to) an `EasyQuerySet`, make sure to set the
+ `_easymodel` variable to the related `EasyModel`.
+ """
+ def iterator(self, *args, **kwargs):
+ for obj in super(EasyQuerySet, self).iterator(*args, **kwargs):
+ yield EasyInstance(self._easymodel, obj)
+
+ def _clone(self, *args, **kwargs):
+ c = super(EasyQuerySet, self)._clone(*args, **kwargs)
+ c._easymodel = self._easymodel
+ return c
@@ -64,22 +64,22 @@ def homepage_view(self, request):
def calendar_view(self, request, field, year=None, month=None, day=None):
easy_model = EasyModel(self.site, self.model)
+ queryset = easy_model.get_query_set()
extra_context = {'root_url': self.site.root_url, 'model': easy_model, 'field': field}
if day is not None:
- # TODO: The objects in this template should be EasyInstances
- return date_based.archive_day(request, year, month, day, self.model.objects.all(), field.name,
+ return date_based.archive_day(request, year, month, day, queryset, field.name,
template_name='databrowse/calendar_day.html', allow_empty=False, allow_future=True,
extra_context=extra_context)
elif month is not None:
- return date_based.archive_month(request, year, month, self.model.objects.all(), field.name,
+ return date_based.archive_month(request, year, month, queryset, field.name,
template_name='databrowse/calendar_month.html', allow_empty=False, allow_future=True,
extra_context=extra_context)
elif year is not None:
- return date_based.archive_year(request, year, self.model.objects.all(), field.name,
+ return date_based.archive_year(request, year, queryset, field.name,
template_name='databrowse/calendar_year.html', allow_empty=False, allow_future=True,
extra_context=extra_context)
else:
- return date_based.archive_index(request, self.model.objects.all(), field.name,
+ return date_based.archive_index(request, queryset, field.name,
template_name='databrowse/calendar_main.html', allow_empty=True, allow_future=True,
extra_context=extra_context)
assert False, ('%s, %s, %s, %s' % (field, year, month, day))
@@ -2,6 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="{{ LANGUAGE_CODE }}" xml:lang="{{ LANGUAGE_CODE }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
<head>
<title>{% block title %}{% endblock %}</title>
+{% block style %}
<style type="text/css">
* { margin:0; padding:0; }
body { background:#eee; color:#333; font:76%/1.6 "Lucida Grande","Bitstream Vera Sans",Verdana,sans-serif; }
@@ -48,9 +49,11 @@
/* CONTENT */
#content { background:#fff; border-bottom:1px solid #ddd; padding:0 20px; }
</style>
+{% endblock %}
+{% block extrahead %}{% endblock %}
</head>
<body id="{% block bodyid %}page{% endblock %}">
-<div id="header"><a href="{{ root_url }}">Databrowse</a></div>
+<div id="header"><a href="{{ root_url }}">{% block databrowse_title %}Databrowse{% endblock %}</a></div>
<div id="content">
{% block content %}{% endblock %}
</div>
@@ -0,0 +1 @@
+{% extends "databrowse/base.html" %}
@@ -1,12 +1,12 @@
-{% extends "databrowse/base.html" %}
+{% extends "databrowse/base_site.html" %}
{% block title %}{{ model.verbose_name_plural|capfirst }} with {{ field.verbose_name }} {{ day|date:"F j, Y" }}{% endblock %}
{% block content %}
<div id="breadcrumbs"><a href="{{ root_url }}">Home</a> / <a href="{{ model.url }}">{{ model.verbose_name_plural|capfirst }}</a> / <a href="../../../../">Calendars</a> / <a href="../../../">By {{ field.verbose_name }}</a> / <a href="../../">{{ day.year }}</a> / <a href="../">{{ day|date:"F" }}</a> / {{ day.day }}</div>
-<h1>{{ model.verbose_name_plural|capfirst }} with {{ field.verbose_name }} on {{ day|date:"F j, Y" }}</h1>
+<h1>{{ object_list.count }} {% if object_list.count|pluralize %}{{ model.verbose_name_plural|escape }}{% else %}{{ model.verbose_name|escape }}{% endif %} with {{ field.verbose_name }} on {{ day|date:"F j, Y" }}</h1>
<ul class="objectlist">
{% for object in object_list %}
@@ -1,4 +1,4 @@
-{% extends "databrowse/base.html" %}
+{% extends "databrowse/base_site.html" %}
{% block title %}Calendars{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "databrowse/base.html" %}
+{% extends "databrowse/base_site.html" %}
{% block title %}{{ field.verbose_name|capfirst }} calendar{% endblock %}
@@ -1,12 +1,12 @@
-{% extends "databrowse/base.html" %}
+{% extends "databrowse/base_site.html" %}
{% block title %}{{ model.verbose_name_plural|capfirst }} with {{ field.verbose_name }} in {{ month|date:"F Y" }}{% endblock %}
{% block content %}
<div id="breadcrumbs"><a href="{{ root_url }}">Home</a> / <a href="{{ model.url }}">{{ model.verbose_name_plural|capfirst }}</a> / <a href="../../../">Calendars</a> / <a href="../../">By {{ field.verbose_name }}</a> / <a href="../">{{ month.year }}</a> / {{ month|date:"F" }}</div>
-<h1>{{ model.verbose_name_plural|capfirst }} with {{ field.verbose_name }} in {{ month|date:"F Y" }}</h1>
+<h1>{{ object_list.count }} {% if object_list.count|pluralize %}{{ model.verbose_name_plural|escape }}{% else %}{{ model.verbose_name|escape }}{% endif %} with {{ field.verbose_name }} on {{ day|date:"F Y" }}</h1>
<ul class="objectlist">
{% for object in object_list %}
@@ -1,4 +1,4 @@
-{% extends "databrowse/base.html" %}
+{% extends "databrowse/base_site.html" %}
{% block title %}{{ model.verbose_name_plural|capfirst }} with {{ field.verbose_name }} in {{ year }}{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "databrowse/base.html" %}
+{% extends "databrowse/base_site.html" %}
{% block title %}{{ model.verbose_name_plural|capfirst }} by {{ field.field.verbose_name }}: {{ value|escape }}{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "databrowse/base.html" %}
+{% extends "databrowse/base_site.html" %}
{% block title %}{{ model.verbose_name_plural|capfirst }} by {{ field.field.verbose_name }}{% endblock %}
@@ -1,12 +1,12 @@
-{% extends "databrowse/base.html" %}
+{% extends "databrowse/base_site.html" %}
{% block title %}{{ model.verbose_name_plural|capfirst|escape }} with {{ field.field.verbose_name|escape }} {{ value|escape }}{% endblock %}
{% block content %}
<div id="breadcrumbs"><a href="{{ root_url }}">Home</a> / <a href="{{ model.url }}">{{ model.verbose_name_plural|capfirst }}</a> / <a href="../../">Fields</a> / <a href="../">By {{ field.field.verbose_name|escape }}</a> / {{ value|escape }}</div>
-<h1>{{ model.verbose_name_plural|capfirst|escape }} with {{ field.field.verbose_name|escape }} {{ value|escape }}</h1>
+<h1>{{ object_list.count }} {% if object_list.count|pluralize %}{{ model.verbose_name_plural|escape }}{% else %}{{ model.verbose_name|escape }}{% endif %} with {{ field.field.verbose_name|escape }} {{ value|escape }}</h1>
<ul class="objectlist">
{% for object in object_list %}
@@ -1,4 +1,4 @@
-{% extends "databrowse/base.html" %}
+{% extends "databrowse/base_site.html" %}
{% block title %}Browsable fields in {{ model.verbose_name_plural|escape }}{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "databrowse/base.html" %}
+{% extends "databrowse/base_site.html" %}
{% block title %}{{ model.verbose_name_plural|capfirst|escape }} by {{ field.field.verbose_name|escape }}{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "databrowse/base.html" %}
+{% extends "databrowse/base_site.html" %}
{% block title %}Databrowse{% endblock %}
@@ -1,12 +1,12 @@
-{% extends "databrowse/base.html" %}
+{% extends "databrowse/base_site.html" %}
{% block title %}{{ model.verbose_name_plural|capfirst }}{% endblock %}
{% block content %}
<div id="breadcrumbs"><a href="{{ root_url }}">Home</a> / {{ model.verbose_name_plural|capfirst }}</div>
-<h1>{{ model.verbose_name_plural|capfirst }}</h1>
+<h1>{{ model.objects.count }} {% if model.objects.count|pluralize %}{{ model.verbose_name_plural }}{% else %}{{ model.verbose_name }}{% endif %}</h1>
{{ plugin_html }}
@@ -1,4 +1,4 @@
-{% extends "databrowse/base.html" %}
+{% extends "databrowse/base_site.html" %}
{% block title %}{{ object.model.verbose_name|capfirst }}: {{ object }}{% endblock %}
No changes.
Oops, something went wrong.

0 comments on commit c49f2d2

Please sign in to comment.