def msg_types(context): terms = [] terms.append(SimpleTerm("info", title=_("info"))) terms.append(SimpleTerm("significant", title=_("significant"))) terms.append(SimpleTerm("warning", title=_("warning"))) return SimpleVocabulary(terms)
def location(context): terms = [] terms.append(SimpleTerm("fullsite", title=_("Full site"))) terms.append(SimpleTerm("homepage", title=_("Homepage"))) return SimpleVocabulary(terms)
def validateStartEnd(data): if data.start is not None and data.end is not None: if data.start > data.end: raise Invalid(_(u"The start date must precede the end date."))
class IMessage(model.Schema): title = schema.TextLine( title=_(u'Title'), required=True, ) text = RichText( title=_(u'Text'), required=True, description=_(u'Message text'), ) msg_type = schema.Choice( title=_(u'Message type'), required=True, source=msg_types, description=_(u'Following the type, the color will be different'), ) form.widget('can_hide', RadioFieldWidget) can_hide = schema.Bool( title=_(u'Can be marked as read'), description=_(u'If checked, the user can hide the message'), default=False, ) start = schema.Datetime( title=_(u'Start date'), required=False, description=_(u'Specify start date message appearance'), defaultFactory=default_start, ) if HAS_PLONE_5: form.widget('start', dtfw5, default_timezone=default_timezone) else: form.widget('start', dtfw4) end = schema.Datetime( title=_(u'End date'), required=False, description= _(u'Specify end date message appearance. If nothing specified, this is infinite. ' u"If you pick a date, <span class=warning-formHelp>dont't forget hours !</span>" ), ) if HAS_PLONE_5: form.widget('end', dtfw5, default_timezone=default_timezone) else: form.widget('end', dtfw4) required_roles = schema.Set( title=_(u'Required roles'), description=_( u'Choose the roles for which the message will be displayed'), required=False, value_type=schema.Choice(vocabulary='plone.app.vocabularies.Roles'), ) form.widget('required_roles', CheckBoxFieldWidget, multiple='multiple', size=15) form.widget('use_local_roles', RadioFieldWidget) use_local_roles = schema.Bool( title=_(u'Use Reader local role'), description= _(u"If checked, the message will be shown only to users having message local role 'Reader'" ), default=False, ) location = schema.Choice( title=_(u'Location'), required=True, source=location, ) hidden_uid = schema.TextLine( title=u'Generated uid', defaultFactory=generate_uid, ) form.mode(hidden_uid='hidden') @invariant def validateStartEnd(data): if data.start is not None and data.end is not None: data_start = add_timezone(data.start) data_end = add_timezone(data.end) if data_start > data_end: raise Invalid(_(u'The start date must precede the end date.'))
def location(context): terms = [] terms.append(SimpleTerm('fullsite', title=_('Full site'))) terms.append(SimpleTerm('homepage', title=_('Homepage'))) return SimpleVocabulary(terms)
def msg_types(context): terms = [] terms.append(SimpleTerm('info', title=_('info'))) terms.append(SimpleTerm('significant', title=_('significant'))) terms.append(SimpleTerm('warning', title=_('warning'))) return SimpleVocabulary(terms)
def validateStartEnd(data): if data.start is not None and data.end is not None: data_start = add_timezone(data.start) data_end = add_timezone(data.end) if data_start > data_end: raise Invalid(_(u'The start date must precede the end date.'))