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

Fixed save_as option

git-svn-id: http://code.djangoproject.com/svn/django/branches/new-admin@1081 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Robert Wittams 2005-11-04 15:55:08 +00:00
parent 741a13e1dd
commit d545100ddb
3 changed files with 7 additions and 8 deletions

View File

@ -22,7 +22,7 @@
{% endif %}{% endif %}
<form {{ bound_manipulator.form_enc_attrib }} action='{{ form_url }}' method="post">{% block form_top %}{%endblock%}
{% if is_popup %}<input type="hidden" name="_popup" value="1">{% endif %}
{% if bound_manipulator.save_on_top %}{% submit_row %}{% endif %}
{% if bound_manipulator.save_on_top %}{% submit_row bound_manipulator %}{% 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 %}
@ -52,7 +52,7 @@
{% for related_object in bound_manipulator.inline_related_objects %}{% edit_inline related_object %}{% endfor %}
{% block after_related_objects%}{%endblock%}
{% submit_row %}
{% submit_row bound_manipulator %}
{% if add %}
<script type="text/javascript">document.getElementById("{{bound_manipulator.first_form_field_id}}").focus();</script>
{% endif %}

View File

@ -24,22 +24,20 @@ include_admin_script = simple_tag(include_admin_script)
#@inclusion_tag('admin/submit_line', takes_context=True)
def submit_row(context):
def submit_row(context, bound_manipulator):
change = context['change']
add = context['add']
show_delete = context['show_delete']
ordered_objects = context['ordered_objects']
save_as = context['save_as']
has_delete_permission = context['has_delete_permission']
is_popup = context['is_popup']
return {
'onclick_attrib' : (ordered_objects and change
'onclick_attrib' : (bound_manipulator.ordered_objects and change
and 'onclick="submitOrderForm();"' or ''),
'show_delete_link' : (not is_popup and has_delete_permission
and (change or show_delete)),
'show_save_as_new' : not is_popup and change and save_as,
'show_save_and_add_another': not is_popup and (not save_as or add),
'show_save_as_new' : not is_popup and change and bound_manipulator.save_as,
'show_save_and_add_another': not is_popup and (not bound_manipulator.save_as or add),
'show_save_and_continue': not is_popup,
'show_save': True
}

View File

@ -597,6 +597,7 @@ def add_stage(request, app_label, module_name, show_delete=False, form_url='', p
'title': _('Add %s') % opts.verbose_name,
'form': form,
'is_popup': request.REQUEST.has_key('_popup'),
'show_delete': show_delete,
})
if object_id_override is not None:
c['object_id'] = object_id_override