[Zope3-checkins] CVS: Products3/NewsSite - reviewlist.pt:1.1 browser.py:1.5 configure.zcml:1.19 newssite.py:1.7

Christian Theune ct@gocept.com
Thu, 27 Mar 2003 11:04:58 -0500


Update of /cvs-repository/Products3/NewsSite
In directory cvs.zope.org:/tmp/cvs-serv2650

Modified Files:
	browser.py configure.zcml newssite.py 
Added Files:
	reviewlist.pt 
Log Message:
 - added worklist for reviewers
 - added workflow aware filtering for index site,
   rss and worklist



=== Added File Products3/NewsSite/reviewlist.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<title>News Site</title>

</head>
<body>
<div metal:fill-slot="body">
    <span tal:repeat="item view/listPendingNewsItems">
    
		<p>
        
            <span style="font-weight:bold;"  tal:content="item/date"/>
            <a href="link" tal:attributes= "href item/absolute_url"><span tal:content="item/dc/title"/></a>
            <a href="link" tal:attributes= "href item/review_url">Workflow</a>
           
            <br/>
		    <span tal:content="item/obj/lead"/>
       </p>
	</span>
</div>
</body>
</html>


=== Products3/NewsSite/browser.py 1.4 => 1.5 ===
--- Products3/NewsSite/browser.py:1.4	Thu Mar 27 09:05:11 2003
+++ Products3/NewsSite/browser.py	Thu Mar 27 11:04:57 2003
@@ -29,6 +29,8 @@
 from zope.app.event.objectevent import ObjectCreatedEvent
 from zope.app.interfaces.dublincore import IZopeDublinCore
 from zope.app.browser.container.adding import Adding
+from zope.app.browser.workflow.stateful.interfaces \
+    import IContentFilterAdapter
 
 from interfaces import INewsSite, INewsSiteFormSchema
 from interfaces import ISyndicationPolicies
@@ -98,9 +100,13 @@
         self.syn_policies = getAdapter(context, ISyndicationPolicies)
 
     def listSortedEntries(self):
-
         result = []
+        
         for k, v in self.site.items():
+            adapter = getAdapter(v, IContentFilterAdapter)
+            if not adapter.filterObjectByState(v, 'published', 'default'):
+                continue
+            
             dc = getAdapter(v, IZopeDublinCore)
             result.append((dc.effective or dc.created, k))
         return [x[1] for x in result]


=== Products3/NewsSite/configure.zcml 1.18 => 1.19 ===
--- Products3/NewsSite/configure.zcml:1.18	Thu Mar 27 09:50:58 2003
+++ Products3/NewsSite/configure.zcml	Thu Mar 27 11:04:57 2003
@@ -247,6 +247,18 @@
     for=".interfaces.INewsSite"
     />
 
+<!-- Reviewers worklist -->
+
+<browser:page
+    name="review.html"
+    for=".interfaces.INewsSite"
+    class=".newssite.NewsSiteView"
+    template="reviewlist.pt"
+    permission="zopeproducts.NewsSite.PublishContent"
+    menu="zmi_views"
+    title="Publisher review worklist"
+    />
+    
 <!-- Render RSS for our items.
   -->
 <browser:page


=== Products3/NewsSite/newssite.py 1.6 => 1.7 ===
--- Products3/NewsSite/newssite.py:1.6	Thu Mar 27 07:09:36 2003
+++ Products3/NewsSite/newssite.py	Thu Mar 27 11:04:57 2003
@@ -23,6 +23,8 @@
 from zope.app.interfaces.dublincore import ICMFDublinCore
 from zope.component import getAdapter, getView
 from zope.app.content.folder import Folder
+from zope.app.interfaces.workflow import IProcessInstanceContainerAdaptable
+from zope.app.browser.workflow.stateful.interfaces import IContentFilterAdapter
 
 from interfaces import INewsSite
 from interfaces import ISyndicationPolicies
@@ -38,25 +40,18 @@
 class NewsSiteView(BrowserView):
 
     __used_for__ = INewsSite
+    __implements__ = (BrowserView.__implements__, IProcessInstanceContainerAdaptable)
 
     def listPublicNewsItems(self):
-        #return self._list()
-        return self._newList()
-    
-    def _list(self):
-        site = [ ContextWrapper(self.context[x], self.context, name=x) 
-                 for x in self.context]
-        list = filter(lambda x: INewsItem.isImplementedBy(x), site)
-        list = [ (x, getAdapter(x, ICMFDublinCore).EffectiveDate())
-                 for x in list ]
-        list.sort(lambda x,y: cmp(x[1], y[1]))
-        list = [ x[0] for x in list]
-        list = [ {'obj':x,
-                  'absolute_url':getView(x, 'absolute_url', self.request)()}
-                 for x in list]
-        return list
+        return self._list(state=u"published")
+
+    def listPendingNewsItems(self):
+        return self._list(state=u"pending")
+
+    def listPrivateNewsItems(self):
+        return self._list(state=u"private")
 
-    def _newList(self):
+    def _list(self, state=u"published"):
         """Return a sequence of mappings for our news items.
 
         o Sort the list in descending order by date (either the effective
@@ -77,20 +72,26 @@
           'absolute_url' -- the item's URL.
         """
         decorated = []
-        for k, v in self.context.items():
-
-            if INewsItem.isImplementedBy(v):
+        
+        site = [ ContextWrapper(self.context[x], self.context, name=x) 
+                 for x in self.context]
+        list = filter(lambda x: INewsItem.isImplementedBy(x), site)
 
-                wrapped = ContextWrapper(v, self.context, name=k)
-                dc = getAdapter(wrapped, ICMFDublinCore)
+        filterAdapter = getAdapter(self.context, IContentFilterAdapter)
+        list = filterAdapter.filterListByState(list, state)
+        
+        for item in list:
+                dc = getAdapter(item, ICMFDublinCore)
                 date = dc.effective or dc.created
-                info = {'obj' : wrapped,
+                info = {'obj' : item,
                         'dc' : dc,
                         'date' : self._dateString(date),
                         'effective' : self._dateString(dc.effective),
                         'expires' : self._dateString(dc.expires),
                         'absolute_url' :
-                            getView(wrapped, 'absolute_url', self.request)()
+                            getView(item, 'absolute_url', self.request)(),
+                        'review_url' : 
+                            getView(item, 'absolute_url', self.request)()+u'/workflows.html'
                        }
                 decorated.append( (date, info) )