2010-09-27 17:34:52 +00:00
|
|
|
from axes.models import AccessAttempt
|
|
|
|
|
|
2011-04-12 21:04:51 +00:00
|
|
|
|
2013-07-27 17:16:54 +00:00
|
|
|
def reset(ip=None, username=None):
|
|
|
|
|
"""Reset records that match ip or username, and
|
|
|
|
|
return the count of removed attempts.
|
|
|
|
|
"""
|
|
|
|
|
count = 0
|
2012-08-26 06:36:52 +00:00
|
|
|
|
2013-07-27 17:16:54 +00:00
|
|
|
attempts = AccessAttempt.objects.all()
|
2012-08-26 06:36:52 +00:00
|
|
|
if ip:
|
2013-07-27 17:16:54 +00:00
|
|
|
attempts = attempts.filter(ip_address=ip)
|
2012-08-26 06:36:52 +00:00
|
|
|
if username:
|
2013-07-27 17:16:54 +00:00
|
|
|
attempts = attempts.filter(username=username)
|
2012-08-26 06:36:52 +00:00
|
|
|
|
|
|
|
|
if attempts:
|
2013-07-27 17:16:54 +00:00
|
|
|
count = attempts.count()
|
2012-08-26 06:36:52 +00:00
|
|
|
attempts.delete()
|
2013-07-27 17:16:54 +00:00
|
|
|
|
|
|
|
|
return count
|