예제 #1
0
class ILinkTile(IPersistentCoverTile):

    title = schema.TextLine(
        title=_(u'Title'),
        required=False,
    )

    description = schema.Text(
        title=_(u'Description'),
        required=False,
    )

    image = NamedImage(
        title=_(u'Image'),
        required=False,
    )

    remote_url = schema.TextLine(
        title=_(u'URL'),
        required=False,
    )

    uuid = schema.TextLine(
        title=_(u'UUID'),
        required=False,
        readonly=True,  # the field can not be edited or configured
    )
예제 #2
0
class IListTile(IPersistentCoverTile):

    uuids = schema.List(title=u'Item uuids',
                        value_type=schema.TextLine(),
                        readonly=True)

    title = schema.TextLine(title=_(u'Title'), required=False, readonly=True)

    description = schema.Text(title=_(u'Description'),
                              required=False,
                              readonly=True)

    image = NamedImage(title=_(u'Image'), required=False, readonly=True)

    def results():
        """
        This method return a list of the objects in uuids
        """

    def populate_with_object(obj):
        """
        This method will take a CT and will append its uid to uuids
        """

    def delete():
        """
        This method removes the persistent data created for this tile
        """

    def accepted_ct():
        """
예제 #3
0
class CustomEditForm(DefaultEditForm):
    """Standard tile edit form, which is wrapped by DefaultEditView (see
    below).

    This form is capable of rendering the fields of any tile schema as defined
    by an ITileType utility.
    """
    def update(self):
        super(CustomEditForm, self).update()

        typeName = self.tileType.__name__
        tileId = self.tileId

        tile = self.context.restrictedTraverse('@@{0}/{1}'.format(
            typeName, tileId))

        if not tile.isAllowedToEdit():
            raise Unauthorized("You are not allowed to add this kind of tile")

    @button.buttonAndHandler(_('Save'), name='save')
    def handleSave(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        typeName = self.tileType.__name__

        # Traverse to a new tile in the context, with no data
        tile = self.context.restrictedTraverse('@@{0}/{1}'.format(
            typeName, self.tileId))

        dataManager = ITileDataManager(tile)
        # We need to check first for existing content in order to not loose
        # fields that weren't sent with the form.
        old_data = dataManager.get()
        for item in data:
            #            if data[item] is not None:
            old_data[item] = data[item]

        dataManager.set(old_data)

        # Look up the URL - we need to do this after we've set the data to
        # correctly account for transient tiles
        tileURL = absoluteURL(tile, self.request)
        notify(ObjectModifiedEvent(tile))

        # Get the tile URL, possibly with encoded data
        IStatusMessage(self.request).addStatusMessage(_(u"Tile saved", ),
                                                      type=u'info')

        self.request.response.redirect(tileURL)

    @button.buttonAndHandler(_(u'Cancel'), name='cancel')
    def handleCancel(self, action):
        tileDataJson = {}
        tileDataJson['action'] = "cancel"
        url = self.request.getURL()
        url = appendJSONData(url, 'tiledata', tileDataJson)
        self.request.response.redirect(url)
예제 #4
0
class IEmbedTile(IPersistentCoverTile):

    embed = schema.Text(
        title=_(u'Embedding code'),
        required=False,
    )

    title = schema.TextLine(
        title=_(u'Title'),
        required=False,
    )

    description = schema.Text(
        title=_(u'Description'),
        required=False,
    )

    def get_embedding_code():
        """ Returns the embed code stored in the tile.
        """

    def get_title():
        """ Returns the title stored in the tile.
        """

    def get_description():
        """ Returns the description stored in the tile.
예제 #5
0
class IListTile(IPersistentCoverTile):

    uuids = schema.List(
        title=_(u'Elements'),
        value_type=schema.TextLine(),
        required=False,
    )

    title = schema.TextLine(
        title=_(u'Title'),
        required=False,
        readonly=True,
    )

    description = schema.Text(
        title=_(u'Description'),
        required=False,
        readonly=True,
    )

    image = NamedImage(
        title=_(u'Image'),
        required=False,
        readonly=True,
    )
예제 #6
0
class IFileTile(IPersistentCoverTile):

    title = schema.TextLine(
        title=_(u'Title'),
        required=False,
    )

    description = schema.Text(
        title=_(u'Description'),
        required=False,
    )

    image = NamedImage(
        title=_(u'Image'),
        required=False,
    )

    download = schema.TextLine(
        title=_(u'Download link'),
        required=False,
        readonly=True,  # the field can not be edited or configured
    )

    uuid = schema.TextLine(
        title=_(u'UUID'),
        required=False,
        readonly=True,
    )

    def get_title():
        """ Returns the title stored in the tile.
        """

    def get_description():
        """ Returns the description stored in the tile.
        """

    def get_image():
        """ Returns the image stored in the tile.
        """

    def download_widget():
        """ Returns a download link for the file associated with the tile.
        """

    def get_date():
        """ Returns the date of the file associated with the tile.
        """

    def populate_with_object(obj):
        """ Takes a File object as parameter, and it will store the content of
        its fields into the tile.
        """

    def delete():
        """ Removes the persistent data created for the tile.
예제 #7
0
class IBackgroundImage(model.Schema):

    """Adds the possibility of having a background image on the item."""

    background_image = NamedBlobImage(
        title=_(u'Background image'),
        description=_(
            u'Sets the background image to be used on the item. '
            u'For accessibility reasons, you should not use background images as the sole method of conveying important information.',
        ),
        required=False,
    )
예제 #8
0
class IListTile(IPersistentCoverTile):

    uuids = schema.List(
        title=_(u'Elements'),
        value_type=schema.TextLine(),
        required=False,
    )
    form.omitted('uuids')

    # XXX: this field should be used to replace the 'limit' attribute
    form.omitted('count')
    form.no_omit(IDefaultConfigureForm, 'count')
    count = schema.Int(
        title=_(u'Number of items to display'),
        required=False,
        default=5,
    )

    form.omitted('title')
    form.no_omit(IDefaultConfigureForm, 'title')
    title = schema.TextLine(
        title=_(u'Title'),
        required=False,
    )

    form.omitted('description')
    form.no_omit(IDefaultConfigureForm, 'description')
    description = schema.Text(
        title=_(u'Description'),
        required=False,
    )

    form.omitted('image')
    form.no_omit(IDefaultConfigureForm, 'image')
    image = NamedBlobImage(
        title=_(u'Image'),
        required=False,
    )

    form.omitted('date')
    form.no_omit(IDefaultConfigureForm, 'date')
    date = schema.Datetime(
        title=_(u'Date'),
        required=False,
    )

    tile_title = schema.TextLine(title=_(u'Tile Title'), required=False)
    form.omitted('tile_title')
    form.no_omit(ITileEditForm, 'tile_title')

    more_link = schema.TextLine(title=_('Show more... link'), required=False)
    form.omitted('more_link')
    form.no_omit(ITileEditForm, 'more_link')
    form.widget(more_link='collective.cover.tiles.edit_widgets.more_link.MoreLinkFieldWidget')

    more_link_text = schema.TextLine(title=_('Show more... link text'), required=False)
    form.omitted('more_link_text')
    form.no_omit(ITileEditForm, 'more_link_text')
class CoverSettingsEditForm(controlpanel.RegistryEditForm):
    schema = ICoverSettings
    label = _(u'Cover Settings')
    description = _(u'Settings for the collective.cover package')

    #def updateFields(self):
        #super(CoverSettingsEditForm, self).updateFields()
        #self.fields['layouts'].widgetFactory = TextLinesFieldWidget

    def updateWidgets(self):
        super(CoverSettingsEditForm, self).updateWidgets()
        self.widgets['searchable_content_types'].style = u'min-width: 200px;'
예제 #10
0
class IPFGTile(IPersistentCoverTile):

    title = schema.TextLine(
        title=_(u'Title'),
        required=False,
    )

    description = schema.Text(
        title=_(u'Description'),
        required=False,
    )

    form.omitted('uuid')
    uuid = schema.TextLine(title=u'Collection uuid', readonly=True)
예제 #11
0
class IVideoCarouselTile(IListTile):
    """A tile that shows a carousel of videos."""

    tile_description = schema.Text(title=_(u'Tile Description'),
                                   required=False)
    form.omitted('tile_description')
    form.no_omit(ITileEditForm, 'tile_description')

    switch_text = schema.TextLine(title=_(u'Switch Text'), required=False)
    form.omitted('switch_text')
    form.no_omit(ITileEditForm, 'switch_text')

    form.no_omit(ITileEditForm, 'uuids')
    form.widget(uuids=TextLinesSortableFieldWidget)
예제 #12
0
파일: embed.py 프로젝트: eea/bise.datatiles
class IEmbedTile(IPersistentCoverTile):

    write_permission(embed='collective.cover.EmbedCode')
    embed = schema.Text(
        title=_(u'Embedding code'),
        required=False,
    )

    title = schema.TextLine(
        title=_(u'Title'),
        required=False,
    )

    description = RichText(title=u'Description', required=False)
예제 #13
0
class IEmbedAppTile(IPersistentCoverTile):

    embed = schema.Text(
        title=_(u'Embedding view'),
        required=False,
    )

    title = schema.TextLine(
        title=_(u'Title'),
        required=False,
    )

    description = schema.Text(
        title=_(u'Description'),
        required=False,
    )
예제 #14
0
    def populate_with_object(self, obj):
        super(PagedCarouselTile, self).populate_with_object(obj)  # check permission

        type_display = self.data.get('type_display', None)
        content_type = self.data.get('content_type', None)

        if (type_display in ['more_access', 'recent'] and obj.portal_type != 'Folder') \
           or (type_display == 'featured' and obj.portal_type != content_type):
            raise Unauthorized(
                _('You are not allowed to add content to this tile'))

        uuid = IUUID(obj, None)
        data_mgr = ITileDataManager(self)

        old_data = data_mgr.get()
        if data_mgr.get()['uuids']:
            uuids = data_mgr.get()['uuids']
            if type(uuids) != list:
                uuids = [uuid]
            elif uuid not in uuids:
                uuids.append(uuid)
            old_data['uuids'] = uuids
        else:
            old_data['uuids'] = [uuid]
        data_mgr.set(old_data)
예제 #15
0
    def handleSave(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        typeName = self.tileType.__name__

        # Traverse to a new tile in the context, with no data
        tile = self.context.restrictedTraverse('@@%s/%s' % (typeName, self.tileId,))

        dataManager = ITileDataManager(tile)
        # We need to check first for existing content in order to not loose
        # fields that weren't sent with the form.
        old_data = dataManager.get()
        for item in data:
            if data[item] is not None:
                old_data[item] = data[item]

        dataManager.set(old_data)

        # Look up the URL - we need to do this after we've set the data to
        # correctly account for transient tiles
        tileURL = absoluteURL(tile, self.request)
        notify(ObjectModifiedEvent(tile))

        # Get the tile URL, possibly with encoded data
        IStatusMessage(self.request).addStatusMessage(_(u"Tile saved",), type=u'info')

        self.request.response.redirect(tileURL)
예제 #16
0
class IContentBodyTile(IPersistentCoverTile):

    uuid = schema.TextLine(
        title=_(u'UUID'),
        required=False,
        readonly=True,
    )
예제 #17
0
    def handleSave(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        # Traverse to a new tile in the context, with no data
        typeName = self.tileType.__name__
        tile = self.context.restrictedTraverse('@@{0}/{1}'.format(typeName, self.tileId))

        # We need to check first for existing content in order not not loose
        # fields that weren't sent with the form
        dataManager = ITileDataManager(tile)
        old_data = dataManager.get()
        for item in data:
            old_data[item] = data[item]
        dataManager.set(old_data)

        # notify about modification
        notify(ObjectModifiedEvent(tile))
        api.portal.show_message(_(u'Tile saved'), self.request, type='info')

        # Look up the URL - we need to do this after we've set the data to
        # correctly account for transient tiles
        tileURL = absoluteURL(tile, self.request)
        self.request.response.redirect(tileURL)
    def handleSave(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        typeName = self.tileType.__name__

        # Traverse to a new tile in the context, with no data
        tile = self.context.restrictedTraverse('@@%s/%s' % (typeName, self.tileId,))

        tile_conf_adapter = getMultiAdapter((self.context, self.request, tile),
                                            ITilesConfigurationScreen)

        tile_conf_adapter.set_configuration(data)

        #dataManager = ITileDataManager(tile)
        #dataManager.set(data)

        # Look up the URL - We need to redirect to the layout view, since
        # there's the only way from where a user would access the configuration
        contextURL = absoluteURL(tile.context, self.request)

        layoutURL = '%s/layoutedit' % contextURL

        notify(ObjectModifiedEvent(tile))

        # Get the tile URL, possibly with encoded data
        IStatusMessage(self.request).addStatusMessage(_(u"Tile configuration saved.",), type=u'info')

        self.request.response.redirect(layoutURL)
예제 #19
0
class PFGTile(PersistentCoverTile):

    index = ViewPageTemplateFile('templates/pfg.pt')

    is_editable = True
    is_configurable = True
    short_name = _(u'msg_short_name_pfg', default=u'FormGen')

    def body(self):
        body = ''
        uuid = self.data.get('uuid', None)
        try:
            obj = uuid and uuidToObject(uuid)
            if obj is not None:
                body = obj.restrictedTraverse('fg_embedded_view_p3')()
        except Unauthorized:
            body = ''
        return body

    def populate_with_object(self, obj):
        super(PFGTile, self).populate_with_object(obj)

        data = {
            'title': safe_unicode(obj.Title()),
            'description': safe_unicode(obj.Description()),
            'uuid': IUUID(obj),
        }

        data_mgr = ITileDataManager(self)
        data_mgr.set(data)

    def accepted_ct(self):
        """Return 'FormFolder' as the only content type accepted in the tile.
        """
        return ['FormFolder']
예제 #20
0
class ISearchContentsTile(IPersistentCoverTile):
    """
    """

    search_on_context = schema.Bool(
        title=_(u'Buscar objetos no contexto'),
        description=
        _(u'Se marcado a busca de objetos será apenas no contexto do tile, caso contrário em todo portal'
          ),
        default=True,
    )

    portal_type_selected = schema.Choice(title=_(u'Tipo de conteúdo'),
                                         vocabulary=portal_types,
                                         required=True,
                                         default='ArquivoBiblioteca')
예제 #21
0
class IBannerTile(IPersistentCoverTile):

    title = schema.TextLine(
        title=_(u'Title'),
        required=False,
    )

    image = field.NamedBlobImage(
        title=_(u'Image'),
        required=False,
    )

    remote_url = schema.TextLine(
        title=_(u'URL'),
        required=False,
    )
    def handleCancel(self, action):
        api.portal.show_message(
            _(u'Tile configuration cancelled.'), self.request, type='info')

        contextURL = absoluteURL(self.context, self.request)
        layoutURL = '{0}/layoutedit'.format(contextURL)
        self.request.response.redirect(layoutURL)
예제 #23
0
    def handleSave(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        typeName = self.tileType.__name__

        # Traverse to a new tile in the context, with no data
        tile = self.context.restrictedTraverse('@@%s/%s' % (typeName, self.tileId,))

        tile_conf_adapter = getMultiAdapter((self.context, self.request, tile),
                                            ITilesConfigurationScreen)

        tile_conf_adapter.set_configuration(data)

        #dataManager = ITileDataManager(tile)
        #dataManager.set(data)

        # Look up the URL - We need to redirect to the layout view, since
        # there's the only way from where a user would access the configuration
        contextURL = absoluteURL(tile.context, self.request)

        layoutURL = '%s/layoutedit' % contextURL

        notify(ObjectModifiedEvent(tile))

        # Get the tile URL, possibly with encoded data
        IStatusMessage(self.request).addStatusMessage(_(u"Tile configuration saved.",), type=u'info')

        self.request.response.redirect(layoutURL)
    def handleSave(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        # Traverse to a new tile in the context, with no data
        typeName = self.tileType.__name__
        tile = self.context.restrictedTraverse('@@{0}/{1}'.format(
            typeName, self.tileId))
        tile_conf_adapter = getMultiAdapter((self.context, self.request, tile),
                                            ITilesConfigurationScreen)
        tile_conf_adapter.set_configuration(data)

        # notify about modification
        notify(ObjectModifiedEvent(self.context))
        api.portal.show_message(_(u'Tile configuration saved.'),
                                self.request,
                                type='info')

        # Look up the URL - We need to redirect to the layout view, since
        # there's the only way from where a user would access the configuration
        contextURL = absoluteURL(tile.context, self.request)
        layoutURL = '{0}/layoutedit'.format(contextURL)
        self.request.response.redirect(layoutURL)
예제 #25
0
    def populate_with_object(self, obj):
        super(PagedCarouselTile, self).populate_with_object(obj)  # check permission
        
        type_display = self.data.get('type_display', None)
        content_type = self.data.get('content_type', None)
        
        if (type_display in ['more_access', 'recent'] and obj.portal_type != 'Folder') \
           or (type_display == 'featured' and obj.portal_type != content_type):
            raise Unauthorized(
                _('You are not allowed to add content to this tile'))
        
        uuid = IUUID(obj, None)
        data_mgr = ITileDataManager(self)

        old_data = data_mgr.get()
        if data_mgr.get()['uuids']:
            uuids = data_mgr.get()['uuids']
            if type(uuids) != list:
                uuids = [uuid]
            elif uuid not in uuids:
                uuids.append(uuid)
            old_data['uuids'] = uuids
        else:
            old_data['uuids'] = [uuid]
        data_mgr.set(old_data)
예제 #26
0
    def replace_with_objects(self, obj):
        if not self.isAllowedToEdit():
            raise Unauthorized(
                _("You are not allowed to add content to "
                  "this tile"))

        notify(ObjectModifiedEvent(self))
예제 #27
0
class IPFGTile(IPersistentCoverTile):

    title = schema.TextLine(
        title=_(u'Title'),
        required=False,
    )

    description = schema.Text(
        title=_(u'Description'),
        required=False,
    )

    uuid = schema.TextLine(
        title=_(u'UUID'),
        required=False,
        readonly=True,
    )
예제 #28
0
class IRefresh(model.Schema):
    """Reload the current page after a certain amount of time."""

    model.fieldset('settings', fields=['enable_refresh', 'ttl'])

    enable_refresh = schema.Bool(
        title=_(u'Enable refresh'),
        description=_(u'Enable refresh of the current page.'),
        default=False,
    )

    ttl = schema.Int(
        title=_(u'Time to live'),
        description=_(
            u'Number of seconds after which to reload the current page.'),
        default=300,
    )
class IEasyliderTile(Interface):
    """  settings for easyslider tile  """

    title = schema.TextLine(
        title=_(u'Title'),
        required=False,
    )

    description = schema.Text(
        title=_(u'Description'),
        required=False,
    )

    slider = schema.Text(
        title=_(u'Path to slider'),
        required=True,
    )
예제 #30
0
class ICarouselTile(IListTile):
    """
    """

    autoplay = schema.Bool(
        title=_(u'Auto play'),
        required=False,
        default=True,
    )

    form.widget(uuids=TextLinesSortableFieldWidget)
    uuids = schema.List(
        title=_(u'Elements'),
        value_type=schema.TextLine(),
        required=False,
        readonly=False,
    )
예제 #31
0
class CarouselTile(ListTile):

    implements(ICarouselTile)

    index = ViewPageTemplateFile('templates/carousel.pt')
    is_configurable = True
    is_editable = True
    short_name = _(u'msg_short_name_carousel', default=u'Carousel')

    def populate_with_object(self, obj):
        super(CarouselTile, self).populate_with_object(obj)  # check permission
        try:
            scale = obj.restrictedTraverse('@@images').scale('image')
        except:
            scale = None
        if not scale:
            return
        self.set_limit()
        uuid = IUUID(obj, None)
        data_mgr = ITileDataManager(self)

        old_data = data_mgr.get()
        if data_mgr.get()['uuids']:
            uuids = data_mgr.get()['uuids']
            if type(uuids) != list:
                uuids = [uuid]
            elif uuid not in uuids:
                uuids.append(uuid)

            old_data['uuids'] = uuids[:self.limit]
        else:
            old_data['uuids'] = [uuid]
        data_mgr.set(old_data)

    def autoplay(self):
        if self.data['autoplay'] is None:
            return True  # default value

        return self.data['autoplay']

    def init_js(self):
        if self.is_empty():
            # Galleria will display scary error messages when it
            # cannot find its <div>.  So don't start galleria unless
            # the <div> is there and has some items in it.
            return ''

        return """
$(function() {{
    Galleria.loadTheme("++resource++collective.cover/galleria-theme/galleria.cover_theme.js");
    Galleria.run('#galleria-{0} .galleria-inner');

    if($('body').hasClass('template-view')) {{
        Galleria.configure({{ autoplay: {1} }});
    }};
}});
""".format(self.id,
           str(self.autoplay()).lower())
예제 #32
0
class IBannerTile(IPersistentCoverTile):

    title = schema.TextLine(
        title=_(u'Title'),
        required=False,
    )

    form.omitted(IDefaultConfigureForm, 'remote_url')
    remote_url = schema.URI(
        title=_(u'label_remote_url', default=u'URL'),
        description=_(u'help_remote_url', default=u'Use absolute links only.'),
        required=False,
    )

    image = field.NamedBlobImage(
        title=_(u'Image'),
        required=False,
    )

    form.omitted(IDefaultConfigureForm, 'alt_text')
    alt_text = schema.TextLine(
        title=_(u'label_alt_text', default=u'Alternative Text'),
        description=_(
            u'help_alt_text',
            default=
            u'Provides a textual alternative to non-text content in web pages.'
        ),  # noqa E501
        required=False,
    )

    uuid = schema.TextLine(  # FIXME: this must be schema.ASCIILine()
        title=_(u'UUID'),
        required=False,
        readonly=True,
    )
예제 #33
0
    def populate_with_object(self, obj):
        super(CollectionTile, self).populate_with_object(obj)  # check permission

        if obj.portal_type in self.accepted_ct():
            header = safe_unicode(obj.Title())  # use collection's title as header
            footer = _(u"More…")  # XXX: can we use field's default?

            data_mgr = ITileDataManager(self)
            data_mgr.set({"header": header, "footer": footer, "uuid": IUUID(obj)})
예제 #34
0
    def populate_with_object(self, obj):
        super(AgendaTile, self).populate_with_object(obj)  # check permissions

        if obj.portal_type in self.accepted_ct():
            title = _(u'Agenda do {0}').format(obj.autoridade)
            link_url = obj.absolute_url()
            link_text = _(u'Acesse a agenda do {0}').format(obj.autoridade)
            uuid = IUUID(obj, None)
            data_mgr = ITileDataManager(self)
            data_mgr.set({
                'title': title,
                'link_url': link_url,
                'link_text': link_text,
                'period': True,
                'lastest_update': True,
                'collection_events': True,
                'agenda_tile_footer': True,
                'uuid': uuid
            })
예제 #35
0
    def update(self):
        super(CustomEditForm, self).update()

        typeName = self.tileType.__name__
        tileId = self.tileId

        tile = self.context.restrictedTraverse('@@{0}/{1}'.format(typeName, tileId))

        if not tile.isAllowedToEdit():
            raise Unauthorized(
                _(u'You are not allowed to add this kind of tile'))
예제 #36
0
    def update(self):
        super(CustomEditForm, self).update()

        tile = self.getTile()

        if (not IDeferSecurityCheck.providedBy(self.request) and
                not tile.isAllowedToEdit()):
            # if IDeferSecurityCheck is provided by the request,
            # we're not going to worry about security, perms not set up yet
            raise Unauthorized(
                _(u'You are not allowed to add this kind of tile'))
예제 #37
0
    def handleCancel(self, action):
        contextURL = absoluteURL(self.context, self.request)
        layoutURL = '%s/layoutedit' % contextURL

        # XXX: We need to fire a notification ?
        #notify(ObjectModifiedEvent(tile))

        # Get the tile URL, possibly with encoded data
        IStatusMessage(self.request).addStatusMessage(_(u"Tile configuration cancelled.",), type=u'info')

        self.request.response.redirect(layoutURL)
예제 #38
0
    def populate_with_object(self, obj):
        super(CollectionTile, self).populate_with_object(obj)  # check permission

        if obj.portal_type in self.accepted_ct():
            header = safe_unicode(obj.Title())  # use collection's title as header
            footer = _(u'More…')  # XXX: can we use field's default?
            uuid = IUUID(obj)

            data_mgr = ITileDataManager(self)
            data_mgr.set({
                'header': header,
                'footer': footer,
                'uuid': uuid,
            })
예제 #39
0
    def replace_with_objects(self, uids):
        if not self.isAllowedToEdit():
            raise Unauthorized(
                _('You are not allowed to add content to this tile'))
        self.set_limit()
        data_mgr = ITileDataManager(self)
        old_data = data_mgr.get()
        if type(uids) == list:
            old_data['uuids'] = [i for i in uids][:self.limit]
        else:
            old_data['uuids'] = [uids]

        data_mgr.set(old_data)
        notify(ObjectModifiedEvent(self))
예제 #40
0
    def replace_with_uuids(self, uuids):
        """ Replaces the whole list of items with a new list of items

        :param uuids: The list of objects' UUIDs to be used
        :type uuids: List of strings
        """
        if not self.isAllowedToEdit():
            raise Unauthorized(
                _('You are not allowed to add content to this tile'))
        data_mgr = ITileDataManager(self)
        old_data = data_mgr.get()
        # Clean old data
        old_data['uuids'] = dict()
        data_mgr.set(old_data)
        # Repopulate with clean list
        self.populate_with_uuids(uuids)
예제 #41
0
    def populate_with_uids(self, uuids):
        """ Add a list of elements to the list of items. This method will
        append new elements to the already existing list of items

        :param uuids: The list of objects' UUIDs to be used
        :type uuids: List of strings
        """
        if not self.isAllowedToEdit():
            raise Unauthorized(
                _('You are not allowed to add content to this tile'))
        self.set_limit()
        data_mgr = ITileDataManager(self)

        old_data = data_mgr.get()
        if old_data['uuids'] is None:
            # If there is no content yet, just assign an empty dict
            old_data['uuids'] = dict()

        uuids_dict = old_data.get('uuids')
        if not isinstance(uuids_dict, dict):
            # Make sure this is a dict
            uuids_dict = old_data['uuids'] = dict()

        if uuids_dict and len(uuids_dict) > self.limit:
            # Do not allow adding more objects than the defined limit
            return

        order_list = [int(val.get('order', 0))
                      for key, val in uuids_dict.items()]
        if len(order_list) == 0:
            # First entry
            order = 0
        else:
            # Get last order position and increment 1
            order_list.sort()
            order = order_list.pop() + 1

        for uuid in uuids:
            if uuid not in uuids_dict.keys():
                entry = dict()
                entry[u'order'] = unicode(order)
                uuids_dict[uuid] = entry
                order += 1

        old_data['uuids'] = uuids_dict
        data_mgr.set(old_data)
        notify(ObjectModifiedEvent(self))
예제 #42
0
    def populate_with_uids(self, uuids):
        if not self.isAllowedToEdit():
            raise Unauthorized(
                _('You are not allowed to add content to this tile'))
        self.set_limit()
        data_mgr = ITileDataManager(self)

        old_data = data_mgr.get()
        for uuid in uuids:
            if old_data['uuids']:
                if type(old_data['uuids']) != list:
                    old_data['uuids'] = [uuid]
                elif uuid not in old_data['uuids']:
                    old_data['uuids'].append(uuid)
            else:
                old_data['uuids'] = [uuid]
        data_mgr.set(old_data)
        notify(ObjectModifiedEvent(self))
예제 #43
0
    def handleSave(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        tile = self.getTile()

        # We need to check first for existing content in order not not loose
        # fields that weren't sent with the form
        dataManager = ITileDataManager(tile)
        old_data = dataManager.get()
        for item in data:
            old_data[item] = data[item]
        dataManager.set(old_data)

        api.portal.show_message(_(u'Tile saved'), self.request, type='info')

        # Look up the URL - we need to do this after we've set the data to
        # correctly account for transient tiles
        tileURL = absoluteURL(tile, self.request)
        self.request.response.redirect(tileURL)
    def handleSave(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        # Traverse to a new tile in the context, with no data
        typeName = self.tileType.__name__
        tile = self.context.restrictedTraverse('@@{0}/{1}'.format(typeName, self.tileId))
        tile_conf_adapter = getMultiAdapter(
            (self.context, self.request, tile), ITilesConfigurationScreen)
        tile_conf_adapter.set_configuration(data)

        # notify about modification
        notify(ObjectModifiedEvent(tile))
        api.portal.show_message(
            _(u'Tile configuration saved.'), self.request, type='info')

        # Look up the URL - We need to redirect to the layout view, since
        # there's the only way from where a user would access the configuration
        contextURL = absoluteURL(tile.context, self.request)
        layoutURL = '{0}/layoutedit'.format(contextURL)
        self.request.response.redirect(layoutURL)
예제 #45
0
from collective.cover.tiles.base import IPersistentCoverTile, PersistentCoverTile
from plone.app.uuid.utils import uuidToCatalogBrain
from plone.tiles.interfaces import ITileDataManager
from plone.uuid.interfaces import IUUID
from zope import schema
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm

from liberiun.govcontent.content.arquivo_biblioteca import ArquivoBiblioteca
from liberiun.govtiles.models.accesspage import AccessPage


FILE_CONTENT_TYPES = ArquivoBiblioteca.dict_file_content_types


types_display = SimpleVocabulary(
    [SimpleTerm(value=u'more_access', title=_(u'Mais acessados')),
     SimpleTerm(value=u'recent', title=_(u'Recentes')),
     SimpleTerm(value=u'featured', title=_(u'Destaques'))]
    )

content_types = SimpleVocabulary(
    [SimpleTerm(value=u'ArquivoBiblioteca', title=_(u'Arquivos Biblioteca')),
     SimpleTerm(value=u'BoaPratica', title=_(u'Boas Práticas')),]
    )

class IPagedCarouselTile(IPersistentCoverTile):
    """
    """
    
    type_display = schema.Choice(
        title=_(u'Critério de exibição'),
예제 #46
0
from collective.cover import _
from collective.cover.tiles.base import IPersistentCoverTile, PersistentCoverTile
from zope import schema
from zope.component import queryUtility
from zope.schema.interfaces import IVocabularyFactory
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm

from liberiun.govcontent.content.arquivo_biblioteca import ArquivoBiblioteca
from liberiun.govtiles.models.searchterms import SearchTerms


FILE_CONTENT_TYPES = ArquivoBiblioteca.dict_file_content_types

portal_types = SimpleVocabulary(
    [
     SimpleTerm(value=u'ArquivoBiblioteca', title=_(u'Arquivos Biblioteca')),
     SimpleTerm(value=u'BoaPratica', title=_(u'Boas Práticas')),]
    )

class ISearchContentsTile(IPersistentCoverTile):
    """
    """
    
    portal_type_selected = schema.Choice(
        title=_(u'Tipo de conteúdo'),
        vocabulary=portal_types,
        required=True,
    )
    
class SearchContentsTile(PersistentCoverTile):
    is_configurable = True
예제 #47
0
def validate_ttl(value):
    if value <= 0:
        raise Invalid(_(u'Value must be greater than zero.'))
예제 #48
0
 def remove_item(self, uid):
     if not self.isAllowedToEdit():
         raise Unauthorized(
             _('You are not allowed to remove content of this tile'))
예제 #49
0
 def populate_with_object(self, obj):
     if not self.isAllowedToEdit():
         raise Unauthorized(
             _('You are not allowed to add content to this tile'))
예제 #50
0
 def validate(self, value):
     """Validate the value on time to live input"""
     if value <= 0:
         raise Invalid(_(u'Value must be greater than zero.'))
예제 #51
0
    def replace_with_objects(self, obj):
        if not self.isAllowedToEdit():
            raise Unauthorized(_("You are not allowed to add content to "
                                 "this tile"))

        notify(ObjectModifiedEvent(self))
 def label(self):
     return _(u'Configure ${name}', mapping={'name': self.tileType.title})