| 1 |
from django.core.management.base import BaseCommand |
| 2 |
|
| 3 |
from axes.handlers.proxy import AxesProxyHandler |
| 4 |
|
| 5 |
|
| 6 |
class Command(BaseCommand): |
| 7 |
help = "Reset access failure log records older than given days." |
| 8 |
|
| 9 |
def add_arguments(self, parser): |
| 10 |
parser.add_argument( |
| 11 |
"--age", |
| 12 |
type=int, |
| 13 |
default=30, |
| 14 |
help="Maximum age for records to keep in days", |
| 15 |
) |
| 16 |
|
| 17 |
def handle(self, *args, **options): |
| 18 |
count = AxesProxyHandler.reset_failure_logs(age_days=options["age"]) |
| 19 |
if count: |
| 20 |
self.stdout.write(f"{count} logs removed.") |
| 21 |
else: |
| 22 |
self.stdout.write("No logs found.") |