fixed work_view tabbing

pull/1/head
eric 2012-02-29 13:15:38 -05:00
parent 5ce023d322
commit 094f4e56ee
2 changed files with 67 additions and 28 deletions

View File

@ -52,10 +52,10 @@
<div id="js-maincol-fr">
<div class="js-maincol-inner">
<div id="content-block">
<div class="content-block-heading ungluing" id="tabs">
<div class="content-block-heading wantto" id="tabs">
<ul class="tabs">
<li class="tabs1"><a href="#">Unglued</a></li>
<li class="tabs2 active"><a href="#">Active</a></li>
<li class="tabs2"><a href="#">Active</a></li>
<li class="tabs3"><a href="#">Unglue It!</a></li>
</ul>
<div class="badges listspage">
@ -82,20 +82,59 @@
{% ifequal work_list.count 0 %}
There aren't any works in this list yet. Why not add your favorite books to your wishlist, so we can feature them here?
{% else %}
{% paginate 20 work_list %}
{% for work in work_list %}
<div class="{% cycle 'row1' 'row2' %}">
{% with work.last_campaign_status as status %}
{% with work.last_campaign.deadline as deadline %}
{% with work.googlebooks_id as googlebooks_id %}
{% include "book_panel.html" %}
{% endwith %}{% endwith %}{% endwith %}
</div>
{% endfor %}
<br>
<div class="pagination content-block-heading">
{% show_pages %}
</div>
{% lazy_paginate 20 works_unglued using "works_unglued" %}
{% for work in works_unglued %}
<div class="{% cycle 'row1' 'row2' %}">
{% with work.last_campaign_status as status %}
{% with work.last_campaign.deadline as deadline %}
{% with work.googlebooks_id as googlebooks_id %}
{% include "book_panel.html" %}
{% endwith %}{% endwith %}{% endwith %}
</div>
{% endfor %}
<br>
<div class="pagination content-block-heading tabs-1">
{% get_pages %}
{% for page in pages %}
<a href="{{ page.path }}#1">{{ page.number }}</a>
{% endfor %}
</div>
{% lazy_paginate 20 works_active using "works_active" %}
{% for work in works_active %}
<div class="{% cycle 'row1' 'row2' %}">
{% with work.last_campaign_status as status %}
{% with work.last_campaign.deadline as deadline %}
{% with work.googlebooks_id as googlebooks_id %}
{% include "book_panel.html" %}
{% endwith %}{% endwith %}{% endwith %}
</div>
{% endfor %}
<br>
<div class="pagination content-block-heading tabs-2">
{% get_pages %}
{% for page in pages %}
<a href="{{ page.path }}#2">{{ page.number }}</a>
{% endfor %}
</div>
{% lazy_paginate 20 works_wished using "works_wished" %}
{% for work in works_wished %}
<div class="{% cycle 'row1' 'row2' %}">
{% with work.last_campaign_status as status %}
{% with work.last_campaign.deadline as deadline %}
{% with work.googlebooks_id as googlebooks_id %}
{% include "book_panel.html" %}
{% endwith %}{% endwith %}{% endwith %}
</div>
{% endfor %}
<br>
<div class="pagination content-block-heading tabs-3">
{% get_pages %}
{% for page in pages %}
<a href="{{ page.path }}#3">{{ page.number }}</a>
{% endfor %}
</div>
{% endifequal %}
</div>
</div>

View File

@ -221,14 +221,6 @@ class WorkListView(ListView):
template_name = "work_list.html"
context_object_name = "work_list"
def work_set_counts(self,work_set):
counts={}
# counts['unglued'] = work_set.annotate(ebook_count=Count('editions__ebooks')).filter(ebook_count__gt=0).count()
counts['unglued'] = work_set.filter(editions__ebooks__isnull=False).distinct().count()
counts['unglueing'] = work_set.filter(campaigns__status='ACTIVE').count()
counts['wished'] = work_set.count() - counts['unglued'] - counts['unglueing']
return counts
def get_queryset(self):
facet = self.kwargs['facet']
if (facet == 'popular'):
@ -243,9 +235,17 @@ class WorkListView(ListView):
def get_context_data(self, **kwargs):
context = super(WorkListView, self).get_context_data(**kwargs)
qs=self.get_queryset()
context['counts'] = self.work_set_counts(qs)
context['ungluers'] = userlists.work_list_users(qs,5)
context['facet'] =self.kwargs['facet']
context['works_unglued'] = qs.filter(editions__ebooks__isnull=False).distinct()
context['works_active'] = qs.filter(campaigns__status='ACTIVE',editions__ebooks__isnull=True)
context['works_wished'] = qs.exclude(editions__ebooks__isnull=False,campaigns__status='ACTIVE')
counts={}
counts['unglued'] = context['works_unglued'].count()
counts['unglueing'] = context['works_active'].count()
counts['wished'] = context['works_wished'].count()
context['counts'] = counts
return context
class UngluedListView(ListView):
@ -744,9 +744,9 @@ def supporter(request, supporter_username, template_name):
supporter = get_object_or_404(User, username=supporter_username)
wishlist = supporter.wishlist
# querysets for tabs
# unglued tab is anything with an existing ebook
## .order_by() may clash with .distinct() and this should be fixed
# querysets for tabs
# unglued tab is anything with an existing ebook
## .order_by() may clash with .distinct() and this should be fixed
works_unglued = wishlist.works.all().filter(editions__ebooks__isnull=False).distinct().order_by('-num_wishes')
# take the set complement of the unglued tab and filter it for active works to get middle tab