diff --git a/axes/admin.py b/axes/admin.py index 92a03ca..877ab75 100644 --- a/axes/admin.py +++ b/axes/admin.py @@ -56,9 +56,7 @@ class AccessAttemptAdmin(admin.ModelAdmin): return False def expiration(self, obj: AccessAttempt): - if hasattr(obj, "expiration") and obj.expiration.expires_at: - return obj.expiration.expires_at - return _("Not set") + return obj.expiration.expires_at if hasattr(obj, "expiration") else _("Not set") class AccessLogAdmin(admin.ModelAdmin): list_display = ( diff --git a/axes/handlers/database.py b/axes/handlers/database.py index cd2ca77..6f53a5a 100644 --- a/axes/handlers/database.py +++ b/axes/handlers/database.py @@ -400,7 +400,7 @@ class AxesDatabaseHandler(AbstractAxesHandler, AxesBaseHandler): if settings.AXES_USE_ATTEMPT_EXPIRATION: threshold = timezone.now() - count, _ = AccessAttempt.objects.filter(expiration__expires_at__lt=threshold).delete() + count, _ = AccessAttempt.objects.filter(expiration__expires_at__lte=threshold).delete() log.info( "AXES: Cleaned up %s expired access attempts from database that expiry were older than %s", count, @@ -408,7 +408,7 @@ class AxesDatabaseHandler(AbstractAxesHandler, AxesBaseHandler): ) else: threshold = get_cool_off_threshold(request) - count, _ = AccessAttempt.objects.filter(attempt_time__lt=threshold).delete() + count, _ = AccessAttempt.objects.filter(attempt_time__lte=threshold).delete() log.info( "AXES: Cleaned up %s expired access attempts from database that were older than %s", count, diff --git a/axes/migrations/0010_accessattemptexpiration.py b/axes/migrations/0010_accessattemptexpiration.py index ef7e5a6..74b3689 100644 --- a/axes/migrations/0010_accessattemptexpiration.py +++ b/axes/migrations/0010_accessattemptexpiration.py @@ -1,4 +1,4 @@ -# Generated by Django 5.2.1 on 2025-06-08 12:44 +# Generated by Django 5.2.1 on 2025-06-10 20:21 import django.db.models.deletion from django.db import migrations, models @@ -28,9 +28,7 @@ class Migration(migrations.Migration): ( "expires_at", models.DateTimeField( - blank=True, help_text="The time when access attempt expires and is no longer valid.", - null=True, verbose_name="Expires At", ), ), diff --git a/axes/models.py b/axes/models.py index 3c51c6e..5658cab 100644 --- a/axes/models.py +++ b/axes/models.py @@ -61,8 +61,6 @@ class AccessAttemptExpiration(models.Model): ) expires_at = models.DateTimeField( _("Expires At"), - null=True, - blank=True, help_text=_("The time when access attempt expires and is no longer valid."), )