gremmie@1: """ gremmie@1: purge_messages is a custom manage.py command for the messages application. gremmie@1: It is intended to be called from a cron job to purge messages that have been gremmie@1: deleted by both sender and receiver. gremmie@1: """ gremmie@1: gremmie@1: from django.core.management.base import NoArgsCommand gremmie@1: gremmie@1: from messages.models import Message gremmie@1: gremmie@1: gremmie@1: class Command(NoArgsCommand): gremmie@1: help = "Delete messages that have been sent to the trash by both sender and receiver." gremmie@1: gremmie@1: def handle_noargs(self, **options): gremmie@1: Message.objects.filter(sender_delete_date__isnull=False, gremmie@1: receiver_delete_date__isnull=False).delete() gremmie@1: gremmie@1: gremmie@1: # vim: ts=4 sw=4