Exemple #1
0
    def testWidgetAllowedTypesField(self):
        from zope.interface import Interface, implements
        from plone.app.textfield import RichText
        from zope.publisher.browser import TestRequest
        from Products.CMFCore.PortalContent import PortalContent
        from plone.app.textfield.widget import RichTextWidget
        from z3c.form.widget import FieldWidget

        class IWithText(Interface):

            text = RichText(title=u"Text",
                            default_mime_type='text/structured',
                            output_mime_type='text/html',
                            allowed_mime_types=('text/structured',
                                                'text/html'))

        class Context(PortalContent):
            implements(IWithText)

            text = None

        request = TestRequest()

        widget = FieldWidget(IWithText['text'], RichTextWidget(request))
        widget.update()

        self.portal['portal_properties']['site_properties']._setPropValue(
            'forbidden_contenttypes', ['text/structured'])

        allowed = widget.allowedMimeTypes()
        self.failUnless('text/html' in allowed)
        self.failUnless('text/structured' in allowed)
Exemple #2
0
    def testWidgetAllowedTypesField(self):
        from zope.interface import Interface, implementer
        from plone.app.textfield import RichText
        from zope.publisher.browser import TestRequest
        from Products.CMFCore.PortalContent import PortalContent
        from plone.app.textfield.widget import RichTextWidget
        from z3c.form.widget import FieldWidget

        class IWithText(Interface):

            text = RichText(
                title=u"Text",
                default_mime_type='text/structured',
                output_mime_type='text/html',
                allowed_mime_types=(
                    'text/structured',
                    'text/html'))

        @implementer(IWithText)
        class Context(PortalContent):

            text = None

        request = TestRequest()

        widget = FieldWidget(IWithText['text'], RichTextWidget(request))
        widget.update()

        self.portal['portal_properties']['site_properties']._setPropValue(
            'forbidden_contenttypes',
            ['text/structured'])

        allowed = widget.allowedMimeTypes()
        self.failUnless('text/html' in allowed)
        self.failUnless('text/structured' in allowed)