mirror of
https://github.com/jazzband/django-axes.git
synced 2026-04-10 18:21:01 +00:00
20 lines
462 B
Python
20 lines
462 B
Python
from axes.models import AccessAttempt
|
|
|
|
|
|
def reset(ip=None, username=None):
|
|
"""Reset records that match ip or username, and
|
|
return the count of removed attempts.
|
|
"""
|
|
count = 0
|
|
|
|
attempts = AccessAttempt.objects.all()
|
|
if ip:
|
|
attempts = attempts.filter(ip_address=ip)
|
|
if username:
|
|
attempts = attempts.filter(username=username)
|
|
|
|
if attempts:
|
|
count = attempts.count()
|
|
attempts.delete()
|
|
|
|
return count
|