Changeset 2704 in products
- Timestamp:
- Jul 20, 2010 7:51:26 AM (14 years ago)
- Location:
- quintagroup.portlet.collection/trunk/quintagroup/portlet/collection
- Files:
-
- 6 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/browser/configure.zcml
r1572 r2704 14 14 /> 15 15 16 <browser:resource 17 name="batch.js" 18 file="resources/batch.js" /> 16 19 </configure> -
quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/collection.pt
r1575 r2704 2 2 i18n:domain="plone" 3 3 tal:define="collection_url view/collection_url; 4 styling view/data/styling; 5 plone_view context/@@plone; 6 toLocalizedTime nocall:plone_view/toLocalizedTime; 7 getIcon nocall:plone_view/getIcon;" 4 styling view/data/styling" 8 5 tal:attributes="class string:${attrs/class} ${styling}"> 9 6 … … 15 12 </a> 16 13 <span class="portletTopRight"></span> 14 <span class="portletNavSection" 15 tal:condition="view/data/allow_batching" 16 tal:content="structure view/batch_navigation"> 17 </span> 17 18 </dt> 18 19 <tal:events tal:repeat="obj view/results"> 20 <dd class="portletItem" 21 tal:define="oddrow repeat/obj/odd; 22 item_icon python:getIcon(obj); 23 show_title python:view.showProperty('Title'); 24 show_description python:view.showProperty('Description')" 25 tal:attributes="class python:oddrow and 'portletItem even' or 'portletItem odd'"> 26 <a href="#" 27 class="tile" 28 tal:attributes="href obj/getURL; 29 title python: show_description and obj.Description or ''"> 30 <img tal:replace="structure item_icon/html_tag" /> 31 <span class="tileTitle" 32 tal:condition="show_title" 33 tal:content="obj/pretty_title_or_id"> 34 Title 35 </span> 36 <span class="tileDescription" 37 tal:condition="show_description"> 38 <tal:descr content="obj/Description" /> 39 <span class="tileReadMore" 40 tal:condition="view/data/show_item_more" 41 tal:attributes="href obj/getURL" i18n:translate="more_url"> 42 …more 43 </span> 44 </span> 45 <span class="portletItemDetails" 46 tal:condition="view/data/show_dates" 47 tal:content="python:toLocalizedTime(obj.Date)"> 48 Date 49 </span> 50 </a> 51 </dd> 52 </tal:events> 53 19 <tal:items replace="structure view/render_items"/> 54 20 <dd class="portletFooter" tal:condition="view/data/show_more"> 55 21 <span class="portletBottomLeft"></span> -
quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/collection.py
r1572 r2704 16 16 from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile 17 17 from plone.app.vocabularies.catalog import SearchableTextSourceBinder 18 from zope.schema import ValidationError 18 19 from plone.app.form.widgets.uberselectionwidget import UberSelectionWidget 19 20 20 21 from Products.ATContentTypes.interface import IATTopic 22 from Products.CMFPlone.PloneBatch import Batch 21 23 from plone.portlet.collection.collection import ICollectionPortlet 22 24 23 25 from quintagroup.portlet.collection import MessageFactory as _ 26 27 MIN_BATCH_SIZE , MAX_BATCHSIZE = 1, 30 28 29 class NotValidBatchSizeValue(ValidationError): 30 """This is not valid batch size value. 31 32 """ 33 34 def validate_batch_size(value): 35 if MIN_BATCH_SIZE <= value <= MAX_BATCHSIZE: 36 return True 37 raise NotValidBatchSizeValue(value) 24 38 25 39 class IQCollectionPortlet(ICollectionPortlet): … … 52 66 default=True) 53 67 68 allow_batching = schema.Bool(title=_(u"Allow batching."), 69 description=_(u"If enabled, items will be splited into pages."), 70 required=False, 71 default=False) 72 73 batch_size = schema.Int(title=_(u"Batch size"), 74 description=_("Amount of items per page" 75 "(if not set 3 items will be displayed as default)."), 76 required=False, 77 default=3, 78 constraint=validate_batch_size) 79 54 80 class Assignment(base.Assignment): 55 81 """ … … 68 94 def __init__(self, header=u"", target_collection=None, limit=None, 69 95 random=False, show_more=True, show_dates=False, 70 item_attributes=[], styling=u"", show_item_more=False, link_title=True): 96 item_attributes=[], styling=u"", show_item_more=False, 97 link_title=True, allow_batching=False, batch_size=3): 71 98 72 99 super(Assignment, self).__init__(header=header, … … 79 106 self.show_item_more = show_item_more 80 107 self.link_title = link_title 108 self.allow_batching = allow_batching 109 self.batch_size = batch_size 81 110 82 111 @property … … 86 115 """ 87 116 return self.header 88 89 117 90 118 class Renderer(base.Renderer): 91 119 """Portlet renderer. … … 97 125 98 126 render = ViewPageTemplateFile('collection.pt') 127 navigation = ViewPageTemplateFile('browser/templates/navigation.pt') 128 items_listing = ViewPageTemplateFile('browser/templates/items_listing.pt') 99 129 100 130 def showProperty(self, name): 101 131 return name in self.data.item_attributes 102 132 133 def batches(self): 134 items = super(Renderer, self).results() 135 delta = self.data.batch_size 136 return [items[idx:idx + delta] for idx in range(0, len(items), delta)] 137 138 def batch_navigation(self): 139 return self.navigation(batches=self.batches()) 140 141 def render_items(self): 142 if self.data.allow_batching: 143 return ''.join([self.items_listing(portlet_items=batch, 144 page_number=str(index)) 145 for index, batch in enumerate(self.batches())]) 146 return self.items_listing(portlet_items=self.results()) 103 147 104 148 class AddForm(base.AddForm):
Note: See TracChangeset
for help on using the changeset viewer.