コード例 #1
0
ファイル: views.py プロジェクト: JacquesWhite/oioioi
def maintenance_view(request):
    # We don't want users to access maintenance site
    # when maintenance is disabled.
    if not is_maintenance_mode_enabled():
        return HttpResponseRedirect('/')
    maintenance_info = get_maintenance_mode()
    return render(request, 'maintenance.html',
                  {'message': maintenance_info['message']})
コード例 #2
0
def maintenance_view(request):
    # We don't want users to access maintenance site
    # when maintenance is disabled.
    if not is_maintenance_mode_enabled():
        return HttpResponseRedirect('/')
    maintenance_info = get_maintenance_mode()
    return render(request, 'maintenance.html',
                  {'message': maintenance_info['message']})
コード例 #3
0
    def process_request(self, request):
        if not is_maintenance_mode_enabled():
            return None

        # We want to allow admin access the site
        if hasattr(request, 'user'):
            if request.user.is_superuser:
                return None

        # If admin logged in as another user, the information who
        # the real user is is stored in real_user
        if hasattr(request, 'real_user'):
            if request.real_user.is_superuser:
                return None

        # Maybe we want to allow user access some links
        for url in settings.MAINTENANCE_MODE_IGNORE_URLS:
            if re.search(url, request.path_info):
                return None

        # We redirect users to the url specified in settings.
        return HttpResponseRedirect(settings.MAINTENANCE_MODE_REDIRECT_URL)
コード例 #4
0
ファイル: middleware.py プロジェクト: JacquesWhite/oioioi
    def _process_request(self, request):
        if not is_maintenance_mode_enabled():
            return None

        # We want to allow admin access the site
        if hasattr(request, 'user'):
            if request.user.is_superuser:
                return None

        # If admin logged in as another user, the information who
        # the real user is is stored in real_user
        if hasattr(request, 'real_user'):
            if request.real_user.is_superuser:
                return None

        # Maybe we want to allow user access some links
        for url in settings.MAINTENANCE_MODE_IGNORE_URLS:
            if re.search(url, request.path_info):
                return None

        # We redirect users to the url specified in settings.
        return HttpResponseRedirect(settings.MAINTENANCE_MODE_REDIRECT_URL)
コード例 #5
0
def is_maintenance_enabled():
    return is_maintenance_mode_enabled()
コード例 #6
0
def is_maintenance_enabled():
    return is_maintenance_mode_enabled()