예제 #1
0
class IExistingTileSchema(IContentTileSchema):

    form.order_before(title='use_query')
    title = schema.TextLine(title=u'Title heading',
                            description=u'Will be omitted if blank',
                            required=False,
                            default=u'')

    form.widget('display_fields', CheckBoxFieldWidget)
    display_fields = schema.Tuple(
        title=u'Display fields',
        description=u'Fields that should show from the content',
        default=('title', 'image', 'description'),
        value_type=schema.Choice(vocabulary=SimpleVocabulary([
            SimpleTerm('title', 'title', u'Title'),
            SimpleTerm('image', 'image', u'Image'),
            SimpleTerm('description', 'description', u'Overview/Summary'),
            SimpleTerm('date', 'date', u'Date'),
        ])))

    truncate_count = schema.Int(
        title=u'Overview/Summary Truncate',
        description=u'Number of words to truncate the overview/summary to',
        required=False,
        default=18)

    image_display_type = schema.Choice(
        title=u'Image display type',
        description=u'Does not apply to all display types',
        required=True,
        default=defaults.get('existing_tile_image_displaytype', u'landscape'),
        vocabulary=SimpleVocabulary([
            SimpleTerm('landscape', 'landscape', u'Landscape'),
            SimpleTerm('portrait', 'portrait', u'Portrait'),
            SimpleTerm('square', 'square', u'Square')
        ]))

    form.widget('display_type',
                PreviewSelectFieldWidget,
                tile_name=DISPLAY_TYPE_KEY)
    display_type = schema.Choice(title=u"Display Type",
                                 source=TileViewsSource(DISPLAY_TYPE_KEY),
                                 default=defaults.get(
                                     'existing_tile_displaytype', u'default'))

    form.widget(override_focal_point=FocalPointSelectFieldWidget)
    override_focal_point = schema.Text(title=u'Override Focal point',
                                       default=u'',
                                       required=False)
예제 #2
0
class IGalleryTileSchema(IImagesTileSchema):

    form.widget('display_type', PreviewSelectFieldWidget, tile_name='gallery')
    display_type = schema.Choice(title=u"Display Type",
                                 source=TileViewsSource('gallery'),
                                 default=defaults.get(
                                     'gallery_tile_displaytype', u'default'))
예제 #3
0
class IQueryListingTileSchema(model.Schema):

    title = schema.TextLine(
        title=u'Title',
        description=u'Provide title above listing',
        required=False,
        default=None
    )

    form.widget(query=QueryFieldWidget)
    query = schema.List(
        title=u'Base query',
        description=u"This query can be customized based on user selection",
        value_type=schema.Dict(value_type=schema.Field(),
                               key_type=schema.TextLine()),
        required=False
    )

    sort_on = schema.TextLine(
        title=u'Sort on',
        description=u"Sort on this index",
        required=False,
        default=defaults.get('querylisting_tile_sort_on', u'effective')
    )

    sort_reversed = schema.Bool(
        title=u'Reversed order',
        description=u'Sort the results in reverse order',
        required=False,
        default=True
    )

    limit = schema.Int(
        title=u'Limit',
        description=u'Limit number of search results',
        required=False,
        default=15,
        min=1,
    )

    form.widget(
        'available_tags',
        AjaxSelectFieldWidget,
        vocabulary='plone.app.vocabularies.Keywords'
    )
    available_tags = schema.Tuple(
        title=u'Tags',
        description=u'Available tags to select from the query widget',
        value_type=schema.TextLine(),
        required=False,
        missing_value=()
    )

    form.widget('display_fields', CheckBoxFieldWidget)
    display_fields = schema.Tuple(
        title=u'Display fields',
        description=u'Fields that should show on the listing',
        default=(
            'image',
            'description'
        ),
        value_type=schema.Choice(
            vocabulary=SimpleVocabulary([
                SimpleTerm('image', 'image', u'Image'),
                SimpleTerm('date', 'date', u'Publication (Effective) Date'),
                SimpleTerm('eventstartend', 'eventstartend', u'Event Start and End'),
                SimpleTerm('description', 'description', u'Overview/Summary')
            ])
        )
    )

    form.widget('display_type', PreviewSelectFieldWidget,
                tile_name='querylisting')
    display_type = schema.Choice(
        title=u"Display Type",
        source=TileViewsSource('querylisting'),
        default=defaults.get('querylisting_tile_displaytype', u'default')
    )
예제 #4
0
파일: image.py 프로젝트: sm2x/castle.cms
class IImageTileSchema(model.Schema):

    model.fieldset('link', label='Link', fields=('link', 'external_link'))

    form.widget(image=ImageRelatedItemFieldWidget)
    image = schema.List(
        title=u"Image",
        description=u"Reference image on the site.",
        required=True,
        default=[],
        value_type=schema.Choice(vocabulary='plone.app.vocabularies.Catalog'))

    @invariant
    def validate_image(data):
        if data.image and len(data.image) != 1:
            raise Invalid("Must select 1 image")
        if data.image:
            utils = getMultiAdapter((getSite(), getRequest()),
                                    name="castle-utils")
            obj = utils.get_object(data.image[0])
            if not obj or obj.portal_type != 'Image':
                raise Invalid('Must provide image file')

    display_type = schema.Choice(
        title=u'Crop Image Options',
        required=True,
        default=defaults.get('image_tile_displaytype', u'fullwidth'),
        vocabulary=SimpleVocabulary([
            SimpleTerm('natural', 'natural',
                       u'Natural (default size, no crop applied)'),
            SimpleTerm(
                'fullwidth', 'fullwidth',
                u'Full width (fit to tile size, no crop applied, adjusts to width of tile)'
            ),
            SimpleTerm('portrait', 'portrait',
                       u'Crop portrait (larger height than width)'),
            SimpleTerm('landscape', 'landscape',
                       u'Crop landscape (larger width than height)'),
            SimpleTerm('short', 'short',
                       u'Crop short (shorter than landscape)'),
            SimpleTerm('square', 'square',
                       u'Crop square (same height and width)'),
        ]))

    scale = schema.Choice(
        title=u'Resolution',
        description=u'Change the resolution of the image that gets served. '
        u'This can safely be left at the default.',
        required=True,
        source=image_scales,
        default=defaults.get('image_tile_scale', u'large'))

    caption = schema.TextLine(
        title=u'Caption',
        description=
        u'The caption shows under the image. This is different than the summary'
        u' field on the image',
        required=False)

    form.widget(override_focal_point=FocalPointSelectFieldWidget)
    override_focal_point = schema.Text(title=u'Override Focal point',
                                       default=u'',
                                       required=False)

    form.widget(link=RelatedItemFieldWidget)
    link = schema.List(
        title=u"Link",
        description=u"Content to link this image to.",
        required=False,
        default=[],
        value_type=schema.Choice(vocabulary='plone.app.vocabularies.Catalog'))

    external_link = schema.TextLine(
        title=u'External Link',
        description=u'If provided, internal link is ignored',
        required=False,
        default=u'')

    @invariant
    def validate_link(data):
        if data.link and len(data.link) != 1:
            raise Invalid("Must select 1 link only")
예제 #5
0
class IGalleryTileSchema(IImagesTileSchema):

    form.widget('display_type', PreviewSelectFieldWidget,
                tile_name='gallery')
    display_type = schema.Choice(
        title=u"Display Type",
        source=TileViewsSource('gallery'),
        default=defaults.get('gallery_tile_displaytype', u'default')
    )

    gallery_height = schema.Choice(
        title=u"Gallery Height",
        default='default',
        vocabulary=SimpleVocabulary([
            SimpleVocabulary.createTerm('small', 'small', 'Small'),
            SimpleVocabulary.createTerm('default', 'default', 'Default'),
            SimpleVocabulary.createTerm('large', 'large', 'Large'),
            SimpleVocabulary.createTerm('x-large', 'x-large', 'X-Large')
        ])
    )

    show_thumbnails = schema.Bool(
        title=u'Show Thumbnails',
        description=(
            u'Display thumbnail images below main gallery image. '
            u'This option is for advanced display types in certain add-ons.Usually, this option has no affect.'
        ),
        missing_value=True,
        required=False,
    )

    show_image_title = schema.Bool(
        title=u'Show Image Title',
        description=(
            u'Display Image Title directly below the main gallery image. '
            u'This option is for advanced display types in certain add-ons. Usually, this option has no affect.'
        ),
        missing_value=True,
        required=False,
    )

    show_image_captions = schema.Bool(
        title=u'Show Image Captions',
        description=(
            u'Display a small caption (the image\'s summary field) below either the image title (if visible) or the main image. '
            u'This option is for advanced display types in certain add-ons. Usually, this option has no affect.'
        ),
        missing_value=True,
        required=False,
    )

    show_image_counter =  schema.Bool(
        title=u'Show Image Counter',
        description=(
            u'Display a small indicator above the main image indicating which image is being viewed (ex: "Image 15 of 22"). '
            u'This option is for advanced display types in certain add-ons. Usually, this option has no affect.'
        ),
        missing_value=False,
        required=False,
    )

    show_link_to_original_image =  schema.Bool(
        title=u'Show Link to Original Image',
        description=(
            u'When the gallery image is highlighted, show a link to the original image. '
            u'This option is for advanced display types in certain add-ons. Usually, this option has no affect.'
        ),
        missing_value=False,
        required=False,
    )
예제 #6
0
파일: video.py 프로젝트: sm2x/castle.cms
class IVideoTileSchema(model.Schema):

    form.widget(video=VideoRelatedItemsFieldWidget)
    video = schema.List(
        title=u"Video file",
        description=u"Reference video file on the site.",
        required=False,
        default=[],
        value_type=schema.Choice(vocabulary='plone.app.vocabularies.Catalog'))

    youtube_url = schema.TextLine(
        title=u'YouTube url',
        description=u'Or provide a YouTube or Vimeo url',
        required=False)

    @invariant
    def validate_video(data):
        if data.video and len(data.video) != 1:
            raise Invalid("Must select 1 video")
        if data.video and data.youtube_url:
            raise Invalid("You can not select both a video and a youtube url")
        if not data.video and not data.youtube_url:
            raise Invalid("Must select a video or a youtube url")
        if data.video:
            utils = getMultiAdapter((getSite(), getRequest()),
                                    name="castle-utils")
            obj = utils.get_object(data.video[0])
            if obj.portal_type != 'Video':
                raise Invalid('Must provide video file')

    form.widget('display_fields', CheckBoxFieldWidget)
    display_fields = schema.Tuple(
        title=u'Display fields',
        description=u'Fields that should show from the content',
        default=(),
        value_type=schema.Choice(vocabulary=SimpleVocabulary([
            SimpleTerm('title', 'title', u'Title'),
            SimpleTerm('description', 'description', u'Overview/Summary'),
            SimpleTerm('date', 'date', u'Date'),
            SimpleTerm('transcript', 'transcript', u'Transcript'),
        ])))

    display_type = schema.Choice(title=u'Display type',
                                 required=True,
                                 default=defaults.get('video_tile_displaytype',
                                                      u'landscape'),
                                 vocabulary=SimpleVocabulary([
                                     SimpleTerm('landscape', 'landscape',
                                                u'Landscape'),
                                     SimpleTerm('square', 'square', u'Square'),
                                     SimpleTerm('fullwidth', 'fullwidth',
                                                u'Full width'),
                                 ]))

    show_controls = schema.Bool(title=u'Show controls', default=True)

    autoplay = schema.Bool(title=u'Autoplay',
                           default=defaults.get('video_tile_autoplay', False,
                                                'bool'))

    loop = schema.Bool(title=u'Loop',
                       default=defaults.get('video_tile_loop', False, 'bool'))