Ejemplo n.º 1
0
 def process_request(self, request):
     if request.user.is_authenticated() and offline.is_enabled() \
         and not request.user.is_staff:
         return offline_view(request)
     elif not (hasattr(request, 'user')
               and request.user.is_authenticated()) \
         and offline.is_enabled():
         return offline_view(request)
     return
Ejemplo n.º 2
0
 def process_request(self, request):
     if request.path.startswith('/admin'):
         return
     if request.user.is_authenticated() and offline.is_enabled() \
         and not request.user.is_superuser:
         return offline_view(request)
     elif not (hasattr(request, 'user')
               and request.user.is_authenticated()) \
         and offline.is_enabled():
         return offline_view(request)
     return
Ejemplo n.º 3
0
 def process_response(self, request, response):
     if hasattr(request, 'user') and offline.is_enabled() \
         and request.user.is_superuser \
         and self.is_html_response(response):
         template = get_template('admin_notification.html')
         warning_message = template.render(Context())
         response.content = re.sub(r'<body.*>', '\g<0>'
                 + warning_message, response.content.decode('utf-8'))
     return response
Ejemplo n.º 4
0
    def process_request(self, request):
        # Admin and static always go through
        if request.path.startswith('/admin') or request.path.startswith(
                '/static'):
            return
        # If offline isn't enabled, pass through
        if not offline.is_enabled():
            return

        # Offline is enabled; double-check for staff users
        if not (hasattr(request, 'user')) or not request.user.is_authenticated(
        ) or not (request.user.is_staff and request.user.is_superuser):
            return offline_view(request)

        return