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(ISuccessStoryPortlet) label = _("Add Success Story Portlet") description = _("This portlet displays a random success story")
class ISuccessStoryPortlet(IPortletDataProvider): """A portlet 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=_("Header"), description=_("Portlet header"), required=True) searchpath = schema.Choice(title=_("Stories Path"), description=_("Search for success stories inside this path"), required=True, vocabulary='atss.existing_folders') number_of_stories = schema.Int(title=_("Number of stories"), description=_("Specify how many Success Stories you want displayed at the same time in the portlet. Most commonly you will need 1."), required=True) keywords = schema.Tuple(title=_("Categories"), description=_("Items containing what categories " "to show. If none is selected, this " "field will be ignored."), required=False, value_type=schema.Choice( vocabulary="plone.app.vocabularies.Keywords"))
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(ISuccessStoryPortlet) label = _("Add Success Story Portlet") description = _("This portlet displays a random success story") def create(self, data): assignment = Assignment() form.applyChanges(assignment, self.form_fields, data) return assignment
def existingSSFolders( context ): pc = getToolByName(context, 'portal_catalog') pu = getToolByName(context, 'portal_url') portal = pu.getPortalObject() portal_path = '/'.join(portal.getPhysicalPath()) results = pc.searchResults(portal_type='ATSuccessStoryFolder') terms = [SimpleVocabulary.createTerm(portal_path, portal_path, _(u'Global'))] for value in results: path = value.getPath() terms.append(SimpleVocabulary.createTerm(path, path, u'%s - %s'%(value.Title, value.getPath()))) return SimpleVocabulary(terms)
def existingSSFolders(context): pc = getToolByName(context, 'portal_catalog') pu = getToolByName(context, 'portal_url') portal = pu.getPortalObject() portal_path = '/'.join(portal.getPhysicalPath()) results = pc.searchResults(portal_type='ATSuccessStoryFolder') terms = [ SimpleVocabulary.createTerm(portal_path, portal_path, _('Global')) ] for value in results: path = value.getPath() terms.append( SimpleVocabulary.createTerm( path, path, '%s - %s' % (value.Title, value.getPath()))) return SimpleVocabulary(terms)
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. """ return _(u"Success Story Portlet")
from Products.ATSuccessStory.content.ATSuccessStoryFolder import ATSuccessStoryFolder from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin from Products.ATSuccessStory.config import * from Products.ATSuccessStory import _ ##code-section module-header #fill in your manual code here ##/code-section module-header schema = Schema(( TextField( name='Story', allowable_content_types=('text/plain', 'text/structured', 'text/html', 'application/msword',), widget=RichWidget( label=_('Story'), ), default_output_type='text/html', required=1, ), ImageField( name='Image', widget=ImageField._properties['widget']( label=_('Image'), ), required=1, storage=AttributeStorage(), sizes={'large' : (768, 768), 'preview' : (400, 400), 'mini' : (200, 200), 'atss' : (185, 185), 'thumb' : (128, 128), 'tile' : (64, 64), 'icon' : (32, 32), 'listing' : (16, 16),}, ), ),
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. """ return _("Success Story Portlet")
from Products.ATSuccessStory.config import * from Products.ATSuccessStory import _ ##code-section module-header #fill in your manual code here ##/code-section module-header schema = Schema(( TextField( name='Story', allowable_content_types=( 'text/plain', 'text/structured', 'text/html', 'application/msword', ), widget=RichWidget(label=_('Story'), ), default_output_type='text/html', required=1, ), ImageField( name='Image', widget=ImageField._properties['widget'](label=_('Image'), ), required=1, storage=AttributeStorage(), sizes={ 'large': (768, 768), 'preview': (400, 400), 'mini': (200, 200), 'atss': (185, 185), 'thumb': (128, 128), 'tile': (64, 64),