wired license facet block

pull/1/head
eric 2014-12-01 16:07:41 -05:00
parent 2264926301
commit 7913b7e38c
3 changed files with 26 additions and 3 deletions

View File

@ -85,7 +85,8 @@ def description(license):
class ccinfo():
def __init__(self, license):
self.license=license
value=licence_value(license)
self.license=value if value else license
@property
def description(self):
@ -99,15 +100,18 @@ class ccinfo():
@property
def title(self):
if license in LICENSE_LIST_ALL:
return INFO_ALL[LICENSE_LIST_ALL.index(license)][2]
return INFO_ALL[LICENSE_LIST_ALL.index(self.license)][2]
else:
return ''
return self.license
@property
def is_cc(self):
return self.license in LICENSE_LIST
@property
def is_pd(self):
return self.license == 'PD-US'
def __str__(self):
return self.title
def licence_value(facet):
if facet in FACET_LIST:

View File

@ -76,8 +76,15 @@ class LicenseFacetGroup(FacetGroup):
class LicenseFacet(NamedFacet):
def set_name(self):
self.facet_name=facet_name
self.license = cc.ccinfo(facet_name)
def get_query_set(self):
return self._get_query_set().filter(editions__ebooks__rights=cc.licence_value(self.facet_name))
def template(self):
return 'facets/license.html'
def context(self):
return {
'license': self.license,
}
return LicenseFacet
facet_groups = [ FormatFacetGroup() , LicenseFacetGroup() ]

View File

@ -0,0 +1,12 @@
{% with license=facet.context.license %}
<dl>
<dt>
Licence: {{ license.title }}
</dt>
<dd>
<p style="font-size: larger;"><span class="user-short-info">These {% if license.is_cc %}<a href="http://creativecommons.org/">Creative Commons</a>{% endif %} {% if license %}<a href="{{cc.url}}">{{ license }}</a>{% endif %} {%if license.is_pd %}ebooks are ready to read - they belong to all of us!{% else %}licensed ebooks are ready to read - the people who created them want you to read and share them.{% endif %}</span></p>
{% if license %}<p style="font-size: smaller;"><a href="{{license.url}}"><img src="{{license.badge}}" alt="badge for {{license}}" style="float:left;padding:0.5em" /></a> {{license.description}}
</p>{% endif %}
</dd>
</dl>
{% endwith %}