wired license facet block
parent
2264926301
commit
7913b7e38c
10
core/cc.py
10
core/cc.py
|
@ -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:
|
||||
|
|
|
@ -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() ]
|
||||
|
|
|
@ -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 %}
|
Loading…
Reference in New Issue