Skip to content

Commit

Permalink
Merge pull request #31 from collective/hvelarde-button-anonymous
Browse files Browse the repository at this point in the history
Show the 'Listen' button to anonymous users only
  • Loading branch information
rodfersou committed Jul 11, 2016
2 parents f7572ae + 76cb614 commit 2474040
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
1.0b3 (unreleased)
------------------

- Nothing changed yet.
- Show the 'Listen' button to anonymous users only.
[hvelarde]


1.0b2 (2016-07-08)
Expand Down
9 changes: 9 additions & 0 deletions src/collective/texttospeech/browser/viewlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ class TextToSpeechViewlet(ViewletBase):
"""Viewlet with play button."""

def enabled(self):
"""Check if the viewlet must be shown in current context.
The viewlet is shown to anonymous users only if:
- it is globally enabled, and
- the content type in context is also enabled
"""
if not api.user.is_anonymous():
return False

globally_enabled = api.portal.get_registry_record(
ITextToSpeechControlPanel.__identifier__ + '.globally_enabled')
if not globally_enabled:
Expand Down
5 changes: 3 additions & 2 deletions src/collective/texttospeech/tests/test_texttospeech.robot
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ Test Text-To-Speech
Click Button Save
Page Should Contain Changes saved

# the button must be visible to logged in users
# the button must not be visible to logged in users
Go to ${TEST_DOC_URL}
Wait Until Element Is Visible css=${viewlet_button_selector}
Page Should Not Contain Element css=${viewlet_button_selector}

# the button must be visible to anonymous users
Disable Autologin
Go to ${TEST_DOC_URL}
Page Should Contain Element css=${viewlet_button_selector}
Wait Until Element Is Visible css=${viewlet_button_selector}

# test the reader
Expand Down

0 comments on commit 2474040

Please sign in to comment.