Skip to content

Commit 933b9e8

Browse files
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
1 parent 8a109a7 commit 933b9e8

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

django/contrib/admin/sites.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def has_permission(self, request):
139139
Returns True if the given HttpRequest has permission to view
140140
*at least one* page in the admin site.
141141
"""
142-
return request.user.is_authenticated() and request.user.is_staff
142+
return request.user.is_staff
143143

144144
def check_dependencies(self):
145145
"""

django/contrib/admin/templates/admin/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<div id="branding">
2323
{% block branding %}{% endblock %}
2424
</div>
25-
{% if user.is_authenticated and user.is_staff %}
25+
{% if user.is_staff %}
2626
<div id="user-tools">
2727
{% trans 'Welcome,' %}
2828
<strong>{% firstof user.first_name user.username %}</strong>.

django/contrib/admin/views/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def staff_member_required(view_func):
2828
member, displaying the login page if necessary.
2929
"""
3030
def _checklogin(request, *args, **kwargs):
31-
if request.user.is_authenticated() and request.user.is_staff:
31+
if request.user.is_staff:
3232
# The user is valid. Continue to the admin page.
3333
return view_func(request, *args, **kwargs)
3434

django/middleware/doc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def process_view(self, request, view_func, view_args, view_kwargs):
1212
indicating the view function. This is used by the documentation module
1313
to lookup the view function for an arbitrary page.
1414
"""
15-
if request.method == 'HEAD' and (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS or (request.user.is_authenticated() and request.user.is_staff)):
15+
if request.method == 'HEAD' and (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS or request.user.is_staff):
1616
response = http.HttpResponse()
1717
response['X-View'] = "%s.%s" % (view_func.__module__, view_func.__name__)
1818
return response

docs/topics/auth.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ checks to make sure the user is logged in and has the permission
10311031
``polls.can_vote``::
10321032

10331033
def my_view(request):
1034-
if not (request.user.is_authenticated() and request.user.has_perm('polls.can_vote')):
1034+
if not request.user.has_perm('polls.can_vote'):
10351035
return HttpResponse("You can't vote in this poll.")
10361036
# ...
10371037

0 commit comments

Comments
 (0)