From 513e730132c97a36f2136b9e318c94a2d893e75a Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Wed, 16 Oct 2013 15:18:11 +0200 Subject: [PATCH] book, book topics: show only published texts and topics --- compound/book/browser.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/compound/book/browser.py b/compound/book/browser.py index 2635929..e1408a8 100644 --- a/compound/book/browser.py +++ b/compound/book/browser.py @@ -95,6 +95,20 @@ class Base(object): if self.editable: return 'index.html' + def checkState(self, stateful): + if stateful is None: + return True + if stateful.statesDefinition == 'simple_publishing': + return stateful.state in ('published',) + return True + + def children(self): + for c in self.getChildren(): + for stf in c.states or [None]: + if self.checkState(stf): + yield c + break + def getResources(self): relViews = super(Base, self).getResources() return relViews @@ -106,9 +120,12 @@ class Base(object): idx = 0 for rv in self.getResources(): if rv.context.contentType.startswith('text/'): - idx += 1 - result.append(rv) - self.images.append([]) + for stf in rv.states or [None]: + if self.checkState(stf): + idx += 1 + result.append(rv) + self.images.append([]) + break else: self.registerDojoLightbox() url = self.nodeView.getUrlForTarget(rv.context)