Author: adrian
Date: 2007-01-16 20:13:06 -0600 (Tue, 16 Jan 2007)
New Revision: 4342
Modified:
django/branches/newforms-admin/django/contrib/admin/options.py
django/branches/newforms-admin/django/contrib/admin/views/main.py
django/branches/newforms-admin/django/db/models/base.py
django/branches/newforms-admin/django/db/models/options.py
Log:
newforms-admin: Backwards-incompatible change: Removed undocumented
Admin.manager option in favor of Admin.change_list_queryset() method
Modified: django/branches/newforms-admin/django/contrib/admin/options.py
===================================================================
--- django/branches/newforms-admin/django/contrib/admin/options.py
2007-01-17 01:45:01 UTC (rev 4341)
+++ django/branches/newforms-admin/django/contrib/admin/options.py
2007-01-17 02:13:06 UTC (rev 4342)
@@ -95,6 +95,9 @@
opts = self.opts
return request.user.has_perm(opts.app_label + '.' +
opts.get_delete_permission())
+ def change_list_queryset(self, request):
+ return self.model._default_manager.get_query_set()
+
def add_view(self, request, show_delete=False, form_url='', post_url=None,
post_url_continue='../%s/', object_id_override=None):
"The 'add' admin view for this model."
from django.contrib.admin.views.main import render_change_form
@@ -280,7 +283,7 @@
raise PermissionDenied
try:
cl = ChangeList(request, self.model, self.list_display,
self.list_display_links, self.list_filter,
- self.date_hierarchy, self.search_fields,
self.list_select_related, self.list_per_page)
+ self.date_hierarchy, self.search_fields,
self.list_select_related, self.list_per_page, self)
except IncorrectLookupParameters:
# Wacky lookup parameters were given, so redirect to the main
# changelist page, without parameters, and pass an 'invalid=1'
Modified: django/branches/newforms-admin/django/contrib/admin/views/main.py
===================================================================
--- django/branches/newforms-admin/django/contrib/admin/views/main.py
2007-01-17 01:45:01 UTC (rev 4341)
+++ django/branches/newforms-admin/django/contrib/admin/views/main.py
2007-01-17 02:13:06 UTC (rev 4342)
@@ -293,11 +293,11 @@
perms_needed.add(related.opts.verbose_name)
class ChangeList(object):
- def __init__(self, request, model, list_display, list_display_links,
list_filter, date_hierarchy, search_fields, list_select_related, list_per_page):
+ def __init__(self, request, model, list_display, list_display_links,
list_filter, date_hierarchy, search_fields, list_select_related, list_per_page,
model_admin):
self.model = model
self.opts = model._meta
self.lookup_opts = self.opts
- self.manager = self.opts.admin.manager
+ self.root_query_set = model_admin.change_list_queryset(request)
self.list_display = list_display
self.list_display_links = list_display_links
self.list_filter = list_filter
@@ -372,7 +372,7 @@
if isinstance(self.query_set._filters, models.Q) and not
self.query_set._filters.kwargs:
full_result_count = result_count
else:
- full_result_count = self.manager.count()
+ full_result_count = self.root_query_set.count()
can_show_all = result_count <= MAX_SHOW_ALL_ALLOWED
multi_page = result_count > self.list_per_page
@@ -424,7 +424,7 @@
return order_field, order_type
def get_query_set(self):
- qs = self.manager.get_query_set()
+ qs = self.root_query_set
lookup_params = self.params.copy() # a dictionary of the query string
for i in (ALL_VAR, ORDER_VAR, ORDER_TYPE_VAR, SEARCH_VAR, IS_POPUP_VAR):
if lookup_params.has_key(i):
Modified: django/branches/newforms-admin/django/db/models/base.py
===================================================================
--- django/branches/newforms-admin/django/db/models/base.py 2007-01-17
01:45:01 UTC (rev 4341)
+++ django/branches/newforms-admin/django/db/models/base.py 2007-01-17
02:13:06 UTC (rev 4342)
@@ -137,7 +137,7 @@
# of ModelAdmin.
cls._meta.ModelAdmin = type('ModelAdmin', (value, ModelAdmin), {})
# This AdminOptions stuff is legacy and will eventually be removed.
- value = AdminOptions(**dict([(k, v) for k, v in
value.__dict__.items() if not k.startswith('_') and k not in ('list_display',
'list_display_links', 'list_filter', 'date_hierarchy', 'save_as',
'search_fields', 'list_select_related', 'list_per_page', 'ordering',
'save_on_top', 'js')]))
+ value = AdminOptions(**dict([(k, v) for k, v in
value.__dict__.items() if not k.startswith('_') and k not in ('list_display',
'list_display_links', 'list_filter', 'date_hierarchy', 'save_as',
'search_fields', 'list_select_related', 'list_per_page', 'ordering',
'save_on_top', 'js', 'manager')]))
value.contribute_to_class(cls, name)
elif hasattr(value, 'contribute_to_class'):
value.contribute_to_class(cls, name)
Modified: django/branches/newforms-admin/django/db/models/options.py
===================================================================
--- django/branches/newforms-admin/django/db/models/options.py 2007-01-17
01:45:01 UTC (rev 4341)
+++ django/branches/newforms-admin/django/db/models/options.py 2007-01-17
02:13:06 UTC (rev 4342)
@@ -4,7 +4,6 @@
from django.db.models.fields import AutoField, FieldDoesNotExist
from django.db.models.loading import get_models
from django.db.models.query import orderlist2sql
-from django.db.models import Manager
from bisect import bisect
import re
@@ -199,9 +198,8 @@
return self._field_types[field_type]
class AdminOptions(object):
- def __init__(self, fields=None, manager=None):
+ def __init__(self, fields=None):
self.fields = fields
- self.manager = manager or Manager()
def get_field_sets(self, opts):
"Returns a list of AdminFieldSet objects for this AdminOptions object."
@@ -220,8 +218,6 @@
def contribute_to_class(self, cls, name):
cls._meta.admin = self
- # Make sure the admin manager has access to the model
- self.manager.model = cls
class AdminFieldSet(object):
def __init__(self, name, classes, field_locator_func, line_specs,
description):
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django
updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---