Revised not to log the user visits when DEBUG is on in the development environment in the Mia core application.

This commit is contained in:
依瑪貓 2020-08-11 11:27:46 +08:00
parent 96e1bd2374
commit 9973fc851c

View File

@ -23,6 +23,7 @@ import ipaddress
import socket
from functools import wraps
from django.conf import settings
from django.db.models import F
from django.db.models.functions import Now
from django.http import HttpResponse, HttpRequest
@ -76,7 +77,8 @@ def login_required(function=None):
if "visit_logged" in request.session:
del request.session["visit_logged"]
return HttpResponse(status=401)
_log_visit(request)
if not settings.DEBUG:
_log_visit(request)
return view_func(request, *args, **kwargs)
return _wrapped_view
if function: