=== modified file 'django/contrib/admin/options.py'
|
|
|
452 | 452 | request.user.message_set.create(message=msg) |
453 | 453 | return HttpResponseRedirect("../") |
454 | 454 | |
455 | | def render_change_form(self, request, model, context, add=False, change=False, form_url='', obj=None): |
| 455 | def render_change_form(self, request, model, context, add=False, change=False, obj=None): |
456 | 456 | opts = model._meta |
457 | 457 | app_label = opts.app_label |
458 | 458 | ordered_objects = opts.get_ordered_objects() |
… |
… |
|
465 | 465 | 'has_file_field': True, # FIXME - this should check if form or formsets have a FileField, |
466 | 466 | 'has_absolute_url': hasattr(model, 'get_absolute_url'), |
467 | 467 | 'ordered_objects': ordered_objects, |
468 | | 'form_url': mark_safe(form_url), |
469 | 468 | 'opts': opts, |
470 | 469 | 'content_type_id': ContentType.objects.get_for_model(model).id, |
471 | 470 | 'save_on_top': self.save_on_top, |
| 471 | 'save_as': self.save_as, |
| 472 | 'is_save_as': request.POST.has_key('_saveasnew'), |
472 | 473 | } |
473 | 474 | context.update(extra_context) |
474 | 475 | return render_to_response([ |
… |
… |
|
476 | 477 | "admin/%s/change_form.html" % app_label, |
477 | 478 | "admin/change_form.html"], context_instance=context) |
478 | 479 | |
479 | | def add_view(self, request, form_url=''): |
| 480 | def add_view(self, request): |
480 | 481 | "The 'add' admin view for this model." |
481 | 482 | model = self.model |
482 | 483 | opts = model._meta |
… |
… |
|
523 | 524 | 'title': _('Add %s') % opts.verbose_name, |
524 | 525 | 'adminform': adminForm, |
525 | 526 | 'is_popup': request.REQUEST.has_key('_popup'), |
526 | | 'show_delete': False, |
527 | 527 | 'media': mark_safe(media), |
528 | 528 | 'inline_admin_formsets': inline_admin_formsets, |
529 | 529 | }) |
… |
… |
|
549 | 549 | if obj is None: |
550 | 550 | raise Http404('%s object with primary key %r does not exist.' % (opts.verbose_name, escape(object_id))) |
551 | 551 | |
552 | | if request.POST and request.POST.has_key("_saveasnew"): |
553 | | return self.add_view(request, form_url='../../add/') |
| 552 | if request.POST and request.POST.has_key('_saveasnew'): |
| 553 | return self.add_view(request) |
554 | 554 | |
555 | 555 | ModelForm = self.form_change(request, obj) |
556 | 556 | inline_formsets = [] |
=== modified file 'django/contrib/admin/templates/admin/change_form.html'
|
|
|
30 | 30 | </ul> |
31 | 31 | {% endif %}{% endif %} |
32 | 32 | {% endblock %} |
33 | | <form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.module_name }}_form">{% block form_top %}{% endblock %} |
| 33 | <form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="." method="post" id="{{ opts.module_name }}_form">{% block form_top %}{% endblock %} |
34 | 34 | <div> |
35 | 35 | {% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %} |
36 | 36 | {% if save_on_top %}{% submit_row %}{% endif %} |
=== modified file 'django/contrib/admin/templatetags/admin_modify.py'
|
|
|
18 | 18 | |
19 | 19 | def submit_row(context): |
20 | 20 | opts = context['opts'] |
| 21 | add = context['add'] |
21 | 22 | change = context['change'] |
22 | 23 | is_popup = context['is_popup'] |
23 | | # TODO: Fix this hack. |
24 | | # save_as = opts.admin.save_as |
25 | | save_as = False |
| 24 | save_as = context['save_as'] |
| 25 | is_save_as = context['is_save_as'] |
26 | 26 | return { |
27 | 27 | 'onclick_attrib': (opts.get_ordered_objects() and change |
28 | 28 | and 'onclick="submitOrderForm();"' or ''), |
29 | | 'show_delete_link': (not is_popup and context['has_delete_permission'] |
30 | | and (change or context['show_delete'])), |
31 | | 'show_save_as_new': not is_popup and change and save_as, |
32 | | 'show_save_and_add_another': context['has_add_permission'] and |
33 | | not is_popup and (not save_as or context['add']), |
34 | | 'show_save_and_continue': not is_popup and context['has_change_permission'], |
35 | | 'show_save': True |
| 29 | 'show_delete_link': change and context['has_delete_permission'] and not is_popup and not is_save_as, |
| 30 | 'show_save_as_new': save_as and (is_save_as or change) and context['has_add_permission'] and not is_popup, |
| 31 | 'show_save_and_add_another': (add or not save_as) and context['has_add_permission'] and not is_popup and not is_save_as, |
| 32 | 'show_save_and_continue': context['has_change_permission'] and not is_popup and not is_save_as, |
| 33 | 'show_save': not is_save_as, |
36 | 34 | } |
37 | 35 | submit_row = register.inclusion_tag('admin/submit_line.html', takes_context=True)(submit_row) |
38 | 36 | |
=== modified file 'django/contrib/auth/admin.py'
|
|
|
57 | 57 | 'auto_populated_fields': (), |
58 | 58 | 'opts': User._meta, |
59 | 59 | 'username_help_text': User._meta.get_field('username').help_text, |
| 60 | 'save_as': False, |
| 61 | 'is_save_as': False, |
60 | 62 | }, context_instance=template.RequestContext(request)) |
61 | 63 | |
62 | 64 | admin.site.register(Group, GroupAdmin) |
=== modified file 'django/contrib/auth/views.py'
|
|
|
129 | 129 | 'opts': User._meta, |
130 | 130 | 'original': user, |
131 | 131 | 'show_save': True, |
| 132 | 'save_as': False, |
| 133 | 'is_save_as': False, |
132 | 134 | }, context_instance=RequestContext(request)) |