=== modified file 'django/contrib/admin/options.py'
|
|
|
527 | 527 | 'media': media, |
528 | 528 | 'inline_admin_formsets': inline_admin_formsets, |
529 | 529 | }) |
| 530 | c.update(self.add_view_extra_context(request)) |
530 | 531 | return self.render_change_form(request, c, add=True) |
531 | 532 | |
532 | 533 | def change_view(self, request, object_id): |
… |
… |
|
604 | 605 | 'media': media, |
605 | 606 | 'inline_admin_formsets': inline_admin_formsets, |
606 | 607 | }) |
| 608 | c.update(self.change_view_extra_context(request, obj)) |
607 | 609 | return self.render_change_form(request, c, obj, change=True) |
608 | 610 | |
609 | 611 | def changelist_view(self, request): |
… |
… |
|
631 | 633 | 'cl': cl, |
632 | 634 | }) |
633 | 635 | c.update({'has_add_permission': self.has_add_permission(request)}), |
| 636 | c.update(self.changelist_view_extra_context(request)) |
634 | 637 | return render_to_response(['admin/%s/%s/change_list.html' % (app_label, opts.object_name.lower()), |
635 | 638 | 'admin/%s/change_list.html' % app_label, |
636 | 639 | 'admin/change_list.html'], context_instance=c) |
… |
… |
|
678 | 681 | "perms_lacking": perms_needed, |
679 | 682 | "opts": opts, |
680 | 683 | } |
| 684 | extra_context.update(self.delete_view_extra_context(request, obj)) |
681 | 685 | return render_to_response(["admin/%s/%s/delete_confirmation.html" % (app_label, opts.object_name.lower() ), |
682 | 686 | "admin/%s/delete_confirmation.html" % app_label , |
683 | 687 | "admin/delete_confirmation.html"], extra_context, context_instance=template.RequestContext(request)) |
… |
… |
|
703 | 707 | "admin/%s/object_history.html" % opts.app_label, |
704 | 708 | "admin/object_history.html" |
705 | 709 | ] |
| 710 | extra_context.update(self.history_view_extra_context(request, obj)) |
706 | 711 | return render_to_response(template_list, extra_context, context_instance=template.RequestContext(request)) |
707 | 712 | |
708 | 713 | def formsets_add(self, request): |
… |
… |
|
712 | 717 | def formsets_change(self, request, obj): |
713 | 718 | for inline in self.inline_instances: |
714 | 719 | yield inline.formset_change(request, obj) |
| 720 | |
| 721 | def add_view_extra_context(self, request): |
| 722 | """ Extra context for the 'add' admin view. """ |
| 723 | return {} |
| 724 | |
| 725 | def change_view_extra_context(self, request, obj): |
| 726 | """ Extra context for the 'change' admin view. """ |
| 727 | return {} |
| 728 | |
| 729 | def changelist_view_extra_context(self, request): |
| 730 | """ Extra context for the 'change list' admin view. """ |
| 731 | return {} |
| 732 | |
| 733 | def delete_view_extra_context(self, request, obj): |
| 734 | """ Extra context for the 'delete' admin view. """ |
| 735 | return {} |
| 736 | |
| 737 | def history_view_extra_context(self, request, obj): |
| 738 | """ Extra context for the 'history' admin view. """ |
| 739 | return {} |
715 | 740 | |
716 | 741 | class InlineModelAdmin(BaseModelAdmin): |
717 | 742 | """ |
=== modified file 'django/contrib/admin/sites.py'
|
|
|
292 | 292 | for app in app_list: |
293 | 293 | app['models'].sort(lambda x, y: cmp(x['name'], y['name'])) |
294 | 294 | |
295 | | return render_to_response('admin/index.html', { |
296 | | 'title': _('Site administration'), |
297 | | 'app_list': app_list, |
298 | | }, context_instance=template.RequestContext(request)) |
| 295 | context = { |
| 296 | 'title': _('Site administration'), |
| 297 | 'app_list': app_list, |
| 298 | } |
| 299 | context.update(self.index_view_extra_context(request)) |
| 300 | return render_to_response('admin/index.html', context, |
| 301 | context_instance=template.RequestContext(request)) |
| 302 | |
| 303 | def index_view_extra_context(self, request): |
| 304 | """ Extra context for the 'index' admin view. """ |
| 305 | return {} |
299 | 306 | |
300 | 307 | # This global object represents the default admin site, for the common case. |
301 | 308 | # You can instantiate AdminSite in your own code to create a custom admin site. |