Ticket #6552: admin-context.patch
File admin-context.patch, 6.3 KB (added by , 16 years ago) |
---|
-
django/contrib/admin/options.py
3 3 from django.forms.models import modelform_factory, inlineformset_factory 4 4 from django.forms.models import BaseInlineFormSet 5 5 from django.contrib.contenttypes.models import ContentType 6 from django.contrib.admin import widgets 7 from django.contrib.admin import helpers6 from django.contrib.admin import widgets, helpers 7 from django.contrib.admin.context import AdminContext 8 8 from django.contrib.admin.util import unquote, flatten_fieldsets, get_deleted_objects 9 9 from django.core.exceptions import PermissionDenied 10 10 from django.db import models, transaction … … 442 442 "admin/%s/%s/change_form.html" % (app_label, opts.object_name.lower()), 443 443 "admin/%s/change_form.html" % app_label, 444 444 "admin/change_form.html" 445 ], context, context_instance= template.RequestContext(request))445 ], context, context_instance=AdminContext(request)) 446 446 447 447 def response_add(self, request, obj, post_url_continue='../%s/'): 448 448 """ … … 688 688 'admin/%s/%s/change_list.html' % (app_label, opts.object_name.lower()), 689 689 'admin/%s/change_list.html' % app_label, 690 690 'admin/change_list.html' 691 ], context, context_instance= template.RequestContext(request))691 ], context, context_instance=AdminContext(request)) 692 692 693 693 def delete_view(self, request, object_id, extra_context=None): 694 694 "The 'delete' admin view for this model." … … 743 743 "admin/%s/%s/delete_confirmation.html" % (app_label, opts.object_name.lower()), 744 744 "admin/%s/delete_confirmation.html" % app_label, 745 745 "admin/delete_confirmation.html" 746 ], context, context_instance= template.RequestContext(request))746 ], context, context_instance=AdminContext(request)) 747 747 748 748 def history_view(self, request, object_id, extra_context=None): 749 749 "The 'history' admin view for this model." … … 770 770 "admin/%s/%s/object_history.html" % (app_label, opts.object_name.lower()), 771 771 "admin/%s/object_history.html" % app_label, 772 772 "admin/object_history.html" 773 ], context, context_instance= template.RequestContext(request))773 ], context, context_instance=AdminContext(request)) 774 774 775 775 # 776 776 # DEPRECATED methods. -
django/contrib/admin/context.py
1 from django import template 2 from django.conf import settings 3 4 class AdminContext(template.RequestContext): 5 """RequestContext subclass that adds a few context variables 6 useful for admin. 7 8 The variables are 'user', 'messages' and 'perms' (internally, it 9 uses the auth context processor if it's not already in the settings). 10 """ 11 12 def __init__(self, request, dict=None, processors=None): 13 template.RequestContext.__init__(self, request, dict, processors) 14 15 if 'django.core.context_processors.auth' not in settings.TEMPLATE_CONTEXT_PROCESSORS: 16 from django.core import context_processors 17 self.update(context_processors.auth(request)) -
django/contrib/admin/views/template.py
1 1 from django import template, forms 2 from django.contrib.admin.context import AdminContext 2 3 from django.contrib.admin.views.decorators import staff_member_required 3 4 from django.template import loader 4 5 from django.shortcuts import render_to_response … … 28 29 return render_to_response('admin/template_validator.html', { 29 30 'title': 'Template validator', 30 31 'form': form, 31 }, context_instance= template.RequestContext(request))32 }, context_instance=AdminContext(request)) 32 33 template_validator = staff_member_required(template_validator) 33 34 34 35 -
django/contrib/admin/sites.py
1 1 import re 2 2 from django import http, template 3 3 from django.contrib.admin import ModelAdmin 4 from django.contrib.admin.context import AdminContext 4 5 from django.contrib.auth import authenticate, login 5 6 from django.db.models.base import ModelBase 6 7 from django.core.exceptions import ImproperlyConfigured … … 120 121 raise ImproperlyConfigured("Put 'django.contrib.admin' in your INSTALLED_APPS setting in order to use the admin application.") 121 122 if not ContentType._meta.installed: 122 123 raise ImproperlyConfigured("Put 'django.contrib.contenttypes' in your INSTALLED_APPS setting in order to use the admin application.") 123 if 'django.core.context_processors.auth' not in settings.TEMPLATE_CONTEXT_PROCESSORS:124 raise ImproperlyConfigured("Put 'django.core.context_processors.auth' in your TEMPLATE_CONTEXT_PROCESSORS setting in order to use the admin application.")125 124 126 125 def admin_view(self, view): 127 126 """ … … 331 330 } 332 331 context.update(extra_context or {}) 333 332 return render_to_response(self.index_template or 'admin/index.html', context, 334 context_instance= template.RequestContext(request)333 context_instance=AdminContext(request) 335 334 ) 336 335 index = never_cache(index) 337 336 … … 345 344 } 346 345 context.update(extra_context or {}) 347 346 return render_to_response(self.login_template or 'admin/login.html', context, 348 context_instance= template.RequestContext(request)347 context_instance=AdminContext(request) 349 348 ) 350 349 351 350 def app_index(self, request, app_label, extra_context=None): … … 391 390 } 392 391 context.update(extra_context or {}) 393 392 return render_to_response(self.app_index_template or 'admin/app_index.html', context, 394 context_instance= template.RequestContext(request)393 context_instance=AdminContext(request) 395 394 ) 396 395 397 396 def root(self, request, url):