def upgrade_11_to_20b1(setup_tool): """ Upgrade old Carousel banners by moving the description into the new body field. """ # Install new dependencies. qi = getToolByName(setup_tool, 'portal_quickinstaller') if qi.isProductInstallable('plone.app.z3cform') and not \ qi.isProductInstalled('plone.app.z3cform'): qi.installProduct('plone.app.z3cform') # Update Carousel banners. catalog = getToolByName(setup_tool, 'portal_catalog') transforms = getToolByName(setup_tool, 'portal_transforms') banners = catalog.searchResults({ 'object_provides': ICarouselBanner.__identifier__, }) for banner in banners: description = banner.Description if description: html = transforms.convertTo('text/html', description, mimetype='text/plain') banner.getObject().setText(html.getData(), mimetype='text/html') # Change the tab name to Carousel. actions = getToolByName(setup_tool, 'portal_actions') obj_actions = actions.get('object', {}) if 'carousel' in obj_actions.keys(): obj_actions['carousel'].title = _(u'Carousel')
class TransitionGroup(group.Group): """ Transition options. """ label = _('Transition') fields = field.Fields(ICarouselSettings).select( 'transition_type', 'transition_speed', 'transition_delay')
class CarouselSettingsForm(group.GroupForm, form.EditForm): """ Form for editing Carousel settings. """ label = _('Carousel Settings') groups = (AppearanceGroup, TransitionGroup, DisplayGroup,) def getContent(self): return ICarouselSettings(self.context)
class DisplayGroup(group.Group): """ Display options. """ label = _('Display') fields = field.Fields(ICarouselSettings).select( 'enabled', 'default_page_only') fields['enabled'].widgetFactory = SingleCheckBoxFieldWidget fields['default_page_only'].widgetFactory = SingleCheckBoxFieldWidget
class AppearanceGroup(group.Group): """ Appearance options. """ label = _('Appearance') fields = field.Fields(ICarouselSettings).select( 'banner_template', 'banner_elements', 'width', 'height', 'pager_template', 'element_id', 'lazyload', 'random_order') fields['banner_elements'].widgetFactory = CheckBoxFieldWidget fields['lazyload'].widgetFactory = SingleCheckBoxFieldWidget fields['random_order'].widgetFactory = SingleCheckBoxFieldWidget
label = _(u"Display") fields = field.Fields(ICarouselSettings).select("enabled", "default_page_only") fields["enabled"].widgetFactory = SingleCheckBoxFieldWidget fields["default_page_only"].widgetFactory = SingleCheckBoxFieldWidget class CarouselSettingsForm(group.GroupForm, form.EditForm): """ Form for editing Carousel settings. """ label = _(u"Carousel Settings") groups = (AppearanceGroup, TransitionGroup, DisplayGroup) def getContent(self): return ICarouselSettings(self.context) CarouselSettingsForm.buttons["apply"].title = _(u"Save") class CarouselSettingsView(FormWrapper): """ View for searching and filtering ATResources. """ implements(ICarouselSettingsView) index = ViewPageTemplateFile("settings.pt") form = CarouselSettingsForm
from Products.Carousel.interfaces import ICarouselBanner from Products.Carousel.config import PROJECTNAME CarouselBannerSchema = link.ATLinkSchema.copy() + atapi.Schema(( atapi.ImageField('image', required = False, storage = atapi.AnnotationStorage(), languageIndependent = True, max_size = zconf.ATNewsItem.max_image_dimension, sizes= {}, validators = (('isNonEmptyFile', V_REQUIRED), ('checkNewsImageMaxSize', V_REQUIRED)), widget = atapi.ImageWidget( description = _(u'This image will be shown when this banner is active.'), label= _(u'Image'), show_content_type = False) ), atapi.StringField('imageUrl', required=False, searchable=False, default = "http://", widget = atapi.StringWidget( description = _(u'Instead of uploading an image, you may enter' u' the URL of an image hosted on another server.'), label = _(u'Image URL'), maxlength = '511') ),
label = _('Display') fields = field.Fields(ICarouselSettings).select( 'enabled', 'default_page_only') fields['enabled'].widgetFactory = SingleCheckBoxFieldWidget fields['default_page_only'].widgetFactory = SingleCheckBoxFieldWidget class CarouselSettingsForm(group.GroupForm, form.EditForm): """ Form for editing Carousel settings. """ label = _('Carousel Settings') groups = (AppearanceGroup, TransitionGroup, DisplayGroup,) def getContent(self): return ICarouselSettings(self.context) CarouselSettingsForm.buttons['apply'].title = _('Save') class CarouselSettingsView(FormWrapper): """ View for searching and filtering ATResources. """ implements(ICarouselSettingsView) index = ViewPageTemplateFile('settings.pt') form = CarouselSettingsForm
class ICarouselSettings(Interface): """ Settings for a Carousel. """ enabled = schema.Bool( title=_(u'Enabled'), description=_(u'Uncheck this box to hide the Carousel temporarily.'), default=True, ) banner_template = schema.Choice( title=_(u'Banner Type'), description=_(u'The banner is the part of the Carousel that rotates.' ' Choose Default for the standard Carousel banner.'), vocabulary='Products.Carousel.BannerTemplates', ) banner_elements = schema.List( title=_('Banner Elements'), description=_( u'Select the elements that should be visible on the' u' banner. Note that custom banner types may not provide all elements.' ), value_type=schema.Choice(vocabulary=SimpleVocabulary.fromItems(( (_(u'Title'), u'title'), (_(u'Text'), u'text'), (_(u'Image'), u'image'), )), ), default=[u'title', u'text', u'image'], required=False, ) width = schema.Int( title=_(u'Banner Width'), description=_( u'Enter the width of the banner in pixels. If you leave' ' this field blank, Carousel will use the width of the first banner.' ), required=False, ) height = schema.Int( title=_(u'Banner Height'), description=_( u'Enter the height of the banner in pixels. If you leave' ' this field blank, Carousel will use the height of the first banner.' ), required=False, ) pager_template = schema.Choice( title=_(u'Pager Type'), description=_( u'The pager allows user to navigate between banners.' ' Choose the type of pager to display, or select None for no pager.' ), vocabulary='Products.Carousel.PagerTemplates', ) element_id = schema.TextLine( title=_(u'Unique ID'), description=_(u'Enter an ID for the Carousel container element.' ' It can be used to apply CSS to the Carousel.'), ) transition_type = schema.Choice( title=_(u'Transition'), vocabulary=SimpleVocabulary.fromItems(( (_(u'Cross Fade'), u'fade'), (_(u'Slide'), u'slide'), )), default=u'fade', ) transition_speed = schema.Float( title=_(u'Transition Speed'), description=_(u'Enter the speed of the transition in seconds.'), default=0.5, min=0.0, ) transition_delay = schema.Float( title=_(u'Transition Delay'), description=_(u'Enter the number of seconds that Carousel should pause' ' between banners.'), default=8.0, min=0.0, ) default_page_only = schema.Bool( title=_(u'Only display on the default item'), description=_( u'Only display the Carousel on the default item of this' ' folder. Otherwise, the Carousel appears on every item in' ' the folder.'), default=True, ) random_order = schema.Bool( title=_(u'Random order'), description= _(u'Carousel pictures will reappear in random order on every page refresh.' ), default=True, ) lazyload = schema.Bool( title=_(u'Enabled lazily load carousel images'), description=_(u'Check this box to conserve the user and the server' ' bandwidth if the full carousel cycle is not shown.'), default=False, ) responsive = schema.Bool( title=_(u'Enabled responsive carousel images'), description=_(u'Check this box to show images witout inline size.'), default=False, )
'image-14' : (554, 2000), 'image-15' : (595, 2000), 'image-16' : (636, 2000), 'image-17' : (677, 2000), 'image-18' : (718, 2000), 'image-19' : (759, 2000), 'image-20' : (800, 2000), 'image-21' : (841, 2000), 'image-22' : (882, 2000), 'image-23' : (923, 2000), 'image-24' : (964, 2000) }, validators = (('isNonEmptyFile', V_REQUIRED), ('checkNewsImageMaxSize', V_REQUIRED)), widget = atapi.ImageWidget( description = _(u'This image will be shown when this banner is active.'), label= _(u'Image'), show_content_type = False) ), )) schemata.finalizeATCTSchema(CarouselBlockImageSchema, moveDiscussion=False) class CarouselBlockImage(CarouselBanner): """Banner image used in the CarouselBlock""" implements(ICarouselBlockImage) meta_type = "CarouselBlockImage"
label = _(u'Display') fields = field.Fields(ICarouselSettings).select( 'enabled', 'default_page_only') fields['enabled'].widgetFactory = SingleCheckBoxFieldWidget fields['default_page_only'].widgetFactory = SingleCheckBoxFieldWidget class CarouselSettingsForm(group.GroupForm, form.EditForm): """ Form for editing Carousel settings. """ label = _(u'Carousel Settings') groups = (AppearanceGroup, TransitionGroup, DisplayGroup,) def getContent(self): return ICarouselSettings(self.context) CarouselSettingsForm.buttons['apply'].title = _(u'Save') class CarouselSettingsView(FormWrapper): """ View for searching and filtering ATResources. """ implements(ICarouselSettingsView) index = ViewPageTemplateFile('settings.pt') form = CarouselSettingsForm
from Products.Carousel import CarouselMessageFactory as _ from Products.Carousel.interfaces import ICarouselBanner from Products.Carousel.config import PROJECTNAME CarouselBannerSchema = link.ATLinkSchema.copy() + atapi.Schema(( atapi.ImageField( 'image', required=False, storage=atapi.AnnotationStorage(), languageIndependent=True, max_size=zconf.ATNewsItem.max_image_dimension, sizes={}, validators=(('isNonEmptyFile', V_REQUIRED), ('checkNewsImageMaxSize', V_REQUIRED)), widget=atapi.ImageWidget(description=_( 'This image will be shown when this banner is active.'), label=_('Image'), show_content_type=False)), atapi.StringField('imageUrl', required=False, searchable=False, default="http://", widget=atapi.StringWidget(description=_( 'Instead of uploading an image, you may enter' ' the URL of an image hosted on another server.'), label=_('Image URL'), maxlength='511')), atapi.TextField( 'text', required=False, validators=('isTidyHtmlWithCleanup', ),