1
0
mirror of https://github.com/django/django.git synced 2025-07-04 17:59:13 +00:00

newforms-admin: Moved save_on_top from AdminOptions to ModelAdmin.

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@4338 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2007-01-16 01:05:25 +00:00
parent 052363fb8b
commit a2b25f7216
5 changed files with 5 additions and 4 deletions

View File

@ -41,6 +41,7 @@ class ModelAdmin(object):
search_fields = ()
date_hierarchy = None
save_as = False
save_on_top = False
ordering = None
def __init__(self, model):

View File

@ -26,7 +26,7 @@
<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.module_name }}_form">{% block form_top %}{% endblock %}
<div>
{% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %}
{% if opts.admin.save_on_top %}{% submit_row %}{% endif %}
{% if save_on_top %}{% submit_row %}{% endif %}
{% if form.error_dict %}
<p class="errornote">
{% blocktrans count form.error_dict.items|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}

View File

@ -192,6 +192,7 @@ def render_change_form(model, manipulator, context, add=False, change=False, for
'form_url': form_url,
'opts': opts,
'content_type_id': ContentType.objects.get_for_model(model).id,
'save_on_top': opts.ModelAdmin.save_on_top,
}
context.update(extra_context)
return render_to_response([

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', 'save_as', 'search_fields', 'list_select_related', 'list_per_page', 'ordering')]))
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')]))
value.contribute_to_class(cls, name)
elif hasattr(value, 'contribute_to_class'):
value.contribute_to_class(cls, name)

View File

@ -200,10 +200,9 @@ class Options(object):
class AdminOptions(object):
def __init__(self, fields=None, js=None,
save_on_top=False, manager=None):
manager=None):
self.fields = fields
self.js = js or []
self.save_on_top = save_on_top
self.manager = manager or Manager()
def get_field_sets(self, opts):