Merge branch 'master' of github.com:Gluejar/regluit

pull/1/head
Andromeda Yelton 2012-02-01 12:41:34 -05:00
commit 8e4171d3ee
2 changed files with 10 additions and 2 deletions

View File

@ -10,7 +10,10 @@ class Command(BaseCommand):
print "Last 20 Works without identifiers: "
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

@ -201,9 +201,11 @@ class WorkListView(ListView):
def get_queryset(self):
facet = self.kwargs['facet']
if (facet == 'popular'):
return models.Work.objects.annotate(wished=Count('wishlists')).order_by('-wished')
return models.Work.objects.filter(wishlists__isnull=False).distinct().annotate(wished=Count('wishlists')).order_by('-wished')
elif (facet == 'recommended'):
return models.Work.objects.filter(wishlists__user=recommended_user)
elif (facet == 'new'):
return models.Work.objects.filter(wishlists__isnull=False).distinct().order_by('-created')
else:
return models.Work.objects.all().order_by('-created')
@ -839,6 +841,7 @@ 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)
if googlebooks_id:
try:
edition = bookloader.add_by_googlebooks_id(googlebooks_id)
@ -848,6 +851,8 @@ 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('/')
elif remove_work_id: