class EditForm(base.EditForm): """Portlet edit form. This is registered with configure.zcml. The form_fields variable tells zope.formlib which fields to display. """ form_fields = form.Fields(IPersonBadgePortlet) label = _(u"title_edit_person_badge_portlet", default=u"Edit person badge portlet") description = _(u"description_personbadge_portlet", default=u"This portlet displays a person of any type on a page. This form enables borders and footers.")
class AddForm(base.AddForm): """Portlet add form. This is registered in configure.zcml. The form_fields variable tells zope.formlib which fields to display. The create() method actually constructs the assignment that is being added. """ form_fields = form.Fields(IPersonBadgePortlet) label = _(u"title_add_person_badge_portlet", default=u"Add person badge portlet") description = _(u"person_badge_portlet", default=u"This portlet displays the person badge. This form enables borders and footers.") def create(self, data): return Assignment(**data)
class Assignment(base.Assignment): """Portlet assignment. This is what is actually managed through the portlets UI and associated with columns. """ implements(IPersonBadgePortlet) header = _(u"title_person_badge_portlet", default=u"Person Badge Portlet") omit_border = True footer = u"" more_url = '' def __init__(self, header=u"", text=u"", omit_border=True, footer=u"", more_url=''): self.header = header self.person = person self.omit_border = omit_border self.footer = footer self.more_url = more_url @property def title(self): """This property is used to give the title of the portlet in the "manage portlets" screen. Here, we use the title that the user gave or static string if title not defined. """ return self.header or _(u'portlet_person_badge', default=u"Person Badge Portlet")
class IPersonBadgePortlet(IPortletDataProvider): """A portlet which renders predefined static HTML. It inherits from IPortletDataProvider because for this portlet, the data that is being rendered and the portlet assignment itself are the same. """ header = schema.TextLine( title=_(u"Portlet header"), description=_(u"Title of the rendered portlet"), constraint=re.compile("[^\s]").match, required=False) person = schema.Choice( title=_(u"Target collection"), description=_(u"Find the collection which provides the items to list"), required=True, source=CatalogSource(portal_type=('FSDPerson')), ) omit_border = schema.Bool( title=_(u"Omit portlet border"), description=_(u"Tick this box if you want to render the text above " "without the standard header, border or footer."), required=True, default=True) footer = schema.TextLine( title=_(u"Portlet footer"), description=_(u"Text to be shown in the footer"), required=False) more_url = schema.ASCIILine( title=_(u"Details link"), description=_(u"If given, the header and footer " "will link to this URL."), required=False)
def title(self): """This property is used to give the title of the portlet in the "manage portlets" screen. Here, we use the title that the user gave or static string if title not defined. """ return self.header or _(u'portlet_person_badge', default=u"Person Badge Portlet")