from django.core.management.base import BaseCommand
from ... import models

class Command(BaseCommand):
    '''Undelete all documents'''
    help = 'Undelete all documents'

    def handle(self, *args, **options):
        count = models.Mailbox.objects.filter(deleted=True).count()
        models.Mailbox.objects.update(deleted=False)
        models.DeletedMailbox.objects.all().delete()
        print "Undeleted %d documents." % count
