Still building initial conversions

This commit is contained in:
= 2019-09-02 02:03:23 -05:00
parent cea56d2868
commit 3cfd9840e8
Signed by: kiichan
GPG key ID: 619DFD67F0976616
23 changed files with 2925 additions and 21 deletions

View file

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals

View file

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
from datetime import timedelta
from django.conf import settings
from django.core.management.base import BaseCommand
from django.utils.timezone import now
from sqrl.models import SQRLNut
class Command(BaseCommand):
help = ('Clears expired SQRL nuts. '
'This command should be used as a cron job. '
'The recommended execution frequency is 5 minutes '
'which will result in longest nut lifespan of 10 minutes.')
def handle(self, *args, **options):
ttl = getattr(settings, 'SQRL', {}).get('TTL', 60 * 5) # 5 minutes
delete_before = now() + timedelta(seconds=-ttl)
SQRLNut.objects.filter(timestamp__lt=delete_before).delete()