Merge branch 'ry'

pull/1/head
Raymond Yee 2012-01-31 15:21:51 -08:00
commit 6920db2440
1 changed files with 4 additions and 5 deletions

View File

@ -201,9 +201,11 @@ class WorkListView(ListView):
def get_queryset(self): def get_queryset(self):
facet = self.kwargs['facet'] facet = self.kwargs['facet']
if (facet == 'popular'): 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'): elif (facet == 'recommended'):
return models.Work.objects.filter(wishlists__user=recommended_user) 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: else:
return models.Work.objects.all().order_by('-created') return models.Work.objects.all().order_by('-created')
@ -839,8 +841,7 @@ def wishlist(request):
googlebooks_id = request.POST.get('googlebooks_id', None) googlebooks_id = request.POST.get('googlebooks_id', None)
remove_work_id = request.POST.get('remove_work_id', None) remove_work_id = request.POST.get('remove_work_id', None)
add_work_id = request.POST.get('add_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: if googlebooks_id:
try: try:
edition = bookloader.add_by_googlebooks_id(googlebooks_id) edition = bookloader.add_by_googlebooks_id(googlebooks_id)
@ -854,8 +855,6 @@ def wishlist(request):
logger.warning("Error in wishlist adding %s" % (e)) logger.warning("Error in wishlist adding %s" % (e))
# TODO: redirect to work page, when it exists # TODO: redirect to work page, when it exists
return HttpResponseRedirect('/') return HttpResponseRedirect('/')
return HttpResponseRedirect('/')
elif remove_work_id: elif remove_work_id:
work = models.Work.objects.get(id=int(remove_work_id)) work = models.Work.objects.get(id=int(remove_work_id))
request.user.wishlist.remove_work(work) request.user.wishlist.remove_work(work)