Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from plone/richtext-behavior
backport richtext behavior from Plone5 branch
- Loading branch information
Showing
12 changed files
with
107 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 -*- | ||
from plone.autoform.interfaces import IFormFieldProvider | ||
from plone.dexterity.interfaces import IDexterityContent | ||
from plone.app.textfield import RichText as RichTextField | ||
from plone.supermodel import model | ||
from zope.component import adapts | ||
from zope.interface import alsoProvides, implements | ||
|
||
from plone.app.contenttypes import _ | ||
|
||
|
||
class IRichText(model.Schema): | ||
|
||
text = RichTextField( | ||
title=_(u'Text', default=u'Text'), | ||
description=u"", | ||
required=False, | ||
) | ||
model.primary('text') | ||
|
||
|
||
alsoProvides(IRichText, IFormFieldProvider) | ||
|
||
|
||
class RichText(object): | ||
implements(IRichText) | ||
adapts(IDexterityContent) | ||
|
||
def __init__(self, context): | ||
self.context = context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import unittest2 as unittest | ||
|
||
from Products.CMFCore.utils import getToolByName | ||
from plone.app.dexterity.testing import DEXTERITY_INTEGRATION_TESTING | ||
from plone.app.testing import TEST_USER_ID, setRoles | ||
from plone.app.testing import SITE_OWNER_NAME | ||
from plone.app.testing import SITE_OWNER_PASSWORD | ||
from plone.testing.z2 import Browser | ||
from plone.dexterity.fti import DexterityFTI | ||
|
||
from plone.app.contenttypes.behaviors.richtext import IRichText | ||
|
||
|
||
class RichTextBase: | ||
# subclass here | ||
_behaviors = None | ||
_portal_type = None | ||
|
||
def _setupFTI(self): | ||
fti = DexterityFTI(self._portal_type) | ||
self.portal.portal_types._setObject(self._portal_type, fti) | ||
fti.klass = 'plone.dexterity.content.Item' | ||
fti.behaviors = self._behaviors | ||
|
||
|
||
class RichTextBehaviorTests(RichTextBase, unittest.TestCase): | ||
""" basic use cases and tests for richtext behavior""" | ||
|
||
layer = DEXTERITY_INTEGRATION_TESTING | ||
|
||
_behaviors = ( | ||
'plone.app.contenttypes.behaviors.richtext.IRichText',) | ||
_portal_type = 'SomeDocument' | ||
|
||
def setUp(self): | ||
app = self.layer['app'] | ||
self.portal = self.layer['portal'] | ||
self.wf = getToolByName(self.portal, "portal_workflow") | ||
self.portal.acl_users._doAddUser('user_std', 'secret', ['Member'], []) | ||
self.portal_url = self.portal.absolute_url() | ||
setRoles(self.portal, TEST_USER_ID, ['Manager']) | ||
self._setupFTI() | ||
self.portal.invokeFactory(self._portal_type, 'doc1') | ||
setRoles(self.portal, TEST_USER_ID, ['Member']) | ||
import transaction | ||
transaction.commit() | ||
# Set up browser | ||
self.browser = Browser(app) | ||
self.browser.handleErrors = False | ||
self.browser.addHeader( | ||
'Authorization', | ||
'Basic %s:%s' % (SITE_OWNER_NAME, SITE_OWNER_PASSWORD,) | ||
) | ||
|
||
def test_richtext_behavior(self): | ||
IRichText.providedBy(self.portal.doc1) | ||
|
||
|
||
def test_suite(): | ||
from unittest import defaultTestLoader | ||
return defaultTestLoader.loadTestsFromName(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters