keyword facets!

for example, /free/kw.Fiction/
pull/1/head
eric 2014-12-10 17:14:28 -05:00
parent b4130807a3
commit 8c9bccc1f0
2 changed files with 33 additions and 1 deletions

View File

@ -125,7 +125,34 @@ class LicenseFacetGroup(FacetGroup):
return self.license.title
return LicenseFacet
facet_groups = [ FormatFacetGroup() , LicenseFacetGroup() ]
class KeywordFacetGroup(FacetGroup):
def __init__(self):
super(FacetGroup,self).__init__()
self.title = 'Keyword'
self.facets = []
def has_facet(self, facet_name):
return facet_name.startswith('kw.')
def get_facet_class(self, facet_name):
class KeywordFacet(NamedFacet):
def set_name(self):
self.facet_name=facet_name
self.keyword=self.facet_name[3:]
def get_query_set(self):
return self._get_query_set().filter(subjects__name=self.keyword)
def template(self):
return 'facets/keyword.html'
@property
def title(self):
return self.keyword
@property
def label(self):
return self.keyword
return KeywordFacet
facet_groups = [ FormatFacetGroup() , LicenseFacetGroup() , KeywordFacetGroup()]
def get_facet(facet_name):
for facet_group in facet_groups:

View File

@ -0,0 +1,5 @@
<div>
<p style="font-size:bigger">
keyword: {{facet.keyword}}
</p>
</div>