def validate_url(value): """Checagem simples se o valor informado representa um site""" if not value: return True regex = re.compile(r'(%s)s?://[^\s\r\n]+' % '|'.join(valid_protocols)) if not regex.match(value): raise Invalid(_(u'Invalid URL.')) return True
class ISpacerTile(IPersistentCoverTile): """Tile to leave some free space to unveil the background image.""" height = schema.Int( title=_(u'Height'), description=_(u'Height of the tile, in pixels.'), required=True, default=400, ) title = schema.Text( title=_(u'Title'), description=_( u'Text used to describe the background image. ' u'For accessibility reasons, you should not use background images as the sole method of conveying important information.' ), required=False, )
class ISmartExpiration(model.Schema): """Behavior providing an expiration date and an expiration url """ expires = schema.Datetime( title=_(u'label_expiration_date', u'Expiration Date'), defaultFactory=default_expires, description=_( u'help_expiration_date', default=u'When this date is reached, the content will no ' u'longer be visible in listings and searches.'), required=False) expires_redirect = schema.TextLine( title=_(u'label_expires_redirect', default=u'Redirect to'), description=_(u'help_expires_redirect', default=u'After expiration, requests will be redirected ' u'to the url filled in here.'), constraint=validate_url, required=False) form.omitted('expires', 'expires_redirect') form.no_omit(IEditForm, 'expires', 'expires_redirect') form.no_omit(IAddForm, 'expires', 'expires_redirect')
class SpacerTile(PersistentCoverTile): """Tile to leave some free space to unveil the background image.""" implements(ISpacerTile) index = ViewPageTemplateFile('spacer.pt') is_configurable = False is_editable = True is_droppable = False short_name = _(u'msg_short_name_file', default=u'Spacer') @property def height(self): return self.data['height'] @property def Title(self): return self.data['title'] def accepted_ct(self): return []
class IPaginaDestaque(model.Schema): """Behavior adding a two-line title, a description and a links field """ title_1 = schema.TextLine( title=_(u'label_title_1', default=u'Title 1'), required=True ) title_2 = schema.TextLine( title=_(u'label_title_2', default=u'Title 2'), required=True ) description = schema.Text( title=_(u'label_description', default=u'Summary'), description=_( u'help_description', default=u'Used in item listings and search results.' ), required=False, missing_value=u'', ) form.widget(links=DataGridFieldFactory) links = schema.List( title=_(u'Footer links'), value_type=DictRow(title=_(u'Link'), schema=ILinkRow), required=False, ) form.order_before(links='*') form.order_before(description='*') form.order_before(title_2='*') form.order_before(title_1='*') form.omitted('title_1', 'title_2', 'description', 'links') form.no_omit(IEditForm, 'title_1', 'title_2', 'description', 'links') form.no_omit(IAddForm, 'title_1', 'title_2', 'description', 'links')
class ILinkRow(Interface): title_1 = schema.TextLine(title=_(u'Title 1'), required=False) title_2 = schema.TextLine(title=_(u'Title 2'), required=False) url = schema.TextLine(title=_(u'URL'), required=False)