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