Changed contrib.admin.views.template and doc to use staff_member_required decorator. Refs #627

git-svn-id: http://code.djangoproject.com/svn/django/trunk@929 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-10-18 05:12:45 +00:00
parent 530f8d12b7
commit 15fb988dbc
2 changed files with 12 additions and 0 deletions

View File

@ -1,6 +1,7 @@
from django.core import meta from django.core import meta
from django import templatetags from django import templatetags
from django.conf import settings from django.conf import settings
from django.contrib.admin.views.decorators import staff_member_required
from django.models.core import sites from django.models.core import sites
from django.core.extensions import DjangoContext, render_to_response from django.core.extensions import DjangoContext, render_to_response
from django.core.exceptions import Http404, ViewDoesNotExist from django.core.exceptions import Http404, ViewDoesNotExist
@ -19,11 +20,13 @@ def doc_index(request):
if not doc: if not doc:
return missing_docutils_page(request) return missing_docutils_page(request)
return render_to_response('doc/index', context_instance=DjangoContext(request)) return render_to_response('doc/index', context_instance=DjangoContext(request))
doc_index = staff_member_required(doc_index)
def bookmarklets(request): def bookmarklets(request):
return render_to_response('doc/bookmarklets', { return render_to_response('doc/bookmarklets', {
'admin_url' : "%s://%s" % (os.environ.get('HTTPS') == 'on' and 'https' or 'http', request.META['HTTP_HOST']), 'admin_url' : "%s://%s" % (os.environ.get('HTTPS') == 'on' and 'https' or 'http', request.META['HTTP_HOST']),
}, context_instance=DjangoContext(request)) }, context_instance=DjangoContext(request))
bookmarklets = staff_member_required(bookmarklets)
def template_tag_index(request): def template_tag_index(request):
import sys import sys
@ -61,6 +64,7 @@ def template_tag_index(request):
template.registered_tags, template.registered_filters = saved_tagset template.registered_tags, template.registered_filters = saved_tagset
return render_to_response('doc/template_tag_index', {'tags': tags}, context_instance=DjangoContext(request)) return render_to_response('doc/template_tag_index', {'tags': tags}, context_instance=DjangoContext(request))
template_tag_index = staff_member_required(template_tag_index)
def template_filter_index(request): def template_filter_index(request):
if not doc: if not doc:
@ -93,6 +97,7 @@ def template_filter_index(request):
template.registered_tags, template.registered_filters = saved_tagset template.registered_tags, template.registered_filters = saved_tagset
return render_to_response('doc/template_filter_index', {'filters': filters}, context_instance=DjangoContext(request)) return render_to_response('doc/template_filter_index', {'filters': filters}, context_instance=DjangoContext(request))
template_filter_index = staff_member_required(template_filter_index)
def view_index(request): def view_index(request):
if not doc: if not doc:
@ -112,6 +117,7 @@ def view_index(request):
'url' : simplify_regex(regex), 'url' : simplify_regex(regex),
}) })
return render_to_response('doc/view_index', {'views': views}, context_instance=DjangoContext(request)) return render_to_response('doc/view_index', {'views': views}, context_instance=DjangoContext(request))
view_index = staff_member_required(view_index)
def view_detail(request, view): def view_detail(request, view):
if not doc: if not doc:
@ -135,6 +141,7 @@ def view_detail(request, view):
'body': body, 'body': body,
'meta': metadata, 'meta': metadata,
}, context_instance=DjangoContext(request)) }, context_instance=DjangoContext(request))
view_detail = staff_member_required(view_detail)
def model_index(request): def model_index(request):
if not doc: if not doc:
@ -150,6 +157,7 @@ def model_index(request):
'class' : opts.module_name, 'class' : opts.module_name,
}) })
return render_to_response('doc/model_index', {'models': models}, context_instance=DjangoContext(request)) return render_to_response('doc/model_index', {'models': models}, context_instance=DjangoContext(request))
model_index = staff_member_required(model_index)
def model_detail(request, model): def model_detail(request, model):
if not doc: if not doc:
@ -191,6 +199,7 @@ def model_detail(request, model):
'summary': "Fields on %s objects" % opts.verbose_name, 'summary': "Fields on %s objects" % opts.verbose_name,
'fields': fields, 'fields': fields,
}, context_instance=DjangoContext(request)) }, context_instance=DjangoContext(request))
model_detail = staff_member_required(model_detail)
def template_detail(request, template): def template_detail(request, template):
templates = [] templates = []
@ -210,6 +219,7 @@ def template_detail(request, template):
'name': template, 'name': template,
'templates': templates, 'templates': templates,
}, context_instance=DjangoContext(request)) }, context_instance=DjangoContext(request))
template_detail = staff_member_required(template_detail)
#################### ####################
# Helper functions # # Helper functions #

View File

@ -1,3 +1,4 @@
from django.contrib.admin.views.decorators import staff_member_required
from django.core import formfields, validators from django.core import formfields, validators
from django.core import template from django.core import template
from django.core.template import loader from django.core.template import loader
@ -26,6 +27,7 @@ def template_validator(request):
'title': 'Template validator', 'title': 'Template validator',
'form': formfields.FormWrapper(manipulator, new_data, errors), 'form': formfields.FormWrapper(manipulator, new_data, errors),
}, context_instance=DjangoContext(request)) }, context_instance=DjangoContext(request))
template_validator = staff_member_required(template_validator)
class TemplateValidator(formfields.Manipulator): class TemplateValidator(formfields.Manipulator):
def __init__(self, settings_modules): def __init__(self, settings_modules):