add license-specific view to CC display

pull/1/head
eric 2014-05-08 10:22:35 -04:00
parent de6b8555d1
commit d102854d02
6 changed files with 37 additions and 8 deletions

View File

@ -29,7 +29,7 @@
<div id="user-block1">
<div id="block-intro-text"><span class="special-user-name">Ready to Read</span></div>
</div>
<div class="user-block2"><span class="user-short-info">These {% if pub_lang %}{{ pub_lang|ez_lang_name }} language {% endif %}<a href="http://creativecommons.org/">Creative Commons</a> licensed ebooks are ready to read - the people who created them want you to read and share them.</span>
<div class="user-block24"><span class="user-short-info">These {% if pub_lang %}{{ pub_lang|ez_lang_name }} language {% endif %}<a href="http://creativecommons.org/">Creative Commons</a> {{ license }} licensed ebooks are ready to read - the people who created them want you to read and share them.</span>
</div>
<div class="user-block3">
</div>
@ -72,7 +72,7 @@
<div id="content-block-content">
<div id="books-go-here">
{% ifequal work_list.count 0 %}
There aren't any {{ pub_lang|ez_lang_name }} works in this list. Why don't you add some?
There aren't any {{ pub_lang|ez_lang_name }} Creative Commons {{ license }} works in this list. Why don't you add some? Use the "More" tab on a work, there are links there for adding CC ebooks.
{% else %}
{% lazy_paginate 20 work_list using "work_list" %}
{% for work in work_list %}

View File

@ -24,6 +24,17 @@
<!--<li><a href="{% url work_list 'recommended' %}"><span>Noteworthy</span></a></li>-->
<li><a href="{% url unglued_list '' %}"><span>Ready to Read</span></a></li>
<li class="last"><a href="{% url cc_list%}">Latest Creative Commons</a></li>
{% ifequal aspect 'cc' %}
<ul class="menu level3">
<li class="first"><a href="{% url cc_list_detail 'by' %}"><span>CC BY</span></a></li>
<li><a href="{% url cc_list_detail 'by-nc-nd' %}"><span>CC BY-NC-ND</span></a></li>
<li><a href="{% url cc_list_detail 'by-nc-sa' %}"><span>CC BY-NC-SA</span></a></li>
<li><a href="{% url cc_list_detail 'by-nc' %}"><span>CC BY-NC</span></a></li>
<li><a href="{% url cc_list_detail 'by-sa' %}"><span>CC BY-SA</span></a></li>
<li><a href="{% url cc_list_detail 'by-nd' %}"><span>CC BY-ND</span></a></li>
<li><a href="{% url cc_list_detail 'cc0' %}"><span>CC0</span></a></li>
</ul>
{% endifequal %}
{% if pubname %}
<li>{{ pubname }}...
<ul class="menu level3">
@ -37,7 +48,7 @@
{% if show_langs %}
<li class="parent">
<span class="show_langs">Languages...</span>
<ul class="menu level2" id="lang_list">
<ul class="menu level3" id="lang_list">
<li class="first{% ifequal pub_lang '' %} active_lang{% endifequal %}"><a href="?">ALL</a></li>
{% for wished_lang in WISHED_LANGS %}
<li{% ifequal pub_lang wished_lang %} class="active_lang"{% endifequal %}><a href="?pub_lang={{wished_lang}}">{{wished_lang|ez_lang_name_local}}</a></li>

View File

@ -78,6 +78,7 @@ urlpatterns = patterns(
url(r"^bypub/(?P<facet>\w*)/(?P<pubname>.*)$", ByPubListView.as_view(), name='bypub_list'),
url(r"^unglued/(?P<facet>\w*)$", UngluedListView.as_view(), name='unglued_list'),
url(r"^creativecommons/$", CCListView.as_view(), name='cc_list'),
url(r"^creativecommons/(?P<facet>[\w\-]*)$", CCListView.as_view(), name='cc_list_detail'),
url(r"^goodreads/auth/$", "goodreads_auth", name="goodreads_auth"),
url(r"^goodreads/auth_cb/$", "goodreads_cb", name="goodreads_cb"),
url(r"^goodreads/flush/$","goodreads_flush_assoc", name="goodreads_flush_assoc"),

View File

@ -71,6 +71,7 @@ from regluit.core import (
goodreads,
ungluify_record
)
import regluit.core.cc as cc
from regluit.core.bookloader import merge_works, detach_edition
from regluit.core.goodreads import GoodreadsClient
from regluit.core.search import gluejar_search
@ -231,7 +232,7 @@ def home(request, landing=False):
cc_books = models.Work.objects.filter(
editions__ebooks__isnull=False,
editions__ebooks__rights__in=['CC BY', 'CC BY-NC-SA', 'CC BY-NC-ND', 'CC BY-NC', 'CC BY-ND', 'CC BY-SA']
editions__ebooks__rights__in=cc.LICENSE_LIST
).distinct().order_by('-created')[:4]
"""
@ -875,17 +876,30 @@ class ByPubListView(ByPubView):
class CCListView(FilterableListView):
template_name = "cc_list.html"
context_object_name = "work_list"
licenses = cc.LICENSE_LIST
facets = cc.FACET_LIST
def get_queryset_all(self):
return models.Work.objects.filter(
facet = self.kwargs.get('facet','')
if facet in self.facets:
return models.Work.objects.filter(
editions__ebooks__isnull=False,
editions__ebooks__rights__in=['CC BY', 'CC BY-NC-SA', 'CC BY-NC-ND', 'CC BY-NC', 'CC BY-ND', 'CC BY-SA']
editions__ebooks__rights=self.licenses[self.facets.index(facet)]
).distinct().order_by('-created')
else:
return models.Work.objects.filter( editions__ebooks__isnull=False,
editions__ebooks__rights__in=self.licenses
).distinct().order_by('-created')
def get_context_data(self, **kwargs):
context = super(CCListView, self).get_context_data(**kwargs)
facet = self.kwargs.get('facet','')
qs=self.get_queryset()
context['ungluers'] = userlists.work_list_users(qs,5)
context['activetab'] = "#1"
context['facet'] = facet
context['aspect'] = 'cc'
context['license'] = self.licenses[self.facets.index(facet)] if facet in self.facets else ''
return context
class UngluedListView(FilterableListView):
@ -900,7 +914,7 @@ class UngluedListView(FilterableListView):
# assumes all ebooks have a PD or CC license. compare rights_badge property
return models.Work.objects.filter(
editions__ebooks__isnull=False,
editions__ebooks__rights__in=['CC BY', 'CC BY-NC-SA', 'CC BY-NC-ND', 'CC BY-NC', 'CC BY-ND', 'CC BY-SA']
editions__ebooks__rights__in=cc.LICENSE_LIST
).exclude(campaigns__status="SUCCESSFUL").distinct().order_by('-num_wishes')
elif (facet == 'pd' or facet == 'publicdomain'):
return models.Work.objects.filter(

File diff suppressed because one or more lines are too long

View File

@ -621,6 +621,9 @@ a#readon {
.height(30px);
}
}
&.level3 li {
.utilitylinks(0px, 20px);
}
}
}