Ejemplo n.º 1
0
    def test_at_tinymcewidget_single_mimetype(self):
        """A RichTextWidget with only one available mimetype should render the
        pattern class directly on itself.
        """
        from Products.Archetypes.Widget import TinyMCEWidget
        widget = TinyMCEWidget()
        rendered = widget.edit(self.portal, self.field, self.request)

        self.assertTrue('<select' not in rendered)
        self.assertTrue('pat-tinymce' in rendered)
        self.assertTrue('data-pat-tinymce' in rendered)
Ejemplo n.º 2
0
    def test_at_tinymcewidget_single_mimetype(self):
        """A RichTextWidget with only one available mimetype should render the
        pattern class directly on itself.
        """
        from Products.Archetypes.Widget import TinyMCEWidget
        widget = TinyMCEWidget()
        rendered = widget.edit(self.portal, self.field, self.request)

        self.assertTrue('<select' not in rendered)
        self.assertTrue('pat-tinymce' in rendered)
        self.assertTrue('data-pat-tinymce' in rendered)
Ejemplo n.º 3
0
 def test_widget(self):
     # BBB: portal_tinymce is removed in Plone 5. Remove this check when
     # Plone < 5 is no longer supported.
     utility = getToolByName(self.portal, 'portal_tinymce', None)
     if not utility:
         return
     from Products.Archetypes.Widget import TinyMCEWidget
     widget = TinyMCEWidget()
     self.field.widget = widget
     base_args = widget._base_args(self.portal, self.field, self.request)
     self.assertEqual(base_args['name'], 'fieldname')
     self.assertEqual(base_args['value'], 'fieldvalue')
     self.assertEqual(base_args['pattern'], 'tinymce')
Ejemplo n.º 4
0
 def test_widget(self):
     # BBB: portal_tinymce is removed in Plone 5. Remove this check when
     # Plone < 5 is no longer supported.
     utility = getToolByName(self.portal, 'portal_tinymce', None)
     if not utility:
         return
     from Products.Archetypes.Widget import TinyMCEWidget
     widget = TinyMCEWidget()
     self.field.widget = widget
     base_args = widget._base_args(self.portal, self.field, self.request)
     self.assertEqual(base_args['name'], 'fieldname')
     self.assertEqual(base_args['value'], 'fieldvalue')
     self.assertEqual(base_args['pattern'], 'tinymce')
Ejemplo n.º 5
0
    def test_at_tinymcewidget_multiple_mimetypes_create(self):
        """A RichTextWidget with multiple available mimetypes should render a
        mimetype selection widget along with the textfield. When there is no
        field value, the default mimetype should be preselected.
        """
        from Products.Archetypes.Widget import TinyMCEWidget
        widget = TinyMCEWidget()
        rendered = widget.edit(self.portal, self.field, self.request)

        self.assertTrue('<select' in rendered)
        self.assertTrue('pat-textareamimetypeselector' in rendered)
        self.assertTrue('data-pat-textareamimetypeselector' in rendered)
        self.assertTrue(
            '<option value="text/html" selected="selected">' in rendered)
        self.assertTrue('pat-tinymce' not in rendered)
Ejemplo n.º 6
0
    def test_at_tinymcewidget_multiple_mimetypes_create(self):
        """A RichTextWidget with multiple available mimetypes should render a
        mimetype selection widget along with the textfield. When there is no
        field value, the default mimetype should be preselected.
        """
        from Products.Archetypes.Widget import TinyMCEWidget
        widget = TinyMCEWidget()
        rendered = widget.edit(self.portal, self.field, self.request)

        self.assertTrue('<select' in rendered)
        self.assertTrue('pat-textareamimetypeselector' in rendered)
        self.assertTrue('data-pat-textareamimetypeselector' in rendered)
        self.assertTrue(
            '<option value="text/html" selected="selected">' in rendered)
        self.assertTrue('pat-tinymce' not in rendered)
                default_content_type='image/gif',
            ),
            storage=atapi.AttributeStorage(),
            original_size=(200, 200),
            sizes={'normal': (200, 250)},
            default_output_type='image/jpeg',
            allowable_content_types=('image/gif', 'image/jpeg', 'image/png'),
        ),
        atapi.TextField(
            name='overviewText',
            schemata='Overview',
            allowable_content_types=config.ALLOWABLE_CONTENT_TYPES,
            widget=TinyMCEWidget(
                label=_(
                    u"FacultyStaffDirectory_label_overview_text",
                    default=u"Overview text (used for specialty overview view)"
                ),
                i18n_domain='FacultyStaffDirectory',
            ),
            default_output_type="text/x-html-safe",
            searchable=True,
            validators=('isTidyHtmlWithCleanup', ))), )

Specialty_schema = getattr(PersonGrouping, 'schema', atapi.Schema(
    ())).copy() + schema.copy()


class Specialty(PersonGrouping):
    """
    """
    security = ClassSecurityInfo()
            label=_(u"FacultyStaffDirectory_label_image", default=u"Image"),
            i18n_domain='FacultyStaffDirectory',
            default_content_type='image/gif',
        ),
        storage=atapi.AttributeStorage(),
        original_size=(400, 500),
        sizes={'thumb': (100, 125), 'normal': (200, 250)},
        default_output_type='image/jpeg',
        allowable_content_types=('image/gif', 'image/jpeg', 'image/png'),
    ),

    atapi.TextField(
        name='biography',
        allowable_content_types=config.ALLOWABLE_CONTENT_TYPES,
        widget=TinyMCEWidget(
            label=_(u"FacultyStaffDirectory_label_biography", default=u"Biography"),
            i18n_domain='FacultyStaffDirectory',
        ),
        schemata="Professional Information",
        searchable=True,
        validators=('isTidyHtmlWithCleanup',),
        default_output_type='text/x-html-safe',
        user_property='description'
    ),

    atapi.LinesField(
        name='education',
        widget=atapi.LinesField._properties['widget'](
            label=_(u"FacultyStaffDirectory_label_education", default=u"Education"),
            i18n_domain='FacultyStaffDirectory',
        ),
        schemata="Professional Information",
from Products.CMFPlone.interfaces import IPloneSiteRoot
from Products.FacultyStaffDirectory import FSDMessageFactory as _

try:
    from Products.Archetypes.Widget import TinyMCEWidget
except ImportError:
    TinyMCEWidget = atapi.RichWidget


schema = ATContentTypeSchema.copy() + atapi.Schema((

    atapi.TextField(
        name='text',
        allowable_content_types=config.ALLOWABLE_CONTENT_TYPES,
        widget=TinyMCEWidget(
            label=_("FacultyStaffDirectory_label_text", default="Body Text"),
            i18n_domain='FacultyStaffDirectory',
        ),
        default_output_type="text/x-html-safe",
        searchable=True,
        validators=('isTidyHtmlWithCleanup',)
    ),

),
)

# + on Schemas does only a shallow copy
PersonGrouping_schema = atapi.OrderedBaseFolderSchema.copy() + schema.copy()


class PersonGrouping(atapi.OrderedBaseFolder, ATCTContent):
    """"""
try:
    from Products.Archetypes.Widget import TinyMCEWidget
except ImportError:
    TinyMCEWidget = atapi.RichWidget

schema = atapi.Schema((
    atapi.TextField(name='researchTopic',
                    allowable_content_types=(
                        'text/plain',
                        'text/structured',
                        'text/html',
                    ),
                    widget=TinyMCEWidget(
                        label=_("FacultyStaffDirectory_label_researchTopic",
                                default="Research Topic"),
                        i18n_domain='FacultyStaffDirectory',
                        allow_file_upload=False,
                        rows=5,
                    ),
                    default_output_type='text/x-html-safe'),
    atapi.StringField(name='title',
                      default="Research Topic",
                      widget=atapi.StringWidget(
                          visible={
                              'edit': 'invisible',
                              'view': 'visible'
                          },
                          label=_("FacultyStaffDirectory_label_title",
                                  default="Title"),
                          i18n_domain='FacultyStaffDirectory',
                      ),
                               default="Abbreviation"),
                       i18n_domain='FacultyStaffDirectory',
                   ),
                   searchable=True),
 atapi.StringField(name='number',
                   widget=atapi.StringWidget(
                       label=_("FacultyStaffDirectory_label_number",
                               default="Number"),
                       i18n_domain='FacultyStaffDirectory',
                   ),
                   searchable=True),
 atapi.TextField(name='description',
                 allowable_content_types=config.ALLOWABLE_CONTENT_TYPES,
                 widget=TinyMCEWidget(
                     label=_("FacultyStaffDirectory_label_description",
                             default="Description"),
                     i18n_domain='FacultyStaffDirectory',
                 ),
                 searchable=True,
                 validators=('isTidyHtmlWithCleanup', ),
                 default_output_type='text/html',
                 accessor="Description"),
 atapi.StringField(name='suffix',
                   widget=atapi.StringWidget(
                       size="1",
                       label=_("FacultyStaffDirectory_label_suffix",
                               default="Suffix"),
                       i18n_domain='FacultyStaffDirectory',
                   )),
 atapi.StringField(name='website',
                   widget=atapi.StringWidget(