1
0
mirror of https://github.com/django/django.git synced 2025-07-05 02:09:13 +00:00

newforms-admin: Moved save_as from AdminOptions to ModelAdmin.

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@4333 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2007-01-16 00:35:25 +00:00
parent dcbfd3fa83
commit 7ffbc9d22c
4 changed files with 6 additions and 5 deletions

View File

@ -37,6 +37,7 @@ class ModelAdmin(object):
list_display_links = ()
list_filter = ()
date_hierarchy = None
save_as = False
def __init__(self, model):
self.model = model

View File

@ -41,8 +41,8 @@ def submit_row(context):
and 'onclick="submitOrderForm();"' or ''),
'show_delete_link': (not is_popup and context['has_delete_permission']
and (change or context['show_delete'])),
'show_save_as_new': not is_popup and change and opts.admin.save_as,
'show_save_and_add_another': not is_popup and (not opts.admin.save_as or context['add']),
'show_save_as_new': not is_popup and change and opts.ModelAdmin.save_as,
'show_save_and_add_another': not is_popup and (not opts.ModelAdmin.save_as or context['add']),
'show_save_and_continue': not is_popup and context['has_change_permission'],
'show_save': True
}

View File

@ -137,7 +137,7 @@ class Model(object):
# 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')]))
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')]))
value.contribute_to_class(cls, name)
elif hasattr(value, 'contribute_to_class'):
value.contribute_to_class(cls, name)

View File

@ -200,11 +200,11 @@ class Options(object):
class AdminOptions(object):
def __init__(self, fields=None, js=None,
save_as=False, ordering=None, search_fields=None,
ordering=None, search_fields=None,
save_on_top=False, list_select_related=False, manager=None, list_per_page=100):
self.fields = fields
self.js = js or []
self.save_as, self.ordering = save_as, ordering
self.ordering = ordering
self.search_fields = search_fields or []
self.save_on_top = save_on_top
self.list_select_related = list_select_related