Update web/core/views.py
This commit is contained in:
parent
d94f87ba12
commit
44f25bdc70
@ -12,6 +12,7 @@ from django.views.decorators.http import require_http_methods
|
|||||||
from django.utils.text import Truncator
|
from django.utils.text import Truncator
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.views.decorators.cache import never_cache
|
from django.views.decorators.cache import never_cache
|
||||||
|
from django.views.decorators.http import require_POST
|
||||||
|
|
||||||
from .forms import ImportForm, EntryForm
|
from .forms import ImportForm, EntryForm
|
||||||
from .models import Entry
|
from .models import Entry
|
||||||
@ -1018,3 +1019,15 @@ def login_attempts(request):
|
|||||||
cutoff = timezone.now() - timedelta(days=7)
|
cutoff = timezone.now() - timedelta(days=7)
|
||||||
attempts = LoginAttempt.objects.filter(timestamp__gte=cutoff).order_by("-timestamp")
|
attempts = LoginAttempt.objects.filter(timestamp__gte=cutoff).order_by("-timestamp")
|
||||||
return render(request, "tools/login_attempts.html", {"attempts": attempts})
|
return render(request, "tools/login_attempts.html", {"attempts": attempts})
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@require_POST
|
||||||
|
def clear_history(request):
|
||||||
|
"""
|
||||||
|
Clear recent searches + recently viewed entries for the CURRENT user.
|
||||||
|
Keys are specific to your app: recent_searches, recent_entries.
|
||||||
|
"""
|
||||||
|
for k in ["recent_searches", "recent_entries"]:
|
||||||
|
request.session.pop(k, None)
|
||||||
|
request.session.modified = True
|
||||||
|
return JsonResponse({"ok": True})
|
||||||
Loading…
Reference in New Issue
Block a user