本文整理汇总了Python中eea.facetednavigation.interfaces.ICriteria.__name__方法的典型用法代码示例。如果您正苦于以下问题:Python ICriteria.__name__方法的具体用法?Python ICriteria.__name__怎么用?Python ICriteria.__name__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eea.facetednavigation.interfaces.ICriteria
的用法示例。
在下文中一共展示了ICriteria.__name__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_with_sub_faceted
# 需要导入模块: from eea.facetednavigation.interfaces import ICriteria [as 别名]
# 或者: from eea.facetednavigation.interfaces.ICriteria import __name__ [as 别名]
def test_with_sub_faceted(self):
"""Test behaviour of the vocabulary when we have subfolders
with activated faceted navigation."""
# add collection to self.folder
c1 = api.content.create(
id='collection1',
type='DashboardCollection',
title='Collection 1',
container=self.folder,
tal_condition=u'',
roles_bypassing_talcondition=[],
)
c2 = api.content.create(
id='collection2',
type='DashboardCollection',
title='Collection 2',
container=self.folder,
tal_condition=u'',
roles_bypassing_talcondition=[],
)
# create a subfolder, add collections into it
api.content.create(
id='subfolder',
type='Folder',
title='Subfolder',
container=self.folder
)
c3 = api.content.create(
id='collection3',
type='DashboardCollection',
title='Collection 3',
container=self.folder.subfolder,
tal_condition=u'',
roles_bypassing_talcondition=[],
)
c4 = api.content.create(
id='collection4',
type='DashboardCollection',
title='Collection 4',
container=self.folder.subfolder,
tal_condition=u'',
roles_bypassing_talcondition=[],
)
# for now, faceted navigation is not enabled on subfolder,
# it behaves like a normal category
vocabulary = CollectionVocabularyFactory(self.folder)
folderCatVocabulary = CollectionCategoryVocabularyFactory(self.folder)
subfolderCatVocabulary = CollectionCategoryVocabularyFactory(self.folder.subfolder)
self.assertTrue(folderCatVocabulary.by_token.keys() ==
subfolderCatVocabulary.by_token.keys())
# redirect_to is not filled
self.assertFalse(vocabulary.getTermByToken(c1.UID()).title[1])
self.assertFalse(vocabulary.getTermByToken(c2.UID()).title[1])
self.assertFalse(vocabulary.getTermByToken(c3.UID()).title[1])
self.assertFalse(vocabulary.getTermByToken(c4.UID()).title[1])
# now enable faceted navigation for subfolder
subtyper = getMultiAdapter((self.folder.subfolder, self.request),
name=u'faceted_subtyper')
subtyper.enable()
# change the CollectionWidget id to "c44" so we are sure that
# the generated link is the one to this widget
collection_widget = ICriteria(self.folder.subfolder).get('c1')
self.assertEquals(collection_widget.widget,
CollectionWidget.widget_type)
collection_widget.__name__ = u'c44'
vocabulary = CollectionVocabularyFactory(self.folder)
folderCatVocabulary = CollectionCategoryVocabularyFactory(self.folder)
subfolderCatVocabulary = CollectionCategoryVocabularyFactory(self.folder.subfolder)
self.assertTrue(folderCatVocabulary.by_token.keys() ==
subfolderCatVocabulary.by_token.keys())
# as we are getting the vocabulary on self.folder,
# redirect_to is filled for collections of subfolder
# while generating links to specific sub faceted, a 'no_redirect' is added
# so the user is not redirected to the faceted using the default
self.assertFalse(vocabulary.getTermByToken(c1.UID()).title[1])
self.assertFalse(vocabulary.getTermByToken(c2.UID()).title[1])
self.assertEquals(vocabulary.getTermByToken(c3.UID()).title[1],
'{0}?no_redirect=1#c44={1}'.format(self.folder.subfolder.absolute_url(),
c3.UID())
)
self.assertEquals(vocabulary.getTermByToken(c4.UID()).title[1],
'{0}?no_redirect=1#c44={1}'.format(self.folder.subfolder.absolute_url(),
c4.UID())
)
# if we get vocabulary from subfolder, it works the other way round
# but moreover, we have a no_redirect=1 that avoid to redirect if we
# are sending the user to the root folder of the faceted navigation
vocabulary = CollectionVocabularyFactory(self.folder.subfolder)
folderCatVocabulary = CollectionCategoryVocabularyFactory(self.folder)
subfolderCatVocabulary = CollectionCategoryVocabularyFactory(self.folder.subfolder)
self.assertTrue(folderCatVocabulary.by_token.keys() ==
subfolderCatVocabulary.by_token.keys())
self.assertEquals(vocabulary.getTermByToken(c1.UID()).title[1],
'{0}?no_redirect=1#c1={1}'.format(self.folder.absolute_url(),
c1.UID())
#.........这里部分代码省略.........