Author: adrian
Date: 2010-01-09 14:11:01 -0600 (Sat, 09 Jan 2010)
New Revision: 12142

Modified:
   django/trunk/django/contrib/admin/sites.py
   django/trunk/django/contrib/admin/templates/admin/base.html
   django/trunk/django/contrib/admin/views/decorators.py
   django/trunk/django/middleware/doc.py
   django/trunk/docs/topics/auth.txt
Log:
Fixed #6991 -- Removed some redundant user.is_authenticated() calls in various 
places. Thanks, alexkoshelev, Liang Feng and Ivan Sagalaev

Modified: django/trunk/django/contrib/admin/sites.py
===================================================================
--- django/trunk/django/contrib/admin/sites.py  2010-01-09 20:04:33 UTC (rev 
12141)
+++ django/trunk/django/contrib/admin/sites.py  2010-01-09 20:11:01 UTC (rev 
12142)
@@ -139,7 +139,7 @@
         Returns True if the given HttpRequest has permission to view
         *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):
         """

Modified: django/trunk/django/contrib/admin/templates/admin/base.html
===================================================================
--- django/trunk/django/contrib/admin/templates/admin/base.html 2010-01-09 
20:04:33 UTC (rev 12141)
+++ django/trunk/django/contrib/admin/templates/admin/base.html 2010-01-09 
20:11:01 UTC (rev 12142)
@@ -22,7 +22,7 @@
         <div id="branding">
         {% block branding %}{% endblock %}
         </div>
-        {% if user.is_authenticated and user.is_staff %}
+        {% if user.is_staff %}
         <div id="user-tools">
             {% trans 'Welcome,' %}
             <strong>{% firstof user.first_name user.username %}</strong>.

Modified: django/trunk/django/contrib/admin/views/decorators.py
===================================================================
--- django/trunk/django/contrib/admin/views/decorators.py       2010-01-09 
20:04:33 UTC (rev 12141)
+++ django/trunk/django/contrib/admin/views/decorators.py       2010-01-09 
20:11:01 UTC (rev 12142)
@@ -28,7 +28,7 @@
     member, displaying the login page if necessary.
     """
     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.
             return view_func(request, *args, **kwargs)
 

Modified: django/trunk/django/middleware/doc.py
===================================================================
--- django/trunk/django/middleware/doc.py       2010-01-09 20:04:33 UTC (rev 
12141)
+++ django/trunk/django/middleware/doc.py       2010-01-09 20:11:01 UTC (rev 
12142)
@@ -12,7 +12,7 @@
         indicating the view function.  This is used by the documentation module
         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['X-View'] = "%s.%s" % (view_func.__module__, 
view_func.__name__)
             return response

Modified: django/trunk/docs/topics/auth.txt
===================================================================
--- django/trunk/docs/topics/auth.txt   2010-01-09 20:04:33 UTC (rev 12141)
+++ django/trunk/docs/topics/auth.txt   2010-01-09 20:11:01 UTC (rev 12142)
@@ -1031,7 +1031,7 @@
 ``polls.can_vote``::
 
     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.")
         # ...
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.


Reply via email to