source: products/ploneorg.kudobounty/trunk/ploneorg/kudobounty/browser/viewlets.py @ 3129

Last change on this file since 3129 was 3129, checked in by mylan, 10 years ago

Initial import of the package

  • Property svn:eol-style set to native
File size: 906 bytes
Line 
1from Products.CMFCore.utils import getToolByName
2from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
3from plone.app.layout.viewlets import common
4
5from ploneorg.kudobounty.config import TOPIC_PATH
6
7# -*- extra stuff goes here -*-
8
9class BountyViewlet(common.ViewletBase):
10    render = ViewPageTemplateFile('bounty_viewlet.pt')
11
12    def topic(self):
13        try:
14            return self.portal_state.portal().restrictedTraverse(TOPIC_PATH)
15        except KeyError:
16            return None
17
18    def available(self):
19        return bool(self.topic())
20
21    def bounty_submissions(self):
22        #import pdb;pdb.set_trace()
23        query = self.topic().queryCatalog()
24        res = [{'url':b.getRemoteUrl,
25                'title': b.Title,
26                'alt': b.Description,
27                'img_url': "%s/image_bounty" % b.getURL()} \
28                 for b in query]
29        return res
Note: See TracBrowser for help on using the repository browser.