new management command to check for editions without attached works
parent
9ac7dad3f8
commit
052e523f22
|
@ -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)
|
Loading…
Reference in New Issue