fix display of license url, title and labels
parent
a285b94ddd
commit
75fab489f1
32
core/cc.py
32
core/cc.py
|
@ -3,20 +3,20 @@
|
|||
# let's be DRY with these parameters
|
||||
|
||||
INFO_CC = (
|
||||
('CC BY-NC-ND', 'by-nc-nd', 'Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported (CC BY-NC-ND 3.0)', 'http://creativecommons.org/licenses/by-nc-nd/3.0/'),
|
||||
('CC BY-NC-SA', 'by-nc-sa', 'Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)', 'http://creativecommons.org/licenses/by-nc-sa/3.0/'),
|
||||
('CC BY-NC', 'by-nc', 'Creative Commons Attribution-NonCommercial 3.0 Unported (CC BY-NC 3.0)', 'http://creativecommons.org/licenses/by-nc/3.0/'),
|
||||
('CC BY-ND', 'by-nd', 'Creative Commons Attribution-NoDerivs 3.0 Unported (CC BY-ND 3.0)', 'http://creativecommons.org/licenses/by-nd/3.0/'),
|
||||
('CC BY-SA', 'by-sa', 'Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)', 'http://creativecommons.org/licenses/by-sa/3.0/'),
|
||||
('CC BY', 'by', 'Creative Commons Attribution 3.0 Unported (CC BY 3.0)', 'http://creativecommons.org/licenses/by/3.0/'),
|
||||
('CC0', 'cc0', 'No Rights Reserved (CC0)', 'http://creativecommons.org/about/cc0'),
|
||||
('CC BY-NC-ND', 'by-nc-nd', 'Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported (CC BY-NC-ND 3.0)', 'http://creativecommons.org/licenses/by-nc-nd/3.0/', 'Creative Commons Attribution-NonCommercial-NoDerivs'),
|
||||
('CC BY-NC-SA', 'by-nc-sa', 'Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)', 'http://creativecommons.org/licenses/by-nc-sa/3.0/', 'Creative Commons Attribution-NonCommercial-ShareAlike'),
|
||||
('CC BY-NC', 'by-nc', 'Creative Commons Attribution-NonCommercial 3.0 Unported (CC BY-NC 3.0)', 'http://creativecommons.org/licenses/by-nc/3.0/', 'Creative Commons Attribution-NonCommercial'),
|
||||
('CC BY-ND', 'by-nd', 'Creative Commons Attribution-NoDerivs 3.0 Unported (CC BY-ND 3.0)', 'http://creativecommons.org/licenses/by-nd/3.0/','Creative Commons Attribution-NoDerivs'),
|
||||
('CC BY-SA', 'by-sa', 'Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)', 'http://creativecommons.org/licenses/by-sa/3.0/', 'Creative Commons Attribution-ShareAlike'),
|
||||
('CC BY', 'by', 'Creative Commons Attribution 3.0 Unported (CC BY 3.0)', 'http://creativecommons.org/licenses/by/3.0/', 'Creative Commons Attribution'),
|
||||
('CC0', 'cc0', 'No Rights Reserved (CC0)', 'http://creativecommons.org/about/cc0', 'No Rights Reserved (CC0)'),
|
||||
)
|
||||
INFO_FREE = INFO_CC + (
|
||||
('GFDL', 'gdfl', 'GNU Free Documentation License', 'http://www.gnu.org/licenses/fdl-1.3-standalone.html'),
|
||||
('LAL', 'lal', 'Licence Art Libre', 'http://artlibre.org/licence/lal/'),
|
||||
('GFDL', 'gdfl', 'GNU Free Documentation License', 'http://www.gnu.org/licenses/fdl-1.3-standalone.html', 'GNU Free Documentation License'),
|
||||
('LAL', 'lal', 'Licence Art Libre', 'http://artlibre.org/licence/lal/', 'Licence Art Libre'),
|
||||
)
|
||||
INFO_PD = (
|
||||
('PD-US', 'pd-us', 'Public Domain, US', 'http://creativecommons.org/about/pdm'),
|
||||
('PD-US', 'pd-us', 'Public Domain, US', 'http://creativecommons.org/about/pdm', 'Public Domain, US'),
|
||||
)
|
||||
INFO_ALL = INFO_FREE + INFO_PD
|
||||
# CCHOICES, CCGRANTS, and FORMATS are all used in places that expect tuples
|
||||
|
@ -107,12 +107,18 @@ class ccinfo():
|
|||
def url(self):
|
||||
return CCLicense.url(self.license)
|
||||
@property
|
||||
def title(self):
|
||||
if license in LICENSE_LIST_ALL:
|
||||
def full_title(self):
|
||||
if self.license in LICENSE_LIST_ALL:
|
||||
return INFO_ALL[LICENSE_LIST_ALL.index(self.license)][2]
|
||||
else:
|
||||
return self.license
|
||||
@property
|
||||
def title(self):
|
||||
if self.license in LICENSE_LIST_ALL:
|
||||
return INFO_ALL[LICENSE_LIST_ALL.index(self.license)][4]
|
||||
else:
|
||||
return self.license
|
||||
@property
|
||||
def is_cc(self):
|
||||
return self.license in LICENSE_LIST
|
||||
@property
|
||||
|
@ -120,7 +126,7 @@ class ccinfo():
|
|||
return self.license == 'PD-US'
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
return self.license
|
||||
|
||||
def license_value(facet):
|
||||
if facet in FACET_LIST:
|
||||
|
|
|
@ -24,6 +24,10 @@ class BaseFacet(object):
|
|||
def title(self):
|
||||
return self.__unicode__()
|
||||
|
||||
@property
|
||||
def label(self):
|
||||
return self.__unicode__()
|
||||
|
||||
def get_query_set(self):
|
||||
return self._get_query_set()
|
||||
|
||||
|
@ -102,13 +106,15 @@ class LicenseFacetGroup(FacetGroup):
|
|||
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))
|
||||
return self._get_query_set().filter(editions__ebooks__rights=self.license.license)
|
||||
def template(self):
|
||||
return 'facets/license.html'
|
||||
def context(self):
|
||||
return {
|
||||
'license': self.license,
|
||||
}
|
||||
def label(self):
|
||||
return self.license.__str__()
|
||||
def title(self):
|
||||
return self.license.title
|
||||
return LicenseFacet
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% with license=facet.context.license %}
|
||||
<div>
|
||||
<p><a href="{{license.url}}"><img src="{{license.badge}}" alt="badge for {{license}}" /></a> <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 free to read - they belong to all of us!{% else %}licensed ebooks are free to read - the people who created them want you to read and share them.{% endif %}</span></p>
|
||||
<p><a href="{{license.url}}"><img src="{{license.badge}}" alt="badge for {{license}}" /></a> <span class="user-short-info">These {% if license %}<a href="{{license.url}}">{{ license.title }}</a>{% endif %} {%if license.is_pd %}ebooks are free to read - they belong to all of us!{% else %}licensed ebooks are free to read - the people who created them want you to read and share them.{% endif %}</span></p>
|
||||
<p>{{license.description}}</p>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<ul class="menu level2">
|
||||
<li class="first"><span>{{ group.title }} is ...</span></li>
|
||||
{% for facet in group.get_facets %}
|
||||
<li><a href="{% url faceted_list path %}{{facet.facet_name}}/"><span>{{ facet.title }}</span></a></li>
|
||||
<li><a href="{% url faceted_list path %}{{facet.facet_name}}/" title="{{ facet.title }}"><span>{{ facet.label }}</span></a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endfor %}
|
||||
|
|
Loading…
Reference in New Issue