X-Git-Url: https://git.mdrn.pl/django-cas-provider.git/blobdiff_plain/cc61c5969227c2d49544997ebbf074541029400b..a9dc703609231521ed596e6ac9fa7cd746aa6fe1:/cas_provider/management/commands/cleanuptickets.py?ds=inline diff --git a/cas_provider/management/commands/cleanuptickets.py b/cas_provider/management/commands/cleanuptickets.py index 751e220..401bec1 100644 --- a/cas_provider/management/commands/cleanuptickets.py +++ b/cas_provider/management/commands/cleanuptickets.py @@ -8,18 +8,27 @@ contains the actual logic for determining which accounts are deleted. """ from django.core.management.base import NoArgsCommand -from django.core.management.base import CommandError from django.conf import settings import datetime -from cas_provider.models import ServiceTicket +from cas_provider.models import ServiceTicket, LoginTicket class Command(NoArgsCommand): help = "Delete expired service tickets from the database" def handle_noargs(self, **options): + print "Service tickets:" tickets = ServiceTicket.objects.all() + for ticket in tickets: + expiration = datetime.timedelta(minutes=settings.CAS_TICKET_EXPIRATION) + if datetime.datetime.now() > ticket.created + expiration: + print "Deleting %s..." % ticket.ticket + ticket.delete() + else: + print "%s not expired..." % ticket.ticket + tickets = LoginTicket.objects.all() + print "Login tickets:" for ticket in tickets: expiration = datetime.timedelta(minutes=settings.CAS_TICKET_EXPIRATION) if datetime.datetime.now() > ticket.created + expiration: