utils.py 462 B

1234567891011121314151617181920
  1. from axes.models import AccessAttempt
  2. def reset(ip=None, username=None):
  3. """Reset records that match ip or username, and
  4. return the count of removed attempts.
  5. """
  6. count = 0
  7. attempts = AccessAttempt.objects.all()
  8. if ip:
  9. attempts = attempts.filter(ip_address=ip)
  10. if username:
  11. attempts = attempts.filter(username=username)
  12. if attempts:
  13. count = attempts.count()
  14. attempts.delete()
  15. return count