From: Hanno S. <svn...@pl...> - 2008-07-26 15:38:39
|
Author: hannosch Date: Sat Jul 26 15:38:48 2008 New Revision: 21893 Modified: plone.app.portlets/trunk/docs/HISTORY.txt plone.app.portlets/trunk/plone/app/portlets/portlets/review.pt plone.app.portlets/trunk/plone/app/portlets/portlets/review.py plone.app.portlets/trunk/plone/app/portlets/tests/test_review_portlet.py Log: Refactored the review portlet a bit and added the review state dependent color coding to it. This closes #6957. Modified: plone.app.portlets/trunk/docs/HISTORY.txt ============================================================================== --- plone.app.portlets/trunk/docs/HISTORY.txt (original) +++ plone.app.portlets/trunk/docs/HISTORY.txt Sat Jul 26 15:38:48 2008 @@ -4,6 +4,10 @@ plone.app.portlets 1.1.4 + - Refactored the review portlet a bit and added the review state dependent + color coding to it. This closes http://dev.plone.org/plone/ticket/6957. + [hannosch] + - Sort the addable portlets in the management screen by their title. This closes http://dev.plone.org/plone/ticket/8227. [hannosch] Modified: plone.app.portlets/trunk/plone/app/portlets/portlets/review.pt ============================================================================== --- plone.app.portlets/trunk/plone/app/portlets/portlets/review.pt (original) +++ plone.app.portlets/trunk/plone/app/portlets/portlets/review.pt Sat Jul 26 15:38:48 2008 @@ -10,27 +10,23 @@ <span class="portletTopRight"></span> </dt> - <tal:items tal:define="plone_view context/@@plone; - getIcon nocall:plone_view/getIcon; - toLocalizedTime nocall:plone_view/toLocalizedTime;" - tal:repeat="o view/review_items"> + <tal:items tal:repeat="o view/review_items"> <dd class="portletItem" tal:define="oddrow repeat/o/odd; - item_icon python:getIcon(o);" + review_state o/review_state;" tal:attributes="class python:oddrow and 'portletItem even' or 'portletItem odd'"> <a href="#" - class="visualIconPadding tile" - tal:attributes="href string:${o/absolute_url}/view; - title o/Description"> - <img tal:replace="structure item_icon/html_tag" /> + tal:attributes="href string:${o/path}/view; + title o/description; + class string:${o/review_state_class}visualIconPadding tile"> + <img tal:replace="structure o/icon" /> <span tal:replace="o/pretty_title_or_id"> Title </span> - <span class="portletItemDetails" - tal:define="moddate o/ModificationDate;"> - <span tal:replace="o/Creator">Jim Smith</span> — - <span tal:replace="python:toLocalizedTime(moddate)"> May 5</span> + <span class="portletItemDetails"> + <span tal:replace="o/creator">Jim Smith</span> — + <span tal:replace="o/mod_date"> May 5</span> </span> </a> Modified: plone.app.portlets/trunk/plone/app/portlets/portlets/review.py ============================================================================== --- plone.app.portlets/trunk/plone/app/portlets/portlets/review.py (original) +++ plone.app.portlets/trunk/plone/app/portlets/portlets/review.py Sat Jul 26 15:38:48 2008 @@ -1,9 +1,11 @@ from zope import schema from zope.component import getMultiAdapter +from zope.component import queryUtility from zope.formlib import form from zope.interface import implements from plone.app.portlets.portlets import base +from plone.i18n.normalizer.interfaces import IIDNormalizer from plone.memoize.instance import memoize from plone.portlets.interfaces import IPortletDataProvider @@ -27,15 +29,12 @@ render = ViewPageTemplateFile('review.pt') - def __init__(self, *args): - base.Renderer.__init__(self, *args) - - portal_state = getMultiAdapter((self.context, self.request), name=u'plone_portal_state') - self.anonymous = portal_state.anonymous() - self.portal_url = portal_state.portal_url() - - plone_tools = getMultiAdapter((self.context, self.request), name=u'plone_tools') - self.workflow = plone_tools.workflow() + @property + def anonymous(self): + context = aq_inner(self.context) + portal_state = getMultiAdapter((context, self.request), + name=u'plone_portal_state') + return portal_state.anonymous() @property def available(self): @@ -45,14 +44,39 @@ return self._data() def full_review_link(self): - return '%s/full_review_list' % self.portal_url + context = aq_inner(self.context) + portal_state = getMultiAdapter((context, self.request), + name=u'plone_portal_state') + return '%s/full_review_list' % portal_state.portal_url() @memoize def _data(self): if self.anonymous: return [] + context = aq_inner(self.context) + workflow = getToolByName(context, 'portal_workflow') - return self.workflow.getWorklistsResults() + plone_view = getMultiAdapter((context, self.request), name=u'plone') + getIcon = plone_view.getIcon + toLocalizedTime = plone_view.toLocalizedTime + + idnormalizer = queryUtility(IIDNormalizer) + norm = idnormalizer.normalize + objects = workflow.getWorklistsResults() + items = [] + for obj in objects: + review_state = workflow.getInfoFor(obj, 'review_state') + items.append(dict( + path = obj.absolute_url(), + title = obj.pretty_title_or_id(), + description = obj.Description(), + icon = getIcon(obj).html_tag(), + creator = obj.Creator(), + review_state = review_state, + review_state_class = 'state-%s ' % norm(review_state), + mod_date = toLocalizedTime(obj.ModificationDate()), + )) + return items class AddForm(base.NullAddForm): Modified: plone.app.portlets/trunk/plone/app/portlets/tests/test_review_portlet.py ============================================================================== --- plone.app.portlets/trunk/plone/app/portlets/tests/test_review_portlet.py (original) +++ plone.app.portlets/trunk/plone/app/portlets/tests/test_review_portlet.py Sat Jul 26 15:38:48 2008 @@ -1,6 +1,7 @@ from zope.component import getUtility, getMultiAdapter from zope.app.component.hooks import setHooks, setSite +from Products.CMFCore.utils import getToolByName from Products.GenericSetup.utils import _getDottedName from plone.portlets.interfaces import IPortletType @@ -66,6 +67,9 @@ def afterSetUp(self): setHooks() setSite(self.portal) + self.setRoles(['Manager']) + self.portal.invokeFactory('Document', 'doc1') + self.portal.invokeFactory('Document', 'doc2') def renderer(self, context=None, request=None, view=None, manager=None, assignment=None): context = context or self.folder @@ -79,6 +83,10 @@ def test_review_items(self): r = self.renderer(assignment=review.Assignment()) self.assertEquals(0, len(r.review_items())) + wf = getToolByName(self.portal, 'portal_workflow') + wf.doActionFor(self.portal.doc1, 'submit') + r = self.renderer(assignment=review.Assignment()) + self.assertEquals(1, len(r.review_items())) def test_full_news_link(self): r = self.renderer(assignment=review.Assignment()) |