Merge branch 'ry'

pull/1/head
Raymond Yee 2012-01-31 14:26:45 -08:00
commit 9eb40c36ec
2 changed files with 10 additions and 1 deletions

View File

@ -11,6 +11,9 @@ class Command(BaseCommand):
for w in models.Work.objects.filter(identifiers__isnull=True).order_by('-created')[0:20]:
print "id: %d | title: %s | created: %s" % (w.id, w.title, w.created)
# models.Work.objects.filter(identifiers__isnull=True).filter(editions__isnull=False)[0].identifiers.all()
print "Number of editions that are currently tied to Works w/o identifiers ", \
models.Edition.objects.filter(work__identifiers__isnull=True).count()
print "Number of Identifiers not tied to Works (should be 0): ", \
models.Identifier.objects.filter(work__isnull=True).count()
print "Number of Editions not tied to a Work (should be 0): ", models.Edition.objects.filter(work__isnull=True).count()

View File

@ -839,6 +839,8 @@ def wishlist(request):
googlebooks_id = request.POST.get('googlebooks_id', None)
remove_work_id = request.POST.get('remove_work_id', None)
add_work_id = request.POST.get('add_work_id', None)
logger.info("about to print again...")
logger.info("googlebooks_id %s, remove_work_id %s, add_work_id %s " %( googlebooks_id, remove_work_id, add_work_id))
if googlebooks_id:
try:
edition = bookloader.add_by_googlebooks_id(googlebooks_id)
@ -848,8 +850,12 @@ def wishlist(request):
request.user.wishlist.add_work(edition.work,'user')
except bookloader.LookupFailure:
logger.warning("failed to load googlebooks_id %s" % googlebooks_id)
except Exception, e:
logger.warning("Error in wishlist adding %s" % (e))
# TODO: redirect to work page, when it exists
return HttpResponseRedirect('/')
return HttpResponseRedirect('/')
elif remove_work_id:
work = models.Work.objects.get(id=int(remove_work_id))
request.user.wishlist.remove_work(work)