new queries: listing of blogs that ignores empty blogs; listing for type instances
This commit is contained in:
parent
99de14ff44
commit
d9a0f39f06
5 changed files with 84 additions and 3 deletions
|
@ -320,6 +320,10 @@ class ConceptView(BaseView):
|
||||||
if r.order != pos:
|
if r.order != pos:
|
||||||
r.order = pos
|
r.order = pos
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def filterOptions(self):
|
||||||
|
return self.getOptions('filter.states')
|
||||||
|
|
||||||
def getChildren(self, topLevelOnly=True, sort=True, noDuplicates=True,
|
def getChildren(self, topLevelOnly=True, sort=True, noDuplicates=True,
|
||||||
useFilter=True, predicates=None):
|
useFilter=True, predicates=None):
|
||||||
form = self.request.form
|
form = self.request.form
|
||||||
|
@ -361,8 +365,7 @@ class ConceptView(BaseView):
|
||||||
options = IOptions(adapted(r.predicate), None)
|
options = IOptions(adapted(r.predicate), None)
|
||||||
if options is not None and options('hide_children'):
|
if options is not None and options('hide_children'):
|
||||||
continue
|
continue
|
||||||
filterOptions = self.getOptions('filter.states')
|
if not fv.check(r.context, self.filterOptions):
|
||||||
if not fv.check(r.context, filterOptions):
|
|
||||||
continue
|
continue
|
||||||
yield r
|
yield r
|
||||||
|
|
||||||
|
@ -718,3 +721,22 @@ class ListChildren(ConceptView):
|
||||||
def macro(self):
|
def macro(self):
|
||||||
return concept_macros.macros['list_children']
|
return concept_macros.macros['list_children']
|
||||||
|
|
||||||
|
|
||||||
|
class ListTypeInstances(ListChildren):
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def targets(self):
|
||||||
|
targetPredicate = self.conceptManager['querytarget']
|
||||||
|
for c in self.context.getChildren([targetPredicate]):
|
||||||
|
# TODO: use type-specific view
|
||||||
|
yield ConceptView(c, self.request)
|
||||||
|
|
||||||
|
def children(self, topLevelOnly=True, sort=True, noDuplicates=True,
|
||||||
|
useFilter=True, predicates=None):
|
||||||
|
# TODO: use filter options of query for selection of children
|
||||||
|
for tv in self.targets:
|
||||||
|
tv.filterOptions = self.filterOptions
|
||||||
|
for c in tv.getChildren(topLevelOnly, sort,
|
||||||
|
noDuplicates, useFilter, [self.typePredicate]):
|
||||||
|
yield c
|
||||||
|
|
||||||
|
|
|
@ -545,6 +545,14 @@
|
||||||
factory="loops.browser.concept.ListChildren"
|
factory="loops.browser.concept.ListChildren"
|
||||||
permission="zope.View" />
|
permission="zope.View" />
|
||||||
|
|
||||||
|
<zope:adapter
|
||||||
|
name="list_type_instances.html"
|
||||||
|
for="loops.interfaces.IConcept
|
||||||
|
zope.publisher.interfaces.browser.IBrowserRequest"
|
||||||
|
provides="zope.interface.Interface"
|
||||||
|
factory="loops.browser.concept.ListTypeInstances"
|
||||||
|
permission="zope.View" />
|
||||||
|
|
||||||
<!-- dialogs/forms (end-user views) -->
|
<!-- dialogs/forms (end-user views) -->
|
||||||
|
|
||||||
<page
|
<page
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2012 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2013 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -55,6 +55,32 @@ actions.register('createBlogPost', 'portlet', DialogAction,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# blog lists
|
||||||
|
|
||||||
|
class BlogList(ConceptView):
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def macro(self):
|
||||||
|
return view_macros.macros['bloglist']
|
||||||
|
|
||||||
|
def children(self, topLevelOnly=True, sort=True, noDuplicates=True,
|
||||||
|
useFilter=True, predicates=None):
|
||||||
|
rels = self.getChildren(topLevelOnly, sort,
|
||||||
|
noDuplicates, useFilter, predicates)
|
||||||
|
return [rel for rel in rels if self.notEmpty(rel)]
|
||||||
|
|
||||||
|
def notEmpty(self, rel):
|
||||||
|
if self.request.form.get('filter.states') == 'all':
|
||||||
|
return True
|
||||||
|
# TODO: use type-specific view
|
||||||
|
view = ConceptView(rel.relation.second, self.request)
|
||||||
|
for c in view.children():
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
# blog view
|
||||||
|
|
||||||
def supplyCreator(self, data):
|
def supplyCreator(self, data):
|
||||||
creator = data.get('creator')
|
creator = data.get('creator')
|
||||||
data['creatorId'] = creator
|
data['creatorId'] = creator
|
||||||
|
@ -128,6 +154,8 @@ class BlogView(ConceptView):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
# blog post view
|
||||||
|
|
||||||
class BlogPostView(ConceptView):
|
class BlogPostView(ConceptView):
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
|
@ -171,6 +199,8 @@ class BlogPostView(ConceptView):
|
||||||
yield self.childViewFactory(r, self.request, contextIsSecond=True)
|
yield self.childViewFactory(r, self.request, contextIsSecond=True)
|
||||||
|
|
||||||
|
|
||||||
|
# forms and form controllers
|
||||||
|
|
||||||
class EditBlogPostForm(EditConceptForm):
|
class EditBlogPostForm(EditConceptForm):
|
||||||
|
|
||||||
title = _(u'Edit Blog Post')
|
title = _(u'Edit Blog Post')
|
||||||
|
|
|
@ -37,6 +37,15 @@
|
||||||
|
|
||||||
<!-- views -->
|
<!-- views -->
|
||||||
|
|
||||||
|
<zope:adapter
|
||||||
|
name="bloglist.html"
|
||||||
|
for="loops.interfaces.IConcept
|
||||||
|
zope.publisher.interfaces.browser.IBrowserRequest"
|
||||||
|
provides="zope.interface.Interface"
|
||||||
|
factory="loops.compound.blog.browser.BlogList"
|
||||||
|
permission="zope.View"
|
||||||
|
/>
|
||||||
|
|
||||||
<zope:adapter
|
<zope:adapter
|
||||||
name="blog.html"
|
name="blog.html"
|
||||||
for="loops.interfaces.IConcept
|
for="loops.interfaces.IConcept
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
<html i18n:domain="loops">
|
||||||
|
|
||||||
|
|
||||||
|
<metal:block define-macro="bloglist">
|
||||||
|
<div tal:define="show_headline nothing">
|
||||||
|
<metal:fields use-macro="item/template/macros/concepttitle" /><br />
|
||||||
|
<metal:fields use-macro="item/template/macros/conceptchildren" />
|
||||||
|
</div>
|
||||||
|
</metal:block>
|
||||||
|
|
||||||
|
|
||||||
<metal:block define-macro="blog">
|
<metal:block define-macro="blog">
|
||||||
|
@ -74,3 +83,6 @@
|
||||||
<metal:resources use-macro="view/concept_macros/conceptresources" />
|
<metal:resources use-macro="view/concept_macros/conceptresources" />
|
||||||
<metal:block use-macro="view/comment_macros/comments" />
|
<metal:block use-macro="view/comment_macros/comments" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
Loading…
Add table
Reference in a new issue