2012-02-02 14:05:22 +00:00
|
|
|
"""
|
|
|
|
To avoid continually hitting google, a failed isbn lookup from add_related creates a work and on edition with language = "xx"
|
|
|
|
this command goes through all these editions and checks them in google books
|
|
|
|
"""
|
|
|
|
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from regluit.core import models, bookloader
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
help = "relookup all editions attached to language=xx works"
|
2012-08-03 00:44:08 +00:00
|
|
|
args = "<title>"
|
2012-02-02 14:05:22 +00:00
|
|
|
|
2012-08-03 00:44:08 +00:00
|
|
|
def handle(self, title='', **options):
|
|
|
|
print "Number of Works with language=xx, title like %s: %s" % (title, models.Work.objects.filter(language='xx', title__istartswith=title).count())
|
2012-02-02 14:05:22 +00:00
|
|
|
updated_num=0
|
|
|
|
|
2012-08-03 00:44:08 +00:00
|
|
|
for work in models.Work.objects.filter(language='xx', title__istartswith=title):
|
2012-02-02 14:05:22 +00:00
|
|
|
print "updating work %s" % work
|
|
|
|
for edition in work.editions.all():
|
|
|
|
print "updating edition %s" % edition
|
|
|
|
updated = bookloader.update_edition(edition)
|
|
|
|
if updated.work.language!= 'xx':
|
|
|
|
updated_num+=1
|
|
|
|
print "Number of updated editions= %s" % updated_num
|