Skip to content

Commit

Permalink
Merge pull request #90 from plone/issue_1556
Browse files Browse the repository at this point in the history
Display document byline viewlet only to anonymous users
  • Loading branch information
jensens committed Jun 2, 2016
2 parents 0fb5aff + 7a603af commit 5e486e8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 69 deletions.
7 changes: 6 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ Bug fixes:

Incompatibilities:

- Deprecated ``plone.app.layout.globals.pattern_settings``.
- Deprecated ``plone.app.layout.globals.pattern_settings``.
Moved view to ``Products.CMFPlone.patterns.view``.
Deprecated also pointless interface for this view.
Addresses https://github.com/plone/Products.CMFPlone/issues/1513 and goes together with https://github.com/plone/Products.CMFPlone/issues/1514.
[jensens]

Fixes:

- Document byline viewlet is now displayed only to anonymous users if permited by the `Allow anyone to view 'about' information` option in the `Security Settings` of `Site Setup` (closes `CMFPlone#1556`_).
Code used to show the lock status and history view was removed from the document byline as this information was not available to anonymous users anyway.
[hvelarde]

- Fix body class ``pat-markspeciallinks`` not set.
Fixes #84.
[thet]
Expand Down Expand Up @@ -1720,3 +1724,4 @@ Fixes:
.. _`CMFPlone#1037`: https://github.com/plone/Products.CMFPlone/issues/1037
.. _`CMFPlone#1151`: https://github.com/plone/Products.CMFPlone/issues/1151
.. _`CMFPlone#1178`: https://github.com/plone/Products.CMFPlone/issues/1178
.. _`CMFPlone#1556`: https://github.com/plone/Products.CMFPlone/issues/1556
38 changes: 1 addition & 37 deletions plone/app/layout/viewlets/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,43 +71,7 @@ def show(self):
ISecuritySchema,
prefix='plone',
)
return not self.anonymous or settings.allow_anon_views_about

def show_history(self):
has_access_preview_versions_permission = _checkPermission(
'CMFEditions: Access previous versions',
self.context
)
if not has_access_preview_versions_permission:
return False
if IViewView.providedBy(self.__parent__):
return True
if IFolderContentsView.providedBy(self.__parent__):
return True
return False

def locked_icon(self):
if not getSecurityManager().checkPermission('Modify portal content',
self.context):
return ""

locked = False
lock_info = queryMultiAdapter((self.context, self.request),
name='plone_lock_info')
if lock_info is not None:
locked = lock_info.is_locked()
else:
context = aq_inner(self.context)
lockable = getattr(
context.aq_explicit, 'wl_isLocked', None) is not None
locked = lockable and context.wl_isLocked()

if not locked:
return ""

portal = self.portal_state.portal()
icon = portal.restrictedTraverse('lock_icon.png')
return icon.tag(title='Locked')
return self.anonymous and settings.allow_anon_views_about

def creator(self):
return self.context.Creator()
Expand Down
14 changes: 0 additions & 14 deletions plone/app/layout/viewlets/document_byline.pt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
id="plone-document-byline"
i18n:domain="plone"
tal:condition="view/show">
<span id="lock-icon"
tal:define="lock_icon view/locked_icon"
tal:condition="python:lock_icon">
<img tal:replace="structure lock_icon" />
</span>

<tal:creator tal:define="creator_short_form view/creator;"
tal:condition="creator_short_form">
<tal:name tal:define="creator_long_form string:?author=${creator_short_form};
Expand Down Expand Up @@ -58,14 +52,6 @@
i18n:translate="time_expired">expired</span>
</tal:expired>

<span class="contentHistory" id="content-history"
tal:condition="view/show_history">
<a href="#"
tal:attributes="href string:${here/absolute_url}/@@historyview"
i18n:translate="label_history">History</a>
</span>

<div class="documentContributors"
tal:define="contributors context/Contributors"
tal:condition="contributors"
Expand Down
17 changes: 0 additions & 17 deletions plone/app/layout/viewlets/tests/test_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,6 @@ def _get_viewlet(self):
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
Expand Down

0 comments on commit 5e486e8

Please sign in to comment.