Fixed #6991 -- Removed some redundant user.is_authenticated() calls in various places. Thanks, alexkoshelev, Liang Feng and Ivan Sagalaev
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12142 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
8a109a7bc8
commit
933b9e8de7
|
@ -139,7 +139,7 @@ class AdminSite(object):
|
||||||
Returns True if the given HttpRequest has permission to view
|
Returns True if the given HttpRequest has permission to view
|
||||||
*at least one* page in the admin site.
|
*at least one* page in the admin site.
|
||||||
"""
|
"""
|
||||||
return request.user.is_authenticated() and request.user.is_staff
|
return request.user.is_staff
|
||||||
|
|
||||||
def check_dependencies(self):
|
def check_dependencies(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<div id="branding">
|
<div id="branding">
|
||||||
{% block branding %}{% endblock %}
|
{% block branding %}{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
{% if user.is_authenticated and user.is_staff %}
|
{% if user.is_staff %}
|
||||||
<div id="user-tools">
|
<div id="user-tools">
|
||||||
{% trans 'Welcome,' %}
|
{% trans 'Welcome,' %}
|
||||||
<strong>{% firstof user.first_name user.username %}</strong>.
|
<strong>{% firstof user.first_name user.username %}</strong>.
|
||||||
|
|
|
@ -28,7 +28,7 @@ def staff_member_required(view_func):
|
||||||
member, displaying the login page if necessary.
|
member, displaying the login page if necessary.
|
||||||
"""
|
"""
|
||||||
def _checklogin(request, *args, **kwargs):
|
def _checklogin(request, *args, **kwargs):
|
||||||
if request.user.is_authenticated() and request.user.is_staff:
|
if request.user.is_staff:
|
||||||
# The user is valid. Continue to the admin page.
|
# The user is valid. Continue to the admin page.
|
||||||
return view_func(request, *args, **kwargs)
|
return view_func(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ class XViewMiddleware(object):
|
||||||
indicating the view function. This is used by the documentation module
|
indicating the view function. This is used by the documentation module
|
||||||
to lookup the view function for an arbitrary page.
|
to lookup the view function for an arbitrary page.
|
||||||
"""
|
"""
|
||||||
if request.method == 'HEAD' and (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS or (request.user.is_authenticated() and request.user.is_staff)):
|
if request.method == 'HEAD' and (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS or request.user.is_staff):
|
||||||
response = http.HttpResponse()
|
response = http.HttpResponse()
|
||||||
response['X-View'] = "%s.%s" % (view_func.__module__, view_func.__name__)
|
response['X-View'] = "%s.%s" % (view_func.__module__, view_func.__name__)
|
||||||
return response
|
return response
|
||||||
|
|
|
@ -1031,7 +1031,7 @@ checks to make sure the user is logged in and has the permission
|
||||||
``polls.can_vote``::
|
``polls.can_vote``::
|
||||||
|
|
||||||
def my_view(request):
|
def my_view(request):
|
||||||
if not (request.user.is_authenticated() and request.user.has_perm('polls.can_vote')):
|
if not request.user.has_perm('polls.can_vote'):
|
||||||
return HttpResponse("You can't vote in this poll.")
|
return HttpResponse("You can't vote in this poll.")
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue