=== modified file 'django/contrib/admin/options.py'
|
|
|
459 | 459 | request.user.message_set.create(message=msg) |
460 | 460 | return HttpResponseRedirect(redirect_url) |
461 | 461 | |
462 | | def render_change_form(self, model, context, add=False, change=False, form_url=''): |
| 462 | def render_change_form(self, request, context, add=False, change=False): |
| 463 | model = self.model |
463 | 464 | opts = model._meta |
464 | 465 | app_label = opts.app_label |
465 | 466 | ordered_objects = opts.get_ordered_objects() |
… |
… |
|
471 | 472 | 'has_file_field': True, # FIXME - this should check if form or formsets have a FileField, |
472 | 473 | 'has_absolute_url': hasattr(model, 'get_absolute_url'), |
473 | 474 | 'ordered_objects': ordered_objects, |
474 | | 'form_url': mark_safe(form_url), |
475 | 475 | 'opts': opts, |
476 | 476 | 'content_type_id': ContentType.objects.get_for_model(model).id, |
477 | 477 | 'save_on_top': self.save_on_top, |
| 478 | 'save_as': self.save_as, |
| 479 | 'is_save_as': request.POST.has_key('_saveasnew'), |
478 | 480 | } |
479 | 481 | context.update(extra_context) |
480 | 482 | return render_to_response([ |
… |
… |
|
482 | 484 | "admin/%s/change_form.html" % app_label, |
483 | 485 | "admin/change_form.html"], context_instance=context) |
484 | 486 | |
485 | | def add_view(self, request, form_url=''): |
| 487 | def add_view(self, request): |
486 | 488 | "The 'add' admin view for this model." |
487 | 489 | model = self.model |
488 | 490 | opts = model._meta |
… |
… |
|
527 | 529 | 'media': media, |
528 | 530 | 'inline_admin_formsets': inline_admin_formsets, |
529 | 531 | }) |
530 | | return self.render_change_form(model, c, add=True) |
| 532 | return self.render_change_form(request, c, add=True) |
531 | 533 | |
532 | 534 | def change_view(self, request, object_id): |
533 | 535 | "The 'change' admin view for this model." |
… |
… |
|
549 | 551 | if obj is None: |
550 | 552 | raise Http404('%s object with primary key %r does not exist.' % (opts.verbose_name, escape(object_id))) |
551 | 553 | |
552 | | if request.POST and request.POST.has_key("_saveasnew"): |
553 | | return self.add_view(request, form_url='../../add/') |
| 554 | if request.POST and request.POST.has_key('_saveasnew'): |
| 555 | return self.add_view(request) |
554 | 556 | |
555 | 557 | ModelForm = self.form_change(request, obj) |
556 | 558 | inline_formsets = [] |
… |
… |
|
604 | 606 | 'media': media, |
605 | 607 | 'inline_admin_formsets': inline_admin_formsets, |
606 | 608 | }) |
607 | | return self.render_change_form(model, c, change=True) |
| 609 | return self.render_change_form(request, c, change=True) |
608 | 610 | |
609 | 611 | def changelist_view(self, request): |
610 | 612 | "The 'change list' admin view for this model." |
=== 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 | 29 | 'show_delete_link': (not is_popup and context['has_delete_permission'] |
30 | 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': not is_popup and (not save_as or context['add']), |
33 | | 'show_save_and_continue': not is_popup and context['has_change_permission'], |
34 | | 'show_save': True |
| 31 | 'show_save_as_new': not is_popup and save_as and (is_save_as or change), |
| 32 | 'show_save_and_add_another': not is_popup and not is_save_as and (add or not save_as), |
| 33 | 'show_save_and_continue': not is_popup and not is_save_as and context['has_change_permission'], |
| 34 | 'show_save': not is_save_as, |
35 | 35 | } |
36 | 36 | submit_row = register.inclusion_tag('admin/submit_line.html', takes_context=True)(submit_row) |
37 | 37 | |
=== modified file 'django/contrib/admin/views/auth.py'
|
|
|
40 | 40 | 'auto_populated_fields': (), |
41 | 41 | 'opts': User._meta, |
42 | 42 | 'username_help_text': User._meta.get_field('username').help_text, |
| 43 | 'save_as': False, |
| 44 | 'is_save_as': False, |
43 | 45 | }, context_instance=template.RequestContext(request)) |
44 | 46 | user_add_stage = staff_member_required(user_add_stage) |
45 | 47 | |
… |
… |
|
71 | 73 | 'opts': User._meta, |
72 | 74 | 'original': user, |
73 | 75 | 'show_save': True, |
| 76 | 'save_as': False, |
| 77 | 'is_save_as': False, |
74 | 78 | }, context_instance=template.RequestContext(request)) |
75 | 79 | user_change_password = staff_member_required(user_change_password) |