Merge pull request #133 from Gluejar/list_by_a_publisher

basic by-publisher list [#45617641]
pull/1/head
Raymond Yee 2013-03-06 08:37:18 -08:00
commit 8759dad546
5 changed files with 179 additions and 6 deletions

View File

@ -0,0 +1,138 @@
{% extends "base.html" %}
{% load endless %}
{% load lang_utils %}
{% block title %} Works published by {{ pubname }} {% endblock %}
{% block extra_css %}
<link type="text/css" rel="stylesheet" href="/static/css/supporter_layout.css" />
<link type="text/css" rel="stylesheet" href="/static/css/book_list.css" />
<link type="text/css" rel="stylesheet" href="/static/css/book_panel.css" />
<link type="text/css" rel="stylesheet" href="/static/css/lists.css" />
{% endblock %}
{% block extra_head %}
<script type="text/javascript" src="/static/js/wishlist.js"></script>
<script type="text/javascript" src="{{ jquery_home }}"></script>
<script type="text/javascript" src="/static/js/jquery.cookie.js"></script>
<script type="text/javascript" src="{{ jquery_ui_home }}"></script>
<script type="text/javascript" src="/static/js/greenpanel.js"></script>
<script type="text/javascript" src="/static/js/toggle.js"></script>
<script type="text/javascript" src="/static/js/tabs.js"></script>
{% endblock %}
{% block topsection %}
<div id="locationhash">{{ activetab }}</div>
<div id="js-topsection">
<div class="js-main">
<div class="js-topnews">
<div class="js-topnews1">
<div class="js-topnews2">
<div class="js-topnews3">
<div class="user-block">
<div id="user-block1">
<div id="block-intro-text"><span class="special-user-name">{{ facet|capfirst }}</span></div>
</div>
<div class="user-block2"><span class="special-user-name">Books from {{ pubname }} {% if pub_lang %}( {{pub_lang|ez_lang_name}} ) {% endif %}</span>
</div>
<div class="user-block3">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block content %}
<div id="main-container">
<div class="js-main">
<div id="js-leftcol">
{% include "explore.html" %}
</div>
<div id="js-maincol-fr">
<div class="js-maincol-inner">
<div id="content-block">
<div class="content-block-heading wantto" id="tabs">
<ul class="tabs">
<li class="tabs1"><a href="#">Unglued<br />({{ counts.unglued }})</a></li>
<li class="tabs2"><a href="#">Active<br />({{ counts.unglueing }})</a></li>
<li class="tabs3"><a href="#">Unglue It!<br />({{ counts.wished }})</a></li>
</ul>
<ul class="book-list-view">
<li>View As:</li>
<li class="view-list">
<a href="#" id="toggle-list">
<img src="/static/images/booklist/view-list.png" alt="view list" title="view list" height="21" width="24" />
</a>
</li>
<li class="view-list">
<a href="#" id="toggle-panel">
<img src="/static/images/booklist/view-icon.png" alt="view icon" title="view icon" height="22" width="22" />
</a>
</li>
</ul>
</div>
<div id="content-block-content">
{% ifequal work_list.count 0 %}
There aren't any {{ pub_lang|ez_lang_name }} works in this list yet. Why not add your favorite books to your wishlist, so we can feature them here?
{% else %}
{% 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 %}
<div class="pagination content-block-heading tabs-1">
{% get_pages %}
{% for page in pages %}
<a href="{{ page.path }}#1" class="endless_page_link">{{ 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 %}
<div class="pagination content-block-heading tabs-2">
{% get_pages %}
{% for page in pages %}
<a href="{{ page.path }}#2" class="endless_page_link">{{ 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 %}
<div class="pagination content-block-heading tabs-3">
{% get_pages %}
{% for page in pages %}
<a href="{{ page.path }}#3" class="endless_page_link">{{ page.number }}</a>
{% endfor %}
</div>
{% endifequal %}
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -20,6 +20,15 @@
<li><a href="{% url work_list 'new' %}"><span>Newly Wished</span></a></li>
<li><a href="{% url work_list 'recommended' %}"><span>Noteworthy</span></a></li>
<li class="last"><a href="{% url unglued_list '' %}"><span>Ready to Read</span></a></li>
{% if pubname %}
<li>{{ pubname }}...
<ul class="menu level3">
<li class="first"><a href="{% url bypub_list pubname 'popular' %}"><span>Most popular</span></a></li>
<li><a href="{% url bypub_list pubname %}"><span>By Title</span></a></li>
<li><a href="{% url bypub_list pubname 'pubdate' %}"><span>By Date Published</span></a></li>
</ul>
</li>
{% endif %}
</ul>
</li>
{% if show_langs %}

View File

@ -370,7 +370,7 @@ $j(document).ready(function(){
<img src="{{ edition.cover_image_small }}" title="edition cover" alt="edition cover" />
</div>
{% endif %}
<div class="metadata" id="edition_{{edition.id}}">{% if edition.publisher %}Publisher: {{edition.publisher}}<br />{% endif %}
<div class="metadata" id="edition_{{edition.id}}">{% if edition.publisher %}Publisher: <a href="{% url bypub_list edition.publisher %}">{{edition.publisher}}</a><br />{% endif %}
{% if edition.publication_date %}Published: {{edition.publication_date}}<br />{% endif %}
{% if edition.isbn_13 %}
ISBN: {{ edition.isbn_13 }}<br />

View File

@ -11,7 +11,7 @@ from regluit.core.feeds import SupporterWishlistFeed
from regluit.core.models import Campaign
from regluit.frontend.views import GoodreadsDisplayView, LibraryThingView, PledgeView, PledgeCompleteView, PledgeCancelView, PledgeRechargeView, FAQView
from regluit.frontend.views import CampaignListView, WorkListView, UngluedListView, InfoPageView, InfoLangView, DonationView, FundPledgeView
from regluit.frontend.views import NonprofitCampaign, DonationCredit, PledgeModifiedView, ManageAccount, MergeView
from regluit.frontend.views import NonprofitCampaign, DonationCredit, PledgeModifiedView, ManageAccount, MergeView, ByPubListView
urlpatterns = patterns(
"regluit.frontend.views",
@ -37,6 +37,8 @@ urlpatterns = patterns(
url(r"^wishlist/$", "wishlist", name="wishlist"),
url(r"^campaigns/(?P<facet>\w*)$", CampaignListView.as_view(), name='campaign_list'),
url(r"^lists/(?P<facet>\w*)$", WorkListView.as_view(), name='work_list'),
url(r"^bypub/(?P<pubname>[^/]*)/(?P<facet>\w*)$", ByPubListView.as_view(), name='bypub_list'),
url(r"^bypub/(?P<pubname>[^/]*)$", ByPubListView.as_view(), name='bypub_list'),
url(r"^unglued/(?P<facet>\w*)$", UngluedListView.as_view(), name='unglued_list'),
url(r"^goodreads/auth/$", "goodreads_auth", name="goodreads_auth"),
url(r"^goodreads/auth_cb/$", "goodreads_cb", name="goodreads_cb"),

View File

@ -484,6 +484,7 @@ recommended_user = User.objects.filter( username=settings.UNGLUEIT_RECOMMENDED_U
class WorkListView(FilterableListView):
template_name = "work_list.html"
context_object_name = "work_list"
max_works=20
def get_queryset_all(self):
facet = self.kwargs['facet']
@ -500,11 +501,11 @@ class WorkListView(FilterableListView):
context = super(WorkListView, self).get_context_data(**kwargs)
qs=self.get_queryset()
context['ungluers'] = userlists.work_list_users(qs,5)
context['facet'] = self.kwargs['facet']
context['facet'] = self.kwargs.get('facet','')
works_unglued = qs.filter(editions__ebooks__isnull=False).distinct() | qs.filter(campaigns__status='SUCCESSFUL').distinct()
context['works_unglued'] = works_unglued.order_by('-campaigns__status', 'campaigns__deadline', '-num_wishes')[:20]
context['works_active'] = qs.filter(campaigns__status='ACTIVE').distinct()[:20]
context['works_wished'] = qs.exclude(editions__ebooks__isnull=False).exclude(campaigns__status='ACTIVE').exclude(campaigns__status='SUCCESSFUL').distinct()[:20]
context['works_unglued'] = works_unglued.order_by('-campaigns__status', 'campaigns__deadline', '-num_wishes')[:self.max_works]
context['works_active'] = qs.filter(campaigns__status='ACTIVE').distinct()[:self.max_works]
context['works_wished'] = qs.exclude(editions__ebooks__isnull=False).exclude(campaigns__status='ACTIVE').exclude(campaigns__status='SUCCESSFUL').distinct()[:self.max_works]
context['activetab'] = "#3"
@ -516,6 +517,29 @@ class WorkListView(FilterableListView):
return context
class ByPubListView(WorkListView):
template_name = "bypub_list.html"
context_object_name = "work_list"
max_works=100
def get_queryset_all(self):
facet = self.kwargs.get('facet','')
pubname = self.kwargs['pubname']
objects = models.Work.objects.filter(editions__publisher__iexact=pubname).distinct()
if (facet == 'popular'):
return objects.order_by('-num_wishes', 'id')
elif (facet == 'pubdate'):
return objects.order_by('-editions__publication_date')
elif (facet == 'new'):
return objects.filter(num_wishes__gt=0).order_by('-created', '-num_wishes' ,'id')
else:
return objects.order_by('title', 'id')
def get_context_data(self, **kwargs):
context = super(ByPubListView, self).get_context_data(**kwargs)
context['pubname'] = self.kwargs['pubname']
return context
class UngluedListView(FilterableListView):
template_name = "unglued_list.html"
context_object_name = "work_list"