Skip to content

Commit

Permalink
[fc] Repository: plone.app.content
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2015-09-19T12:53:16+02:00
Author: vangheem (vangheem) <[email protected]>
Commit: plone/plone.app.content@977ebe1

Require cmf.ModifyPortalContent for content_status_history

Files changed:
M CHANGES.rst
M plone/app/content/browser/configure.zcml
Repository: plone.app.content
Branch: refs/heads/master
Date: 2015-09-19T18:06:14+02:00
Author: Philip Bauer (pbauer) <[email protected]>
Commit: plone/plone.app.content@9d62eae

Merge pull request #45 from plone/content-status-permission

Require cmf.ModifyPortalContent for content_status_history

Files changed:
M CHANGES.rst
M plone/app/content/browser/configure.zcml
  • Loading branch information
pbauer committed Sep 19, 2015
1 parent 8b9e246 commit 1cfbdfb
Showing 1 changed file with 51 additions and 271 deletions.
322 changes: 51 additions & 271 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,308 +1,88 @@
Repository: plone.app.layout
Repository: plone.app.content


Branch: refs/heads/master
Date: 2015-09-19T10:35:14-03:00
Author: Rodrigo Ferreira de Souza (rodfersou) <rodfersou@gmail.com>
Commit: https://github.com/plone/plone.app.layout/commit/42ac72e02d7d365462dbf8ae6ae86f903f5f3949
Date: 2015-09-19T12:53:16+02:00
Author: vangheem (vangheem) <vangheem@gmail.com>
Commit: https://github.com/plone/plone.app.content/commit/977ebe155bcc95b8cd20de74dd36f98f000f79d2

Respect @@site_controlpanel configuration to show publication date in document_byline
Require cmf.ModifyPortalContent for content_status_history

Files changed:
M CHANGES.rst
M plone/app/layout/viewlets/content.py
M plone/app/layout/viewlets/tests/test_content.py
M plone/app/content/browser/configure.zcml

diff --git a/CHANGES.rst b/CHANGES.rst
index 6d7fd29..713fa1b 100644
index 18a7dbe..d1d9599 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,6 +4,10 @@ Changelog
2.5.15 (unreleased)
@@ -4,7 +4,8 @@ Changelog
3.0.12 (unreleased)
-------------------

+- Respect @@site_controlpanel configuration to show publication date
+ in document_byline (closes `#1037`_).
+ [rodfersou]
+
- Fuzzy dates for document_byline (closes `#1000`_).
[rodfersou]
-- Nothing changed yet.
+- Require cmf.ModifyPortalContent for content_status_history
+ [vangheem]

@@ -1596,3 +1600,4 @@ Changelog

.. _`#741`: https://github.com/plone/Products.CMFPlone/issues/741
.. _`#1000`: https://github.com/plone/Products.CMFPlone/issues/1000
+.. _`#1037`: https://github.com/plone/Products.CMFPlone/issues/1037
diff --git a/plone/app/layout/viewlets/content.py b/plone/app/layout/viewlets/content.py
index d4ac86e..615d78f 100644
--- a/plone/app/layout/viewlets/content.py
+++ b/plone/app/layout/viewlets/content.py
@@ -143,10 +143,12 @@ def pub_date(self):
or if Effective Date is not set on object.
"""
# check if we are allowed to display publication date
- properties = getToolByName(self.context, 'portal_properties')
- site_properties = getattr(properties, 'site_properties')
- if not site_properties.getProperty('displayPublicationDateInByline',
- False):
+ registry = getUtility(IRegistry)
+ settings = registry.forInterface(
+ ISiteSchema,
+ prefix='plone')
+
+ if not settings.display_publication_date_in_byline:
return None
3.0.11 (2015-09-12)
diff --git a/plone/app/content/browser/configure.zcml b/plone/app/content/browser/configure.zcml
index 8082f9d..a1e56cb 100644
--- a/plone/app/content/browser/configure.zcml
+++ b/plone/app/content/browser/configure.zcml
@@ -34,7 +34,7 @@
for="*"
name="content_status_history"
class=".content_status_history.ContentStatusHistoryView"
- permission="zope2.View"
+ permission="cmf.ModifyPortalContent"
/>

# check if we have Effective Date set
diff --git a/plone/app/layout/viewlets/tests/test_content.py b/plone/app/layout/viewlets/tests/test_content.py
index 0a766c6..eddd8d8 100644
--- a/plone/app/layout/viewlets/tests/test_content.py
+++ b/plone/app/layout/viewlets/tests/test_content.py
@@ -1,7 +1,8 @@
from DateTime import DateTime
-from plone.app.layout.viewlets.tests.base import ViewletsTestCase
-from plone.app.layout.viewlets.content import HistoryByLineView
from plone.app.layout.viewlets.content import ContentRelatedItems
+from plone.app.layout.viewlets.content import DocumentBylineViewlet
+from plone.app.layout.viewlets.content import HistoryByLineView
+from plone.app.layout.viewlets.tests.base import ViewletsTestCase
from plone.locking.interfaces import ILockable
from plone.registry.interfaces import IRegistry
from Products.CMFPlone.interfaces import ISecuritySchema
@@ -25,7 +26,6 @@ class IMyDexterityItem(Interface):
""" Dexterity test type
"""

-
class TestDocumentBylineViewletView(ViewletsTestCase):
"""
Test the document by line viewlet
@@ -42,6 +42,71 @@ def afterSetUp(self):

def _get_viewlet(self):
request = self.app.REQUEST
+ viewlet = DocumentBylineViewlet(self.context, request, None, None)
+ viewlet.update()
+ return viewlet
+
+ def test_anonymous_locked_icon(self):
+ viewlet = self._get_viewlet()
+ ILockable(self.context).lock()
+ self.logout()
+ viewlet = self._get_viewlet()
+ self.assertEqual(viewlet.locked_icon(), '')
+
+ def test_locked_icon(self):
+ viewlet = self._get_viewlet()
+ self.assertEqual(viewlet.locked_icon(), "")
+ ILockable(self.context).lock()
+ lockIconUrl = (
+ '<img src="http://nohost/plone/lock_icon.png" alt="" '
+ 'title="Locked" height="16" width="16" />'
+ )
+ self.assertEqual(viewlet.locked_icon(), lockIconUrl)
+
+ def test_pub_date(self):
+ # configure our portal to enable publication date on pages globally on
+ # the site
+ registry = getUtility(IRegistry)
+ settings = registry.forInterface(
+ ISiteSchema,
+ prefix='plone')
+
+ settings.display_publication_date_in_byline = True
+
+ self.logout()
+ viewlet = self._get_viewlet()
+
+ # publication date should be None as there is not Effective date set
+ # for our document yet
+ self.assertEqual(viewlet.pub_date(), None)
+
+ # now set effective date for our document
+ effective = DateTime()
+ self.context.setEffectiveDate(effective)
+ self.assertEqual(viewlet.pub_date(), DateTime(effective.ISO8601()))
+
+ # now switch off publication date globally on the site and see if
+ # viewlet returns None for publication date
+ settings.display_publication_date_in_byline = False
+ self.assertEqual(viewlet.pub_date(), None)
+
+
+class TestHistoryBylineViewletView(ViewletsTestCase):
+ """
+ Test the document by line viewlet
+ """
+ def afterSetUp(self):
+ self.folder.invokeFactory('Document', 'doc1', title='Document 1')
+ self.context = self.folder['doc1']
+
+ registry = getUtility(IRegistry)
+ self.security_settings = registry.forInterface(
+ ISecuritySchema,
+ prefix='plone',
+ )
+
+ def _get_viewlet(self):
+ request = self.app.REQUEST
viewlet = HistoryByLineView(self.context, request)
viewlet.update()
return viewlet
<!-- Folder factories -->


Repository: plone.app.layout
Repository: plone.app.content


Branch: refs/heads/master
Date: 2015-09-19T10:57:24-05:00
Author: Nathan Van Gheem (vangheem) <[email protected]>
Commit: https://github.com/plone/plone.app.layout/commit/dd1f14dd40026a1501ca7e3af07994a7f1c25441
Date: 2015-09-19T18:06:14+02:00
Author: Philip Bauer (pbauer) <[email protected]>
Commit: https://github.com/plone/plone.app.content/commit/9d62eae385d04a51ecb6da042372807e800228c5

Merge pull request #62 from plone/issue_1037
Merge pull request #45 from plone/content-status-permission

Issue 1037 - Respect @@site_controlpanel configuration to show publication date in…
Require cmf.ModifyPortalContent for content_status_history

Files changed:
M CHANGES.rst
M plone/app/layout/viewlets/content.py
M plone/app/layout/viewlets/tests/test_content.py
M plone/app/content/browser/configure.zcml

diff --git a/CHANGES.rst b/CHANGES.rst
index 6d7fd29..713fa1b 100644
index 18a7dbe..d1d9599 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,6 +4,10 @@ Changelog
2.5.15 (unreleased)
@@ -4,7 +4,8 @@ Changelog
3.0.12 (unreleased)
-------------------

+- Respect @@site_controlpanel configuration to show publication date
+ in document_byline (closes `#1037`_).
+ [rodfersou]
+
- Fuzzy dates for document_byline (closes `#1000`_).
[rodfersou]

@@ -1596,3 +1600,4 @@ Changelog

.. _`#741`: https://github.com/plone/Products.CMFPlone/issues/741
.. _`#1000`: https://github.com/plone/Products.CMFPlone/issues/1000
+.. _`#1037`: https://github.com/plone/Products.CMFPlone/issues/1037
diff --git a/plone/app/layout/viewlets/content.py b/plone/app/layout/viewlets/content.py
index d4ac86e..615d78f 100644
--- a/plone/app/layout/viewlets/content.py
+++ b/plone/app/layout/viewlets/content.py
@@ -143,10 +143,12 @@ def pub_date(self):
or if Effective Date is not set on object.
"""
# check if we are allowed to display publication date
- properties = getToolByName(self.context, 'portal_properties')
- site_properties = getattr(properties, 'site_properties')
- if not site_properties.getProperty('displayPublicationDateInByline',
- False):
+ registry = getUtility(IRegistry)
+ settings = registry.forInterface(
+ ISiteSchema,
+ prefix='plone')
+
+ if not settings.display_publication_date_in_byline:
return None
-- Nothing changed yet.
+- Require cmf.ModifyPortalContent for content_status_history
+ [vangheem]

# check if we have Effective Date set
diff --git a/plone/app/layout/viewlets/tests/test_content.py b/plone/app/layout/viewlets/tests/test_content.py
index 0a766c6..eddd8d8 100644
--- a/plone/app/layout/viewlets/tests/test_content.py
+++ b/plone/app/layout/viewlets/tests/test_content.py
@@ -1,7 +1,8 @@
from DateTime import DateTime
-from plone.app.layout.viewlets.tests.base import ViewletsTestCase
-from plone.app.layout.viewlets.content import HistoryByLineView
from plone.app.layout.viewlets.content import ContentRelatedItems
+from plone.app.layout.viewlets.content import DocumentBylineViewlet
+from plone.app.layout.viewlets.content import HistoryByLineView
+from plone.app.layout.viewlets.tests.base import ViewletsTestCase
from plone.locking.interfaces import ILockable
from plone.registry.interfaces import IRegistry
from Products.CMFPlone.interfaces import ISecuritySchema
@@ -25,7 +26,6 @@ class IMyDexterityItem(Interface):
""" Dexterity test type
"""

-
class TestDocumentBylineViewletView(ViewletsTestCase):
"""
Test the document by line viewlet
@@ -42,6 +42,71 @@ def afterSetUp(self):
3.0.11 (2015-09-12)
diff --git a/plone/app/content/browser/configure.zcml b/plone/app/content/browser/configure.zcml
index 8082f9d..a1e56cb 100644
--- a/plone/app/content/browser/configure.zcml
+++ b/plone/app/content/browser/configure.zcml
@@ -34,7 +34,7 @@
for="*"
name="content_status_history"
class=".content_status_history.ContentStatusHistoryView"
- permission="zope2.View"
+ permission="cmf.ModifyPortalContent"
/>

def _get_viewlet(self):
request = self.app.REQUEST
+ viewlet = DocumentBylineViewlet(self.context, request, None, None)
+ viewlet.update()
+ return viewlet
+
+ def test_anonymous_locked_icon(self):
+ viewlet = self._get_viewlet()
+ ILockable(self.context).lock()
+ self.logout()
+ viewlet = self._get_viewlet()
+ self.assertEqual(viewlet.locked_icon(), '')
+
+ def test_locked_icon(self):
+ viewlet = self._get_viewlet()
+ self.assertEqual(viewlet.locked_icon(), "")
+ ILockable(self.context).lock()
+ lockIconUrl = (
+ '<img src="http://nohost/plone/lock_icon.png" alt="" '
+ 'title="Locked" height="16" width="16" />'
+ )
+ self.assertEqual(viewlet.locked_icon(), lockIconUrl)
+
+ def test_pub_date(self):
+ # configure our portal to enable publication date on pages globally on
+ # the site
+ registry = getUtility(IRegistry)
+ settings = registry.forInterface(
+ ISiteSchema,
+ prefix='plone')
+
+ settings.display_publication_date_in_byline = True
+
+ self.logout()
+ viewlet = self._get_viewlet()
+
+ # publication date should be None as there is not Effective date set
+ # for our document yet
+ self.assertEqual(viewlet.pub_date(), None)
+
+ # now set effective date for our document
+ effective = DateTime()
+ self.context.setEffectiveDate(effective)
+ self.assertEqual(viewlet.pub_date(), DateTime(effective.ISO8601()))
+
+ # now switch off publication date globally on the site and see if
+ # viewlet returns None for publication date
+ settings.display_publication_date_in_byline = False
+ self.assertEqual(viewlet.pub_date(), None)
+
+
+class TestHistoryBylineViewletView(ViewletsTestCase):
+ """
+ Test the document by line viewlet
+ """
+ def afterSetUp(self):
+ self.folder.invokeFactory('Document', 'doc1', title='Document 1')
+ self.context = self.folder['doc1']
+
+ registry = getUtility(IRegistry)
+ self.security_settings = registry.forInterface(
+ ISecuritySchema,
+ prefix='plone',
+ )
+
+ def _get_viewlet(self):
+ request = self.app.REQUEST
viewlet = HistoryByLineView(self.context, request)
viewlet.update()
return viewlet
<!-- Folder factories -->


0 comments on commit 1cfbdfb

Please sign in to comment.