      Decorator for views that checks that the user is logged in and is a staff
      member, displaying the login page if necessary.
      """
      def _checklogin(request, *args, **kwargs):
          if request.user.is_authenticated() and request.user.is_staff:
              # The user is valid. Continue to the admin page.
              return view_func(request, *args, **kwargs)
  
          assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'."
  
 
</s> remove         if not (request.user.is_authenticated() and request.user.has_perm('polls.can_vote')):
 </s> add         if not request.user.has_perm('polls.can_vote'): </s> remove         if request.method == 'HEAD' and (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS or (request.user.is_authenticated() and request.user.is_staff)):
 </s> add         if request.method == 'HEAD' and (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS or request.user.is_staff): </s> remove         return request.user.is_authenticated() and request.user.is_staff
 </s> add         return request.user.is_staff
        if request.user.is_staff:
      Decorator for views that checks that the user is logged in and is a staff
      member, displaying the login page if necessary.
      """
      def _checklogin(request, *args, **kwargs):
        if request.user.is_staff:
              # The user is valid. Continue to the admin page.
              return view_func(request, *args, **kwargs)
  
          assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'."
  
keep keep keep keep replace keep keep keep keep keep
 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 
django/contrib/admin/views/decorators.py