mirror of
https://github.com/django/django.git
synced 2025-07-05 18:29:11 +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:
parent
dcbfd3fa83
commit
7ffbc9d22c
@ -37,6 +37,7 @@ class ModelAdmin(object):
|
|||||||
list_display_links = ()
|
list_display_links = ()
|
||||||
list_filter = ()
|
list_filter = ()
|
||||||
date_hierarchy = None
|
date_hierarchy = None
|
||||||
|
save_as = False
|
||||||
|
|
||||||
def __init__(self, model):
|
def __init__(self, model):
|
||||||
self.model = model
|
self.model = model
|
||||||
|
@ -41,8 +41,8 @@ def submit_row(context):
|
|||||||
and 'onclick="submitOrderForm();"' or ''),
|
and 'onclick="submitOrderForm();"' or ''),
|
||||||
'show_delete_link': (not is_popup and context['has_delete_permission']
|
'show_delete_link': (not is_popup and context['has_delete_permission']
|
||||||
and (change or context['show_delete'])),
|
and (change or context['show_delete'])),
|
||||||
'show_save_as_new': not is_popup and change and opts.admin.save_as,
|
'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.admin.save_as or context['add']),
|
'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_and_continue': not is_popup and context['has_change_permission'],
|
||||||
'show_save': True
|
'show_save': True
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ class Model(object):
|
|||||||
# of ModelAdmin.
|
# of ModelAdmin.
|
||||||
cls._meta.ModelAdmin = type('ModelAdmin', (value, ModelAdmin), {})
|
cls._meta.ModelAdmin = type('ModelAdmin', (value, ModelAdmin), {})
|
||||||
# This AdminOptions stuff is legacy and will eventually be removed.
|
# 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)
|
value.contribute_to_class(cls, name)
|
||||||
elif hasattr(value, 'contribute_to_class'):
|
elif hasattr(value, 'contribute_to_class'):
|
||||||
value.contribute_to_class(cls, name)
|
value.contribute_to_class(cls, name)
|
||||||
|
@ -200,11 +200,11 @@ class Options(object):
|
|||||||
|
|
||||||
class AdminOptions(object):
|
class AdminOptions(object):
|
||||||
def __init__(self, fields=None, js=None,
|
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):
|
save_on_top=False, list_select_related=False, manager=None, list_per_page=100):
|
||||||
self.fields = fields
|
self.fields = fields
|
||||||
self.js = js or []
|
self.js = js or []
|
||||||
self.save_as, self.ordering = save_as, ordering
|
self.ordering = ordering
|
||||||
self.search_fields = search_fields or []
|
self.search_fields = search_fields or []
|
||||||
self.save_on_top = save_on_top
|
self.save_on_top = save_on_top
|
||||||
self.list_select_related = list_select_related
|
self.list_select_related = list_select_related
|
||||||
|
Loading…
x
Reference in New Issue
Block a user