class NewsFlashSettingsEditForm(controlpanel.RegistryEditForm): schema = INewsFlashSettings label = _(u'News Flash Settings') description = _(u'Here you can modify the settings for ' 'collective.newsflash.') def updateFields(self): super(NewsFlashSettingsEditForm, self).updateFields() def updateWidgets(self): super(NewsFlashSettingsEditForm, self).updateWidgets()
class NewsFlashEditForm(form.Form): fields = field.Fields(INewsFlash) ignoreContext = True # don't use context to get widget data label = _("Manage News Flashes") def update(self): portal = getSite() annotations = IAnnotations(portal) field = self.fields['newsflash'].field field.default = annotations.get('collective.newsflash.newsflash', []) # call the base class version - this is very important! super(NewsFlashEditForm, self).update() def render(self): submitted = self.request.form.get('form.buttons.save', False) if submitted: data, errors = self.extractData() if errors: return super(NewsFlashEditForm, self).render() else: return None else: return super(NewsFlashEditForm, self).render() @button.buttonAndHandler(_(u'Save')) def handleApply(self, action): portal = getSite() data, errors = self.extractData() if errors: return annotations = IAnnotations(portal) if 'newsflash' in data and data['newsflash']: annotations['collective.newsflash.newsflash'] = data['newsflash'] else: annotations['collective.newsflash.newsflash'] = [] return None
class INewsFlashSettings(Interface): """Interface for the form on the control panel. """ titleText = schema.TextLine( title=_(u'Title text'), description=_(u'To remove the title set this to an empty ' 'string.'), required=True, defaultFactory=default_title_text, missing_value=u"", ) speed = schema.Float( title=_(u'Display speed'), description=_(u'The speed at which the news flashes appear on the ' 'screen. Values go from 0.0 - 1.0.'), required=True, min=0.0, max=1.0, default=0.1, ) pauseOnItems = schema.Int( title=_(u'Time items appear on screen'), description=_(u'The time, in miliseconds (ms), that each news flash ' 'item appears on the screen.'), required=True, min=0, default=2000, ) controls = schema.Bool( title=_(u'Controls'), description=_(u'Whether or not to show the ticker controls.'), default=config.CONTROLS, )
# -*- coding: utf-8 -*- from collective.newsflash import _ PROJECTNAME = 'collective.newsflash' CONTROLS = False # Whether or not to show the jQuery News Flash controls TITLE_TEXT = _(u'Latest') # To remove the title set this to an empty string
class INewsFlash(interface.Interface): newsflash = schema.List(value_type=schema.Text(title=_(u'News Flash'), default=u''), default=[], required=False)