source: products/quintagroup.quills.extras/trunk/quintagroup/quills/extras/portlets/recentcomments.py @ 1579

Last change on this file since 1579 was 1579, checked in by fenix, 14 years ago

added recent portlet comment, fixed styles for recent author portlet

  • Property svn:executable set to *
File size: 2.5 KB
Line 
1from zope import schema
2from zope.formlib import form
3from zope.interface import implements
4from zope.component import getMultiAdapter
5
6from plone.memoize.compress import xhtml_compress
7from plone.portlets.interfaces import IPortletDataProvider
8
9from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
10
11# Quills imports
12from quills.core.interfaces import IBaseContent
13from quills.core.interfaces import IWeblogEnhanced
14from quills.core.interfaces import IWeblog
15from quills.app.utilities import recurseToInterface
16from quills.app.utilities import talkbackURL
17from quills.app.utilities import getArchiveURLFor
18from quills.app.browser.baseview import BaseView
19from quills.app import QuillsAppMessageFactory as _
20
21# Local imports
22from quills.app.portlets import recentcomments as base
23from quills.app.portlets.base import BasePortletRenderer
24
25
26PORTLET_TITLE = _(u"Recent Comments")
27PORTLET_DESC = _(u"This portlet lists recent weblog comments.")
28
29
30class IRecentCommentsPortlet(base.IRecentWeblogCommentsPortlet):
31
32    blog_path = schema.TextLine(
33        title=_(u"Path to Blog"),
34        description=_(u"Physical path to blog, from the plone object, 'blog' for ex."),
35        required=True)
36
37
38class Assignment(base.Assignment):
39
40    implements(IRecentCommentsPortlet)
41
42    def __init__(self, max_comments=5, blog_path='blog'):
43        super(Assignment, self).__init__(max_comments = max_comments)
44        self.blog_path = blog_path
45
46    @property
47    def title(self):
48        return PORTLET_TITLE
49
50
51class Renderer(BasePortletRenderer, base.Renderer, BaseView):
52
53    _template = ViewPageTemplateFile('recentcomments.pt')
54
55    @property
56    def available(self):
57        return len(self.getComments) > 0
58
59    @property
60    def title(self):
61        return PORTLET_TITLE
62
63    def getWeblog(self):
64        pstate = getMultiAdapter((self.context, self.request), name=u'plone_portal_state')
65        portal = pstate.portal()
66        weblog = portal.restrictedTraverse(str(self.data.blog_path))
67        return IWeblog(weblog)
68       
69class AddForm(base.AddForm):
70    form_fields = form.Fields(IRecentCommentsPortlet)
71    label = _(u'add-portlet', default=u"Add ${portlet-name} Portlet", mapping={u'portlet-name': PORTLET_TITLE})
72    description = PORTLET_DESC
73
74    def create(self, data):
75        return Assignment(max_comments=5, blog_path='blog')
76
77
78class EditForm(base.EditForm):
79    form_fields = form.Fields(IRecentCommentsPortlet)
80    label = _(u'edit-portlet', default=u"Edit ${portlet-name} Portlet", mapping={u'portlet-name': PORTLET_TITLE})
81    description = PORTLET_DESC
Note: See TracBrowser for help on using the repository browser.