[Testbot] Plone 5.0 - Python 2.7 - Build # 1510 - Fixed! - 0 failure(s)
jenkins at plone.org
jenkins at plone.org
Wed Feb 12 19:31:21 UTC 2014
-------------------------------------------------------------------------------
Plone 5.0 - Python 2.7 - Build # 1510 - Fixed!
-------------------------------------------------------------------------------
http://jenkins.plone.org/job/plone-5.0-python-2.7/1510/
-------------------------------------------------------------------------------
CHANGES
-------------------------------------------------------------------------------
Repository: plone.app.contenttypes
Branch: refs/heads/master
Date: 2014-02-12T05:07:38-08:00
Author: Philip Bauer (pbauer) <bauer at starzel.de>
Commit: https://github.com/plone/plone.app.contenttypes/commit/0bf4acd1ca92153c906ce91417ef7bf96f3b1664
add a warning and hide the edit-link for uneditable content.
Files changed:
A plone/app/contenttypes/browser/templates/archetypes_warning_viewlet.pt
A plone/app/contenttypes/browser/viewlets.py
M plone/app/contenttypes/browser/configure.zcml
diff --git a/plone/app/contenttypes/browser/configure.zcml b/plone/app/contenttypes/browser/configure.zcml
index c8af09a..f2543b6 100644
--- a/plone/app/contenttypes/browser/configure.zcml
+++ b/plone/app/contenttypes/browser/configure.zcml
@@ -241,6 +241,15 @@
allowed_interface="plone.app.contenttypes.browser.utils.IUtils"
/>
+ <browser:viewlet
+ name="archetypes_warning_viewlet"
+ for="Products.Archetypes.interfaces.base.IBaseObject"
+ manager="plone.app.layout.viewlets.interfaces.IAboveContent"
+ class=".viewlets.ATWarningViewlet"
+ template="templates/archetypes_warning_viewlet.pt"
+ layer="plone.app.contenttypes.interfaces.IPloneAppContenttypesLayer"
+ permission="cmf.ModifyPortalContent" />
+
<!-- Query string widget -->
<adapter factory=".widgets.QueryStringFieldWidget" />
diff --git a/plone/app/contenttypes/browser/templates/archetypes_warning_viewlet.pt b/plone/app/contenttypes/browser/templates/archetypes_warning_viewlet.pt
new file mode 100644
index 0000000..cceac46
--- /dev/null
+++ b/plone/app/contenttypes/browser/templates/archetypes_warning_viewlet.pt
@@ -0,0 +1,19 @@
+<dl class="portalMessage alert-box secondary warning">
+ <dt i18n:translate="">Warning</dt>
+ <dd>
+ <tal:manager tal:condition="not:view/can_migrate">
+ <span i18n:translate="">You can't edit this content. Ask your administrator to migrate to Dexterity!</span>
+ </tal:manager>
+ <tal:manager tal:condition="view/can_migrate">
+ <span i18n:translate="">You can't edit this content unless you
+ <a href="#" tal:attributes="href string:${context/plone_portal_state/portal_url}/@@atct_migrator">
+ migrate the default content-types to Dexterity.
+ </a>
+ </span>
+ </tal:manager>
+ </dd>
+</dl>
+
+<style type="text/css">
+#contentview-edit {display: None;}
+</style>
\ No newline at end of file
diff --git a/plone/app/contenttypes/browser/viewlets.py b/plone/app/contenttypes/browser/viewlets.py
new file mode 100644
index 0000000..1edee8b
--- /dev/null
+++ b/plone/app/contenttypes/browser/viewlets.py
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+from AccessControl import getSecurityManager
+from Acquisition import aq_inner
+from Products.CMFCore.permissions import ManagePortal
+from plone.app.layout.viewlets import ViewletBase
+from plone.dexterity.interfaces import IDexterityFTI
+
+import pkg_resources
+
+try:
+ pkg_resources.get_distribution('Products.Archetypes')
+except pkg_resources.DistributionNotFound:
+ HAS_ARCHETYPES = False
+else:
+ from Products.Archetypes.interfaces.base import IBaseObject
+ HAS_ARCHETYPES = True
+
+
+class ATWarningViewlet(ViewletBase):
+
+ def update(self):
+ self.available = False
+ self.context = aq_inner(self.context)
+ if not HAS_ARCHETYPES:
+ return
+ if not IBaseObject.providedBy(self.context):
+ return
+ context_fti = self.context.getTypeInfo()
+ if IDexterityFTI.providedBy(context_fti):
+ self.available = True
+
+ def can_migrate(self):
+ sm = getSecurityManager()
+ if sm.checkPermission(ManagePortal, self.context):
+ return True
Repository: plone.app.contenttypes
Branch: refs/heads/master
Date: 2014-02-12T06:19:45-08:00
Author: Philip Bauer (pbauer) <bauer at starzel.de>
Commit: https://github.com/plone/plone.app.contenttypes/commit/126af9d4593414fbaace3e13b27f51e346db6cdf
add failing test to confirm that the ModificationDate is changed on migration when content of folders is migrated (also when the folders containing the content is migrated)
Files changed:
M plone/app/contenttypes/tests/test_migration.py
diff --git a/plone/app/contenttypes/tests/test_migration.py b/plone/app/contenttypes/tests/test_migration.py
index 705726c..2a36998 100644
--- a/plone/app/contenttypes/tests/test_migration.py
+++ b/plone/app/contenttypes/tests/test_migration.py
@@ -13,6 +13,7 @@
from zope.schema.interfaces import IVocabularyFactory
import os.path
+import time
import unittest2 as unittest
@@ -778,6 +779,70 @@ def test_blob_newsitem_content_is_migrated(self):
self.assertEqual(dx_newsitem.text.mimeType,
'chemical/x-gaussian-checkpoint')
+ def test_modifield_date_is_unchanged(self):
+ from plone.app.contenttypes.migration.migration import (
+ restoreReferences,
+ migrate_documents,
+ migrate_folders
+ )
+
+ # IIntIds is not registered in the test env. So register it here
+ sm = getSiteManager(self.portal)
+ addUtility(sm, IIntIds, IntIds, ofs_name='intids', findroot=False)
+
+ # create folders
+ self.portal.invokeFactory('Folder', 'folder1')
+ at_folder1 = self.portal['folder1']
+ self.portal.invokeFactory('Folder', 'folder2')
+ at_folder2 = self.portal['folder2']
+ self.portal.invokeFactory('Folder', 'folder3')
+ at_folder3 = self.portal['folder3']
+
+ # create ATDocuments
+ at_folder1.invokeFactory('Document', 'doc1')
+ at_doc1 = at_folder1['doc1']
+ at_folder2.invokeFactory('Document', 'doc2')
+ at_doc2 = at_folder2['doc2']
+ self.portal.invokeFactory('Document', 'doc3')
+ at_doc3 = self.portal['doc3']
+ at_folder1.invokeFactory('News Item', 'newsitem')
+ # at_newsitem = at_folder1['newsitem']
+
+ time.sleep(0.1)
+
+ # relate them
+ #at_doc1.setRelatedItems([at_doc2])
+ #at_doc2.setRelatedItems([at_newsitem, at_doc3, at_doc1])
+ #at_doc3.setRelatedItems(at_doc1)
+ #at_folder1.setRelatedItems([at_doc2])
+ #at_folder2.setRelatedItems([at_doc1])
+
+ # migrate content
+ applyProfile(self.portal, 'plone.app.contenttypes:default')
+ migrate_folders(self.portal)
+ migrate_documents(self.portal)
+ dx_folder1 = self.portal['folder1']
+ dx_folder2 = self.portal['folder2']
+ dx_folder3 = self.portal['folder3']
+
+ dx_doc1 = dx_folder1['doc1']
+ dx_doc2 = dx_folder2['doc2']
+ dx_doc3 = self.portal['doc3']
+
+ # migrate references
+ #restoreReferences(self.portal)
+
+ self.assertTrue(at_folder1 is not dx_folder1)
+ self.assertTrue(at_folder2 is not dx_folder2)
+
+ # assert ModificationDates
+ self.assertNotEqual(at_folder1.ModificationDate(), dx_folder1.ModificationDate())
+ self.assertNotEqual(at_folder2.ModificationDate(), dx_folder2.ModificationDate())
+ self.assertEqual(at_folder3.ModificationDate(), dx_folder3.ModificationDate())
+ self.assertEqual(at_doc1.ModificationDate(), dx_doc1.ModificationDate())
+ self.assertEqual(at_doc2.ModificationDate(), dx_doc2.ModificationDate())
+ self.assertEqual(at_doc3.ModificationDate(), dx_doc3.ModificationDate())
+
def test_folder_is_migrated(self):
from plone.app.contenttypes.migration.migration import FolderMigrator
from plone.app.contenttypes.interfaces import IFolder
Repository: plone.app.contenttypes
Branch: refs/heads/master
Date: 2014-02-12T06:19:45-08:00
Author: Philip Bauer (pbauer) <bauer at starzel.de>
Commit: https://github.com/plone/plone.app.contenttypes/commit/000167aae529dd906fe33df02d39f53b886dda40
add convenience-method to add the browser-layer to the request
Files changed:
M plone/app/contenttypes/testing.py
diff --git a/plone/app/contenttypes/testing.py b/plone/app/contenttypes/testing.py
index 1fee5f6..a09d27b 100644
--- a/plone/app/contenttypes/testing.py
+++ b/plone/app/contenttypes/testing.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+from plone.app.contenttypes.interfaces import IPloneAppContenttypesLayer
from plone.app.event.testing import PAEvent_FIXTURE
from plone.app.testing import PloneSandboxLayer
from plone.app.testing import applyProfile
@@ -10,10 +11,20 @@
from plone.app.testing import login
from plone.testing import z2
from zope.configuration import xmlconfig
+from zope.interface import alsoProvides
import pkg_resources
+def set_browserlayer(request):
+ """Set the BrowserLayer for the request.
+
+ We have to set the browserlayer manually, since importing the profile alone
+ doesn't do it in tests.
+ """
+ alsoProvides(request, IPloneAppContenttypesLayer)
+
+
class PloneAppContenttypes(PloneSandboxLayer):
defaultBases = (PAEvent_FIXTURE, PLONE_FIXTURE,)
Repository: plone.app.contenttypes
Branch: refs/heads/master
Date: 2014-02-12T06:19:45-08:00
Author: Philip Bauer (pbauer) <bauer at starzel.de>
Commit: https://github.com/plone/plone.app.contenttypes/commit/e6fdf6de933f0f21c5277a90f8598ea59db68373
Fix #62: Keep ModificationDate during migration.
Files changed:
M CHANGES.rst
M plone/app/contenttypes/migration/browser.py
M plone/app/contenttypes/tests/test_migration.py
diff --git a/CHANGES.rst b/CHANGES.rst
index 293b4ab..745444a 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,6 +4,9 @@ Changelog
1.1a2 (unreleased)
------------------
+- Fix #62: Keep ModificationDate during migration.
+ [pbauer]
+
- Only attempt transforming files if valid content type
[vangheem]
diff --git a/plone/app/contenttypes/migration/browser.py b/plone/app/contenttypes/migration/browser.py
index ff24c4e..9323193 100644
--- a/plone/app/contenttypes/migration/browser.py
+++ b/plone/app/contenttypes/migration/browser.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from Products.CMFCore.interfaces import IPropertiesTool
from Products.CMFCore.utils import getToolByName
+from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl
from Products.Five.browser import BrowserView
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from datetime import datetime
@@ -98,6 +99,12 @@ def __call__(self,
site_props = getattr(ptool, 'site_properties', None)
link_integrity = site_props.getProperty('enable_link_integrity_checks',
False)
+
+ # patch notifyModified to prevent setModificationDate()
+ old_notifyModified = DefaultDublinCoreImpl.notifyModified
+ patched_notifyModified = lambda *args: None
+ DefaultDublinCoreImpl.notifyModified = patched_notifyModified
+
site_props.manage_changeProperties(enable_link_integrity_checks=False)
not_migrated = []
@@ -124,6 +131,9 @@ def __call__(self,
site_props.manage_changeProperties(
enable_link_integrity_checks=link_integrity
)
+
+ DefaultDublinCoreImpl.notifyModified = old_notifyModified
+
endtime = datetime.now()
duration = (endtime - starttime).seconds
if not from_form:
diff --git a/plone/app/contenttypes/tests/test_migration.py b/plone/app/contenttypes/tests/test_migration.py
index 2a36998..d675070 100644
--- a/plone/app/contenttypes/tests/test_migration.py
+++ b/plone/app/contenttypes/tests/test_migration.py
@@ -4,9 +4,11 @@
from five.intid.site import addUtility
from plone.app.contenttypes.testing import \
PLONE_APP_CONTENTTYPES_MIGRATION_TESTING
+from plone.app.contenttypes.testing import set_browserlayer
from plone.event.interfaces import IEventAccessor
from plone.app.testing import login
from plone.app.testing import applyProfile
+from zope.component import getMultiAdapter
from zope.component import getSiteManager
from zope.component import getUtility
from zope.intid.interfaces import IIntIds
@@ -780,11 +782,7 @@ def test_blob_newsitem_content_is_migrated(self):
'chemical/x-gaussian-checkpoint')
def test_modifield_date_is_unchanged(self):
- from plone.app.contenttypes.migration.migration import (
- restoreReferences,
- migrate_documents,
- migrate_folders
- )
+ set_browserlayer(self.request)
# IIntIds is not registered in the test env. So register it here
sm = getSiteManager(self.portal)
@@ -806,21 +804,34 @@ def test_modifield_date_is_unchanged(self):
self.portal.invokeFactory('Document', 'doc3')
at_doc3 = self.portal['doc3']
at_folder1.invokeFactory('News Item', 'newsitem')
- # at_newsitem = at_folder1['newsitem']
+ at_newsitem = at_folder1['newsitem']
+ # be 100% sure the migration-date is after the creation-date
time.sleep(0.1)
# relate them
- #at_doc1.setRelatedItems([at_doc2])
- #at_doc2.setRelatedItems([at_newsitem, at_doc3, at_doc1])
- #at_doc3.setRelatedItems(at_doc1)
- #at_folder1.setRelatedItems([at_doc2])
- #at_folder2.setRelatedItems([at_doc1])
+ at_doc1.setRelatedItems([at_doc2])
+ at_doc2.setRelatedItems([at_newsitem, at_doc3, at_doc1])
+ at_doc3.setRelatedItems(at_doc1)
+ at_folder1.setRelatedItems([at_doc2])
+ at_folder2.setRelatedItems([at_doc1])
# migrate content
applyProfile(self.portal, 'plone.app.contenttypes:default')
- migrate_folders(self.portal)
- migrate_documents(self.portal)
+
+ # we use the migration-view instead of calling the migratons by hand
+ # to make sure the patch for notifyModified is used.
+ migration_view = getMultiAdapter(
+ (self.portal, self.request),
+ name=u'migrate_from_atct'
+ )
+ migration_view(
+ content_types=['Document', 'Folder'],
+ migrate_schemaextended_content=True,
+ migrate_references=True,
+ from_form=False,
+ )
+
dx_folder1 = self.portal['folder1']
dx_folder2 = self.portal['folder2']
dx_folder3 = self.portal['folder3']
@@ -829,19 +840,51 @@ def test_modifield_date_is_unchanged(self):
dx_doc2 = dx_folder2['doc2']
dx_doc3 = self.portal['doc3']
- # migrate references
- #restoreReferences(self.portal)
-
self.assertTrue(at_folder1 is not dx_folder1)
self.assertTrue(at_folder2 is not dx_folder2)
# assert ModificationDates
- self.assertNotEqual(at_folder1.ModificationDate(), dx_folder1.ModificationDate())
- self.assertNotEqual(at_folder2.ModificationDate(), dx_folder2.ModificationDate())
- self.assertEqual(at_folder3.ModificationDate(), dx_folder3.ModificationDate())
- self.assertEqual(at_doc1.ModificationDate(), dx_doc1.ModificationDate())
- self.assertEqual(at_doc2.ModificationDate(), dx_doc2.ModificationDate())
- self.assertEqual(at_doc3.ModificationDate(), dx_doc3.ModificationDate())
+ self.assertEqual(
+ at_folder1.ModificationDate(),
+ dx_folder1.ModificationDate()
+ )
+ self.assertEqual(
+ at_folder2.ModificationDate(),
+ dx_folder2.ModificationDate()
+ )
+ self.assertEqual(
+ at_folder3.ModificationDate(),
+ dx_folder3.ModificationDate()
+ )
+ self.assertEqual(
+ at_doc1.ModificationDate(),
+ dx_doc1.ModificationDate()
+ )
+ self.assertEqual(
+ at_doc2.ModificationDate(),
+ dx_doc2.ModificationDate()
+ )
+ self.assertEqual(
+ at_doc3.ModificationDate(),
+ dx_doc3.ModificationDate()
+ )
+
+ # assert single references
+ dx_doc1_related = [x.to_object for x in dx_doc1.relatedItems]
+ self.assertEqual(dx_doc1_related, [dx_doc2])
+
+ dx_doc3_related = [x.to_object for x in dx_doc3.relatedItems]
+ self.assertEqual(dx_doc3_related, [dx_doc1])
+
+ dx_folder1_related = [x.to_object for x in dx_folder1.relatedItems]
+ self.assertEqual(dx_folder1_related, [dx_doc2])
+
+ dx_folder2_related = [x.to_object for x in dx_folder2.relatedItems]
+ self.assertEqual(dx_folder2_related, [dx_doc1])
+
+ # assert multi references, order is restored
+ dx_doc2_related = [x.to_object for x in dx_doc2.relatedItems]
+ self.assertEqual(dx_doc2_related, [at_newsitem, dx_doc3, dx_doc1])
def test_folder_is_migrated(self):
from plone.app.contenttypes.migration.migration import FolderMigrator
Repository: plone.app.contenttypes
Branch: refs/heads/master
Date: 2014-02-12T06:19:45-08:00
Author: Philip Bauer (pbauer) <bauer at starzel.de>
Commit: https://github.com/plone/plone.app.contenttypes/commit/ccb3d26ade2c83304b6ac2d929358bbafafc66ff
add test for the viewlet warning about uneditable content
Files changed:
M plone/app/contenttypes/tests/test_migration.py
diff --git a/plone/app/contenttypes/tests/test_migration.py b/plone/app/contenttypes/tests/test_migration.py
index d675070..dab73b2 100644
--- a/plone/app/contenttypes/tests/test_migration.py
+++ b/plone/app/contenttypes/tests/test_migration.py
@@ -6,6 +6,7 @@
PLONE_APP_CONTENTTYPES_MIGRATION_TESTING
from plone.app.contenttypes.testing import set_browserlayer
from plone.event.interfaces import IEventAccessor
+from plone.app.testing import TEST_USER_ID, setRoles
from plone.app.testing import login
from plone.app.testing import applyProfile
from zope.component import getMultiAdapter
@@ -1157,3 +1158,28 @@ def test_migrate_xx_functions(self):
'.interfaces.IDexterityContent')
self.assertEqual(len(at_contents), 0)
self.assertEqual(len(dx_contents), 11)
+
+ def test_warning_for_uneditable_content(self):
+ set_browserlayer(self.request)
+ from plone.app.contenttypes.migration.migration import DocumentMigrator
+ from plone.app.contenttypes.interfaces import IDocument
+ self.portal.invokeFactory('Document', 'document')
+ self.portal.invokeFactory('News Item', 'newsitem')
+ at_document = self.portal['document']
+ at_newsitem = self.portal['newsitem']
+ applyProfile(self.portal, 'plone.app.contenttypes:default')
+ at_document_view = at_document.restrictedTraverse('')
+ self.assertTrue(
+ 'http://nohost/plone/@@atct_migrator' in at_document_view()
+ )
+ migrator = self.get_migrator(at_document, DocumentMigrator)
+ migrator.migrate()
+ dx_document = self.portal['document']
+ self.assertTrue(IDocument.providedBy(dx_document))
+ dx_document_view = dx_document.restrictedTraverse('@@view')
+ self.assertFalse('alert-box' in dx_document_view())
+ at_newsitem_view = at_newsitem.restrictedTraverse('')
+ self.assertTrue('alert-box' in at_newsitem_view())
+ self.assertTrue(
+ 'http://nohost/plone/@@atct_migrator' in at_newsitem_view()
+ )
Repository: plone.app.contenttypes
Branch: refs/heads/master
Date: 2014-02-12T09:05:01-08:00
Author: Roel Bruggink (jaroel) <roel at jaroel.nl>
Commit: https://github.com/plone/plone.app.contenttypes/commit/ddfd295e68f893c41833aefa37b74aea6bf42add
Modernize robot tests
Files changed:
M plone/app/contenttypes/testing.py
M plone/app/contenttypes/tests/robot/contenttypes_keywords.txt
M plone/app/contenttypes/tests/robot/keywords.txt
M plone/app/contenttypes/tests/robot/test_collection_creator_criterion.robot
M plone/app/contenttypes/tests/robot/test_collection_location_criterion.robot
M plone/app/contenttypes/tests/robot/test_collection_review_state_criterion.robot
M plone/app/contenttypes/tests/robot/test_collection_short_name_criterion.robot
M plone/app/contenttypes/tests/robot/test_collection_type_criterion.robot
M plone/app/contenttypes/tests/robot/test_contenttypes.robot
M plone/app/contenttypes/tests/robot/variables.py
diff --git a/plone/app/contenttypes/testing.py b/plone/app/contenttypes/testing.py
index a09d27b..341a7cc 100644
--- a/plone/app/contenttypes/testing.py
+++ b/plone/app/contenttypes/testing.py
@@ -14,6 +14,7 @@
from zope.interface import alsoProvides
import pkg_resources
+from .tests.robot.variables import TEST_FOLDER_ID
def set_browserlayer(request):
@@ -56,7 +57,7 @@ def setUpPloneSite(self, portal):
setRoles(portal, TEST_USER_ID, ['Manager'])
portal.invokeFactory(
"Folder",
- id="robot-test-folder",
+ id=TEST_FOLDER_ID,
title=u"Test Folder"
)
diff --git a/plone/app/contenttypes/tests/robot/contenttypes_keywords.txt b/plone/app/contenttypes/tests/robot/contenttypes_keywords.txt
index c24de4c..43611ed 100644
--- a/plone/app/contenttypes/tests/robot/contenttypes_keywords.txt
+++ b/plone/app/contenttypes/tests/robot/contenttypes_keywords.txt
@@ -1,3 +1,5 @@
+Variables plone/app/contenttypes/tests/robot/variables.py
+
*** Keywords ***
Suite Setup
@@ -35,9 +37,9 @@ Create Event
Input text name=form.widgets.start_date-year 2013
Input text name=form.widgets.end_date-day 10
Input text name=form.widgets.end_date-year 2013
-
+
Click Button Save
- Page Should Contain Item created
+ Page Should Contain Item created
Create News Item
[Arguments] ${title}
@@ -46,7 +48,7 @@ Create News Item
Input text name=form.widgets.IDublinCore.title ${title}
Click Button Save
- Page Should Contain Item created
+ Page Should Contain Item created
Create Link
[Arguments] ${title}
@@ -56,7 +58,7 @@ Create Link
Input text name=form.widgets.remoteUrl http://plone.org
Click Button Save
- Page Should Contain Item created
+ Page Should Contain Item created
Create Collection
[Arguments] ${title}
@@ -65,7 +67,7 @@ Create Collection
Input text name=form.widgets.IDublinCore.title ${title}
Click Button Save
- Page Should Contain Item created
+ Page Should Contain Item created
Create Folder
[Arguments] ${title}
@@ -74,7 +76,7 @@ Create Folder
Input text name=form.widgets.IDublinCore.title ${title}
Click Button Save
- Page Should Contain Item created
+ Page Should Contain Item created
Create Document
[Arguments] ${title}
@@ -83,15 +85,15 @@ Create Document
Input text name=form.widgets.IDublinCore.title ${title}
Click Button Save
- Page Should Contain Item created
+ Page Should Contain Item created
Create Image
[Arguments] ${title}
Go to ${test-folder}/++add++Image
- Input text name=form.widgets.title ${title}
+ Input text name=form.widgets.title ${title}
Choose File name=form.widgets.image ${PATH_TO_TEST_FILES}/image.jpg
Click Button Save
- Page Should Contain Item created
- Page Should Contain Click to view full-size image
+ Page Should Contain Item created
+ Page Should Contain Click to view full-size image
diff --git a/plone/app/contenttypes/tests/robot/keywords.txt b/plone/app/contenttypes/tests/robot/keywords.txt
index 47d2e6a..2b71203 100644
--- a/plone/app/contenttypes/tests/robot/keywords.txt
+++ b/plone/app/contenttypes/tests/robot/keywords.txt
@@ -1,55 +1,17 @@
-*** Keywords ***
+Variables plone/app/contenttypes/tests/robot/variables.py
-# ----------------------------------------------------------------------------
-# Suite
-# ----------------------------------------------------------------------------
+*** Keywords ***
-Suite Setup
- Open browser ${PLONE_URL} browser=${BROWSER} remote_url=${REMOTE_URL} desired_capabilities=${DESIRED_CAPABILITIES}
+I am logged in as site owner
Log in as site owner
-Suite Teardown
- Close All Browsers
-
-
-# ----------------------------------------------------------------------------
-# Login/Logout
-# ----------------------------------------------------------------------------
-
-Log in
- [Arguments] ${userid} ${password}
- [Documentation] Log in to the site as ${userid} using ${password}. There
- ... is no guarantee of where in the site you are once this is
- ... done. (You are responsible for knowing where you are and
- ... where you want to be)
- Go to ${PLONE_URL}/login_form
- Page should contain element __ac_name
- Page should contain element __ac_password
- Page should contain button Log in
- Input text __ac_name ${userid}
- Input text __ac_password ${password}
- Click Button Log in
-
-Log in as site owner
- [Documentation] Log in as the SITE_OWNER provided by plone.app.testing,
- ... with all the rights and privileges of that user.
- Log in ${SITE_OWNER_NAME} ${SITE_OWNER_PASSWORD}
-
-Log in as test user
- Log in ${TEST_USER_NAME} ${TEST_USER_PASSWORD}
-
-Log out
- Go to ${PLONE_URL}/logout
- Page should contain logged out
-
-
# ----------------------------------------------------------------------------
# Content
# ----------------------------------------------------------------------------
a collection
[Arguments] ${title}
- Go to ${TEST_FOLDER}/++add++Collection
+ Go to ${PLONE_URL}/++add++Collection
Wait until page contains Add Collection
Input text name=form.widgets.IDublinCore.title ${title}
Click Button Save
@@ -57,7 +19,7 @@ a collection
a document
[Arguments] ${title}
- Go to ${TEST_FOLDER}/++add++Document
+ Go to ${PLONE_URL}/++add++Document
Wait until page contains Add Page
Input text name=form.widgets.IDublinCore.title ${title}
Click Button Save
@@ -65,7 +27,7 @@ a document
a event
[Arguments] ${title}
- Go to ${TEST_FOLDER}/++add++Event
+ Go to ${PLONE_URL}/++add++Event
Wait until page contains Add Event
Input text name=form.widgets.IDublinCore.title ${title}
Click Button Save
@@ -73,7 +35,7 @@ a event
a file
[Arguments] ${title}
- Go to ${TEST_FOLDER}/++add++File
+ Go to ${PLONE_URL}/++add++File
Wait until page contains Add File
Input text name=form.widgets.title ${title}
Choose File name=form.widgets.file ${PATH_TO_TEST_FILES}/file.pdf
@@ -82,7 +44,7 @@ a file
a folder
[Arguments] ${title}
- Go to ${TEST_FOLDER}/++add++Folder
+ Go to ${PLONE_URL}/++add++Folder
Wait until page contains Add Folder
Input text name=form.widgets.IDublinCore.title ${title}
Click Button Save
@@ -90,7 +52,7 @@ a folder
a image
[Arguments] ${title}
- Go to ${TEST_FOLDER}/++add++Image
+ Go to ${PLONE_URL}/++add++Image
Wait until page contains Add Image
Input text name=form.widgets.title ${title}
Choose File name=form.widgets.image ${PATH_TO_TEST_FILES}/image.png
@@ -99,7 +61,7 @@ a image
a link
[Arguments] ${title}
- Go to ${TEST_FOLDER}/++add++Link
+ Go to ${PLONE_URL}/++add++Link
Wait until page contains Add Link
Input text name=form.widgets.IDublinCore.title ${title}
Click Button Save
@@ -107,7 +69,7 @@ a link
a news item
[Arguments] ${title}
- Go to ${TEST_FOLDER}/++add++News Item
+ Go to ${PLONE_URL}/++add++News Item
Wait until page contains Add News Item
Input text name=form.widgets.IDublinCore.title ${title}
fill in metadata
@@ -130,12 +92,12 @@ the content area should not contain
the collection should contain
[Arguments] ${title}
- Go to ${TEST_FOLDER}/my-collection
+ Go to ${PLONE_URL}/my-collection
The content area should contain ${title}
the collection should not contain
[Arguments] ${title}
- Go to ${TEST_FOLDER}/my-collection
+ Go to ${PLONE_URL}/my-collection
The content area should not contain ${title}
fill in metadata
diff --git a/plone/app/contenttypes/tests/robot/test_collection_creator_criterion.robot b/plone/app/contenttypes/tests/robot/test_collection_creator_criterion.robot
index 816436e..8ad5e28 100644
--- a/plone/app/contenttypes/tests/robot/test_collection_creator_criterion.robot
+++ b/plone/app/contenttypes/tests/robot/test_collection_creator_criterion.robot
@@ -1,17 +1,14 @@
*** Settings ***
-Variables plone/app/testing/interfaces.py
-Variables plone/app/contenttypes/tests/robot/variables.py
-
-Library Selenium2Library timeout=${SELENIUM_TIMEOUT} implicit_wait=${SELENIUM_IMPLICIT_WAIT}
-
+Resource plone/app/robotframework/keywords.robot
Resource plone/app/contenttypes/tests/robot/keywords.txt
-Suite Setup Suite Setup
-Suite Teardown Suite Teardown
+Test Setup Run keywords Open test browser
+Test Teardown Close all browsers
+*** Variables ***
-*** Test Cases ***
+*** Test cases ***
Scenario: Test Creator Criterion
Given a site owner document Site Owner Document
@@ -26,6 +23,7 @@ Scenario: Test Creator Criterion
a site owner document
[Arguments] ${title}
+ Log in as site owner
a document ${title}
a test user document
diff --git a/plone/app/contenttypes/tests/robot/test_collection_location_criterion.robot b/plone/app/contenttypes/tests/robot/test_collection_location_criterion.robot
index 8d58d0b..2bc6d8f 100644
--- a/plone/app/contenttypes/tests/robot/test_collection_location_criterion.robot
+++ b/plone/app/contenttypes/tests/robot/test_collection_location_criterion.robot
@@ -1,20 +1,20 @@
*** Settings ***
-Variables plone/app/testing/interfaces.py
-Variables plone/app/contenttypes/tests/robot/variables.py
-
-Library Selenium2Library timeout=${SELENIUM_TIMEOUT} implicit_wait=${SELENIUM_IMPLICIT_WAIT}
-
+Resource plone/app/robotframework/keywords.robot
Resource plone/app/contenttypes/tests/robot/keywords.txt
-Suite Setup Suite Setup
-Suite Teardown Suite Teardown
+Variables plone/app/contenttypes/tests/robot/variables.py
+
+Test Setup Run keywords Open test browser
+Test Teardown Close all browsers
+*** Variables ***
-*** Test Cases ***
+*** Test cases ***
Scenario: Test Relative Location Criterion
- Given a document Document outside Folder
+ Given I am logged in as site owner
+ And a document Document outside Folder
And a folder 'my-folder' with a document 'Document within Folder'
And a collection My Collection
When I set the collection's relative location criterion to ../my-folder
@@ -23,10 +23,11 @@ Scenario: Test Relative Location Criterion
Scenario: Test Absolute Location Criterion
- Given a document Document outside Folder
+ Given I am logged in as site owner
+ And a document Document outside Folder
And a folder 'my-folder' with a document 'Document within Folder'
And a collection My Collection
- When I set the collection's absolute location criterion to /robot-test-folder/my-folder/
+ When I set the collection's absolute location criterion to /my-folder/
Then the collection should contain Document within Folder
And the collection should not contain Document outside Folder
@@ -34,11 +35,11 @@ Scenario: Test Absolute Location Criterion
*** Keywords ***
a folder '${folder-id}' with a document '${document-title}'
- Go to ${TEST_FOLDER}/++add++Folder
+ Go to ${PLONE_URL}/++add++Folder
Wait until page contains element name=form.widgets.IDublinCore.title
Input text name=form.widgets.IDublinCore.title ${folder-id}
Click Button Save
- Go to ${TEST_FOLDER}/${folder-id}/++add++Document
+ Go to ${PLONE_URL}/${folder-id}/++add++Document
Wait until page contains element name=form.widgets.IDublinCore.title
Input text name=form.widgets.IDublinCore.title ${document-title}
Click Button Save
diff --git a/plone/app/contenttypes/tests/robot/test_collection_review_state_criterion.robot b/plone/app/contenttypes/tests/robot/test_collection_review_state_criterion.robot
index 80a2c05..1f944ab 100644
--- a/plone/app/contenttypes/tests/robot/test_collection_review_state_criterion.robot
+++ b/plone/app/contenttypes/tests/robot/test_collection_review_state_criterion.robot
@@ -1,20 +1,18 @@
*** Settings ***
-Variables plone/app/testing/interfaces.py
-Variables plone/app/contenttypes/tests/robot/variables.py
-
-Library Selenium2Library timeout=${SELENIUM_TIMEOUT} implicit_wait=${SELENIUM_IMPLICIT_WAIT}
-
+Resource plone/app/robotframework/keywords.robot
Resource plone/app/contenttypes/tests/robot/keywords.txt
-Suite Setup Suite Setup
-Suite Teardown Suite Teardown
+Test Setup Run keywords Open test browser
+Test Teardown Close all browsers
+*** Variables ***
-*** Test Cases ***
+*** Test cases ***
Scenario: Test Review state Criterion
- Given a published document Published Document
+ Given I am logged in as site owner
+ And a published document Published Document
And a private document Private Document
And a collection My Collection
When I set the collection's review state criterion to private
diff --git a/plone/app/contenttypes/tests/robot/test_collection_short_name_criterion.robot b/plone/app/contenttypes/tests/robot/test_collection_short_name_criterion.robot
index 6fd0730..875083f 100644
--- a/plone/app/contenttypes/tests/robot/test_collection_short_name_criterion.robot
+++ b/plone/app/contenttypes/tests/robot/test_collection_short_name_criterion.robot
@@ -1,20 +1,18 @@
*** Settings ***
-Variables plone/app/testing/interfaces.py
-Variables plone/app/contenttypes/tests/robot/variables.py
-
-Library Selenium2Library timeout=${SELENIUM_TIMEOUT} implicit_wait=${SELENIUM_IMPLICIT_WAIT}
-
+Resource plone/app/robotframework/keywords.robot
Resource plone/app/contenttypes/tests/robot/keywords.txt
-Suite Setup Suite Setup
-Suite Teardown Suite Teardown
+Test Setup Run keywords Open test browser
+Test Teardown Close all browsers
+*** Variables ***
-*** Test Cases ***
+*** Test cases ***
Test Short name (id) Criterion
- Given a document First Document
+ Given I am logged in as site owner
+ And a document First Document
And a document Second Document
And a collection My Collection
When I set the collection short name (id) criterion to first-document
diff --git a/plone/app/contenttypes/tests/robot/test_collection_type_criterion.robot b/plone/app/contenttypes/tests/robot/test_collection_type_criterion.robot
index 98c8a5d..efc90e2 100644
--- a/plone/app/contenttypes/tests/robot/test_collection_type_criterion.robot
+++ b/plone/app/contenttypes/tests/robot/test_collection_type_criterion.robot
@@ -1,20 +1,18 @@
*** Settings ***
-Variables plone/app/testing/interfaces.py
-Variables plone/app/contenttypes/tests/robot/variables.py
-
-Library Selenium2Library timeout=${SELENIUM_TIMEOUT} implicit_wait=${SELENIUM_IMPLICIT_WAIT}
-
+Resource plone/app/robotframework/keywords.robot
Resource plone/app/contenttypes/tests/robot/keywords.txt
-Suite Setup Suite Setup
-Suite Teardown Suite Teardown
+Test Setup Run keywords Open test browser
+Test Teardown Close all browsers
+*** Variables ***
-*** Test Cases ***
+*** Test cases ***
Test Short name (id) Criterion
- Given a document Test Document
+ Given I am logged in as site owner
+ And a document Test Document
And a news_item Test News Item
And a collection My Collection
When I set the collection's type criterion to News Item
diff --git a/plone/app/contenttypes/tests/robot/test_contenttypes.robot b/plone/app/contenttypes/tests/robot/test_contenttypes.robot
index fe4f322..97a33f6 100644
--- a/plone/app/contenttypes/tests/robot/test_contenttypes.robot
+++ b/plone/app/contenttypes/tests/robot/test_contenttypes.robot
@@ -1,20 +1,20 @@
*** Settings ***
-Variables plone/app/testing/interfaces.py
-Variables plone/app/contenttypes/tests/robot/variables.py
-
-Library Selenium2Library timeout=${SELENIUM_TIMEOUT} implicit_wait=${SELENIUM_IMPLICIT_WAIT}
-
+Resource plone/app/robotframework/keywords.robot
Resource plone/app/contenttypes/tests/robot/keywords.txt
-Suite Setup Suite Setup
-Suite Teardown Suite Teardown
+Variables plone/app/contenttypes/tests/robot/variables.py
+
+Test Setup Run keywords Open test browser
+Test Teardown Close all browsers
+*** Variables ***
-*** Test Cases ***
+*** Test cases ***
Scenario: Test Folderlisting
- Given a Folder Test-Folder
+ Given I am logged in as site owner
+ And a Folder Test-Folder
And a File Test-File
And a Image Test-Image
And a Collection Test-Collection
@@ -22,7 +22,7 @@ Scenario: Test Folderlisting
And a Link Test-Link
And a News Item Test-News
And a Document Test-Document
- When I Go to ${TEST_FOLDER}/folder_contents
+ When I Go to ${PLONE_URL}/folder_contents
Then Page Should Contain Test-Folder
And Page Should Contain Test-File
And Page Should Contain Test-Image
diff --git a/plone/app/contenttypes/tests/robot/variables.py b/plone/app/contenttypes/tests/robot/variables.py
index e8eaca0..7310966 100644
--- a/plone/app/contenttypes/tests/robot/variables.py
+++ b/plone/app/contenttypes/tests/robot/variables.py
@@ -1,24 +1,5 @@
# -*- coding: utf-8 -*-
from pkg_resources import resource_filename
-import os
-
-from plone.app.testing.interfaces import PLONE_SITE_ID
-
-
-PORT = os.environ.get('ZSERVER_PORT', 55001)
-PORT = os.environ.get('PLONE_TESTING_PORT', PORT)
-ZSERVER_PORT = PORT
-SELENIUM_IMPLICIT_WAIT = os.environ.get('SELENIUM_IMPLICIT_WAIT', '0.1s')
-SELENIUM_TIMEOUT = os.environ.get('SELENIUM_IMPLICIT_WAIT', '20s')
-
-ZOPE_HOST = os.environ.get('ZOPE_HOST', "localhost")
-ZOPE_URL = os.environ.get('ZOPE_URL', "http://%s:%s" % (ZOPE_HOST, PORT))
-PLONE_SITE_ID = os.environ.get('PLONE_SITE_ID', PLONE_SITE_ID)
-PLONE_URL = os.environ.get('PLONE_URL', "%s/%s" % (ZOPE_URL, PLONE_SITE_ID))
-BROWSER = os.environ.get('BROWSER', "Firefox")
-REMOTE_URL = os.environ.get('REMOTE_URL', "")
-DESIRED_CAPABILITIES = os.environ.get('DESIRED_CAPABILITIES', "")
-
-TEST_FOLDER = os.environ.get('TEST_FOLDER', "%s/robot-test-folder" % PLONE_URL)
+TEST_FOLDER_ID = 'robot-test-folder'
PATH_TO_TEST_FILES = resource_filename("plone.app.contenttypes.tests", "")
Repository: plone.app.contenttypes
Branch: refs/heads/master
Date: 2014-02-12T09:05:01-08:00
Author: Philip Bauer (pbauer) <bauer at starzel.de>
Commit: https://github.com/plone/plone.app.contenttypes/commit/de5e44d015d387d121a9b9c5d35b0411d50ebf18
fix regression coming from plone.dexterity now having notifyModified
Files changed:
M plone/app/contenttypes/migration/browser.py
M plone/app/contenttypes/tests/test_migration.py
diff --git a/plone/app/contenttypes/migration/browser.py b/plone/app/contenttypes/migration/browser.py
index 9323193..ded0fa3 100644
--- a/plone/app/contenttypes/migration/browser.py
+++ b/plone/app/contenttypes/migration/browser.py
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
from Products.CMFCore.interfaces import IPropertiesTool
from Products.CMFCore.utils import getToolByName
-from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl
from Products.Five.browser import BrowserView
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from datetime import datetime
from plone.app.contenttypes.migration import migration
from plone.app.contenttypes.migration.utils import ATCT_LIST
from plone.app.contenttypes.migration.utils import isSchemaExtended
+from plone.dexterity.content import DexterityContent
from plone.dexterity.interfaces import IDexterityContent
from plone.z3cform.layout import wrap_form
from pprint import pformat
@@ -15,8 +15,8 @@
from z3c.form.browser.checkbox import CheckBoxFieldWidget
from z3c.form.interfaces import HIDDEN_MODE
from zope import schema
-from zope.component import queryUtility
from zope.component import getMultiAdapter
+from zope.component import queryUtility
from zope.interface import Interface
# Schema Extender allowed interfaces
@@ -101,9 +101,12 @@ def __call__(self,
False)
# patch notifyModified to prevent setModificationDate()
- old_notifyModified = DefaultDublinCoreImpl.notifyModified
- patched_notifyModified = lambda *args: None
- DefaultDublinCoreImpl.notifyModified = patched_notifyModified
+ # notifyModified lives in plone.dexterity but
+ # older versions used notifyModified from
+ # Products.CMFDefault.DublinCore.DefaultDublinCoreImpl
+ patch = lambda *args: None
+ old_notifyModified = getattr(DexterityContent, 'notifyModified', None)
+ DexterityContent.notifyModified = patch
site_props.manage_changeProperties(enable_link_integrity_checks=False)
@@ -132,7 +135,11 @@ def __call__(self,
enable_link_integrity_checks=link_integrity
)
- DefaultDublinCoreImpl.notifyModified = old_notifyModified
+ # reset notifyModified to old state
+ if old_notifyModified is None:
+ del DexterityContent.notifyModified
+ else:
+ DexterityContent.notifyModified = old_notifyModified
endtime = datetime.now()
duration = (endtime - starttime).seconds
diff --git a/plone/app/contenttypes/tests/test_migration.py b/plone/app/contenttypes/tests/test_migration.py
index dab73b2..777f606 100644
--- a/plone/app/contenttypes/tests/test_migration.py
+++ b/plone/app/contenttypes/tests/test_migration.py
@@ -808,7 +808,7 @@ def test_modifield_date_is_unchanged(self):
at_newsitem = at_folder1['newsitem']
# be 100% sure the migration-date is after the creation-date
- time.sleep(0.1)
+ time.sleep(0.5)
# relate them
at_doc1.setRelatedItems([at_doc2])
@@ -817,6 +817,13 @@ def test_modifield_date_is_unchanged(self):
at_folder1.setRelatedItems([at_doc2])
at_folder2.setRelatedItems([at_doc1])
+ at_folder1_date = at_folder1.ModificationDate()
+ at_folder2_date = at_folder2.ModificationDate()
+ at_folder3_date = at_folder3.ModificationDate()
+ at_doc1_date = at_doc1.ModificationDate()
+ at_doc2_date = at_doc2.ModificationDate()
+ at_doc3_date = at_doc3.ModificationDate()
+
# migrate content
applyProfile(self.portal, 'plone.app.contenttypes:default')
@@ -845,30 +852,12 @@ def test_modifield_date_is_unchanged(self):
self.assertTrue(at_folder2 is not dx_folder2)
# assert ModificationDates
- self.assertEqual(
- at_folder1.ModificationDate(),
- dx_folder1.ModificationDate()
- )
- self.assertEqual(
- at_folder2.ModificationDate(),
- dx_folder2.ModificationDate()
- )
- self.assertEqual(
- at_folder3.ModificationDate(),
- dx_folder3.ModificationDate()
- )
- self.assertEqual(
- at_doc1.ModificationDate(),
- dx_doc1.ModificationDate()
- )
- self.assertEqual(
- at_doc2.ModificationDate(),
- dx_doc2.ModificationDate()
- )
- self.assertEqual(
- at_doc3.ModificationDate(),
- dx_doc3.ModificationDate()
- )
+ self.assertEqual(at_folder1_date, dx_folder1.ModificationDate())
+ self.assertEqual(at_folder2_date, dx_folder2.ModificationDate())
+ self.assertEqual(at_folder3_date, dx_folder3.ModificationDate())
+ self.assertEqual(at_doc1_date, dx_doc1.ModificationDate())
+ self.assertEqual(at_doc2_date, dx_doc2.ModificationDate())
+ self.assertEqual(at_doc3_date, dx_doc3.ModificationDate())
# assert single references
dx_doc1_related = [x.to_object for x in dx_doc1.relatedItems]
Repository: plone.app.contenttypes
Branch: refs/heads/master
Date: 2014-02-12T10:40:21-08:00
Author: Philip Bauer (pbauer) <bauer at starzel.de>
Commit: https://github.com/plone/plone.app.contenttypes/commit/ad1235a7373761178e4c10931e17221390488be9
add i18n-domain
Files changed:
M plone/app/contenttypes/browser/templates/archetypes_warning_viewlet.pt
M plone/app/contenttypes/browser/viewlets.py
diff --git a/plone/app/contenttypes/browser/templates/archetypes_warning_viewlet.pt b/plone/app/contenttypes/browser/templates/archetypes_warning_viewlet.pt
index cceac46..bcac682 100644
--- a/plone/app/contenttypes/browser/templates/archetypes_warning_viewlet.pt
+++ b/plone/app/contenttypes/browser/templates/archetypes_warning_viewlet.pt
@@ -1,4 +1,5 @@
-<dl class="portalMessage alert-box secondary warning">
+<dl class="portalMessage alert-box secondary warning"
+ i18n:domain="plone">
<dt i18n:translate="">Warning</dt>
<dd>
<tal:manager tal:condition="not:view/can_migrate">
diff --git a/plone/app/contenttypes/browser/viewlets.py b/plone/app/contenttypes/browser/viewlets.py
index 1edee8b..32772a7 100644
--- a/plone/app/contenttypes/browser/viewlets.py
+++ b/plone/app/contenttypes/browser/viewlets.py
@@ -20,9 +20,9 @@ class ATWarningViewlet(ViewletBase):
def update(self):
self.available = False
- self.context = aq_inner(self.context)
if not HAS_ARCHETYPES:
return
+ self.context = aq_inner(self.context)
if not IBaseObject.providedBy(self.context):
return
context_fti = self.context.getTypeInfo()
Repository: plone.app.contenttypes
Branch: refs/heads/master
Date: 2014-02-12T10:43:10-08:00
Author: Philip Bauer (pbauer) <bauer at starzel.de>
Commit: https://github.com/plone/plone.app.contenttypes/commit/c6c177736f5cb5f2408977f45da5198bf8a746d9
Merge branch 'master' into #102_warning_for_uneditable_content
Files changed:
Repository: plone.app.contenttypes
Branch: refs/heads/master
Date: 2014-02-12T10:47:05-08:00
Author: Philip Bauer (pbauer) <bauer at starzel.de>
Commit: https://github.com/plone/plone.app.contenttypes/commit/16b5d7271a164dc70bb61e73506ba5beb534dfd0
Merge pull request #119 from plone/#102_warning_for_uneditable_content
add warning for uneditable content (fixes #102)
Files changed:
A plone/app/contenttypes/browser/templates/archetypes_warning_viewlet.pt
A plone/app/contenttypes/browser/viewlets.py
M plone/app/contenttypes/browser/configure.zcml
M plone/app/contenttypes/tests/test_migration.py
diff --git a/plone/app/contenttypes/browser/configure.zcml b/plone/app/contenttypes/browser/configure.zcml
index c8af09a..f2543b6 100644
--- a/plone/app/contenttypes/browser/configure.zcml
+++ b/plone/app/contenttypes/browser/configure.zcml
@@ -241,6 +241,15 @@
allowed_interface="plone.app.contenttypes.browser.utils.IUtils"
/>
+ <browser:viewlet
+ name="archetypes_warning_viewlet"
+ for="Products.Archetypes.interfaces.base.IBaseObject"
+ manager="plone.app.layout.viewlets.interfaces.IAboveContent"
+ class=".viewlets.ATWarningViewlet"
+ template="templates/archetypes_warning_viewlet.pt"
+ layer="plone.app.contenttypes.interfaces.IPloneAppContenttypesLayer"
+ permission="cmf.ModifyPortalContent" />
+
<!-- Query string widget -->
<adapter factory=".widgets.QueryStringFieldWidget" />
diff --git a/plone/app/contenttypes/browser/templates/archetypes_warning_viewlet.pt b/plone/app/contenttypes/browser/templates/archetypes_warning_viewlet.pt
new file mode 100644
index 0000000..bcac682
--- /dev/null
+++ b/plone/app/contenttypes/browser/templates/archetypes_warning_viewlet.pt
@@ -0,0 +1,20 @@
+<dl class="portalMessage alert-box secondary warning"
+ i18n:domain="plone">
+ <dt i18n:translate="">Warning</dt>
+ <dd>
+ <tal:manager tal:condition="not:view/can_migrate">
+ <span i18n:translate="">You can't edit this content. Ask your administrator to migrate to Dexterity!</span>
+ </tal:manager>
+ <tal:manager tal:condition="view/can_migrate">
+ <span i18n:translate="">You can't edit this content unless you
+ <a href="#" tal:attributes="href string:${context/plone_portal_state/portal_url}/@@atct_migrator">
+ migrate the default content-types to Dexterity.
+ </a>
+ </span>
+ </tal:manager>
+ </dd>
+</dl>
+
+<style type="text/css">
+#contentview-edit {display: None;}
+</style>
\ No newline at end of file
diff --git a/plone/app/contenttypes/browser/viewlets.py b/plone/app/contenttypes/browser/viewlets.py
new file mode 100644
index 0000000..32772a7
--- /dev/null
+++ b/plone/app/contenttypes/browser/viewlets.py
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+from AccessControl import getSecurityManager
+from Acquisition import aq_inner
+from Products.CMFCore.permissions import ManagePortal
+from plone.app.layout.viewlets import ViewletBase
+from plone.dexterity.interfaces import IDexterityFTI
+
+import pkg_resources
+
+try:
+ pkg_resources.get_distribution('Products.Archetypes')
+except pkg_resources.DistributionNotFound:
+ HAS_ARCHETYPES = False
+else:
+ from Products.Archetypes.interfaces.base import IBaseObject
+ HAS_ARCHETYPES = True
+
+
+class ATWarningViewlet(ViewletBase):
+
+ def update(self):
+ self.available = False
+ if not HAS_ARCHETYPES:
+ return
+ self.context = aq_inner(self.context)
+ if not IBaseObject.providedBy(self.context):
+ return
+ context_fti = self.context.getTypeInfo()
+ if IDexterityFTI.providedBy(context_fti):
+ self.available = True
+
+ def can_migrate(self):
+ sm = getSecurityManager()
+ if sm.checkPermission(ManagePortal, self.context):
+ return True
diff --git a/plone/app/contenttypes/tests/test_migration.py b/plone/app/contenttypes/tests/test_migration.py
index 93b590e..800df05 100644
--- a/plone/app/contenttypes/tests/test_migration.py
+++ b/plone/app/contenttypes/tests/test_migration.py
@@ -6,6 +6,7 @@
PLONE_APP_CONTENTTYPES_MIGRATION_TESTING
from plone.app.contenttypes.testing import set_browserlayer
from plone.event.interfaces import IEventAccessor
+from plone.app.testing import TEST_USER_ID, setRoles
from plone.app.testing import login
from plone.app.testing import applyProfile
from zope.component import getMultiAdapter
@@ -1146,3 +1147,28 @@ def test_migrate_xx_functions(self):
'.interfaces.IDexterityContent')
self.assertEqual(len(at_contents), 0)
self.assertEqual(len(dx_contents), 11)
+
+ def test_warning_for_uneditable_content(self):
+ set_browserlayer(self.request)
+ from plone.app.contenttypes.migration.migration import DocumentMigrator
+ from plone.app.contenttypes.interfaces import IDocument
+ self.portal.invokeFactory('Document', 'document')
+ self.portal.invokeFactory('News Item', 'newsitem')
+ at_document = self.portal['document']
+ at_newsitem = self.portal['newsitem']
+ applyProfile(self.portal, 'plone.app.contenttypes:default')
+ at_document_view = at_document.restrictedTraverse('')
+ self.assertTrue(
+ 'http://nohost/plone/@@atct_migrator' in at_document_view()
+ )
+ migrator = self.get_migrator(at_document, DocumentMigrator)
+ migrator.migrate()
+ dx_document = self.portal['document']
+ self.assertTrue(IDocument.providedBy(dx_document))
+ dx_document_view = dx_document.restrictedTraverse('@@view')
+ self.assertFalse('alert-box' in dx_document_view())
+ at_newsitem_view = at_newsitem.restrictedTraverse('')
+ self.assertTrue('alert-box' in at_newsitem_view())
+ self.assertTrue(
+ 'http://nohost/plone/@@atct_migrator' in at_newsitem_view()
+ )
-------------------------------------------------------------------------------
More information about the Testbot
mailing list