Merge pull request #422 from Gluejar/facets_instance_var

rewrite some classes in facets.py to use instance variables
pull/1/head
Raymond Yee 2014-12-08 14:28:55 -08:00
commit 187e48e820
1 changed files with 15 additions and 9 deletions

View File

@ -4,12 +4,10 @@ from regluit.core import cc
class BaseFacet(object):
facet_name = 'all'
outer_facet = None
model = get_model('core', 'Work')
def __init__(self, outer_facet):
if outer_facet:
self.outer_facet = outer_facet
self.outer_facet = outer_facet if outer_facet else None
self.model = get_model('core', 'Work')
def _get_query_set(self):
if self.outer_facet:
@ -81,8 +79,12 @@ class NamedFacet(BaseFacet):
self.set_name()
class FormatFacetGroup(FacetGroup):
title = 'Format'
facets = ['pdf', 'epub', 'mobi']
def __init__(self):
super(FacetGroup,self).__init__()
self.title = 'Format'
self.facets = ['pdf', 'epub', 'mobi']
def get_facet_class(self, facet_name):
class FormatFacet(NamedFacet):
@ -96,9 +98,13 @@ class FormatFacetGroup(FacetGroup):
class LicenseFacetGroup(FacetGroup):
title = 'License'
licenses = cc.LICENSE_LIST_ALL
facets = cc.FACET_LIST
def __init__(self):
super(FacetGroup,self).__init__()
self.title = 'License'
self.licenses = cc.LICENSE_LIST_ALL
self.facets = cc.FACET_LIST
def get_facet_class(self, facet_name):
class LicenseFacet(NamedFacet):