new management command to check for editions without attached works

pull/1/head
eric 2012-01-30 12:52:28 -05:00
parent 9ac7dad3f8
commit 052e523f22
1 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,18 @@
# if there's an edition without a work, something went wrong.
from django.core.management.base import BaseCommand
from regluit.core import models
class Command(BaseCommand):
help = "removes editions with no connected works"
def handle(self, **options):
numeditions=0
deleted=0
for edition in models.Edition.objects.all():
if not edition.work:
edition.delete()
deleted=deleted+1
numeditions=numeditions+1
print "%s deleted from %s total" % (deleted, numeditions)