2 A management command which deletes expired service tickets (e.g.,
5 Calls ``ServiceTickets.objects.delete_expired_users()``, which
6 contains the actual logic for determining which accounts are deleted.
10 from django.core.management.base import NoArgsCommand
11 from django.core.management.base import CommandError
12 from django.conf import settings
16 from cas_provider.models import ServiceTicket
18 class Command(NoArgsCommand):
19 help = "Delete expired service tickets from the database"
21 def handle_noargs(self, **options):
22 tickets = ServiceTicket.objects.all()
23 for ticket in tickets:
24 expiration = datetime.timedelta(minutes=settings.CAS_TICKET_EXPIRATION)
25 if datetime.datetime.now() > ticket.created + expiration:
26 print "Deleting %s..." % ticket.ticket
29 print "%s not expired..." % ticket.ticket