Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharing tab shows participation policy description #25

Merged
merged 1 commit into from
Jul 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/ploneintranet/workspace/browser/viewlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from plone import api
from plone.app.layout.viewlets import ViewletBase

from ploneintranet.workspace.browser.forms import particip_vocab


class JoinViewlet(ViewletBase):
""" Allows users to join a self-joining workspace """
Expand Down Expand Up @@ -56,4 +58,6 @@ def visible(self):
return url.endswith('@@sharing')

def participant_policy(self):
return self.context.participant_policy.title()
key = self.context.participant_policy
term = particip_vocab.by_value.get(key)
return term.title
23 changes: 23 additions & 0 deletions src/ploneintranet/workspace/tests/test_viewlets.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from collective.workspace.interfaces import IWorkspace
from plone import api

from ploneintranet.workspace.browser.forms import particip_vocab
from ploneintranet.workspace.browser.viewlets import JoinViewlet
from ploneintranet.workspace.browser.viewlets import SharingViewlet
from ploneintranet.workspace.tests.base import BaseTestCase


Expand Down Expand Up @@ -56,3 +58,24 @@ def test_viewlet(self):
viewlet = JoinViewlet(self.folder, self.request, None, None)
url = "%s/%s" % (self.workspace.absolute_url(), "joinme")
self.assertEqual(viewlet.join_url(), url)


class TestSharingViewlet(BaseTestCase):

def setUp(self):
super(TestSharingViewlet, self).setUp()
self.portal = self.layer["portal"]
self.request = self.layer["request"]

self.login_as_portal_owner()
self.workspace = api.content.create(
self.portal,
"ploneintranet.workspace.workspacefolder",
"demo-workspace",
title="Demo Workspace")

def test_viewlet_message_is_correct(self):
viewlet = SharingViewlet(self.workspace, self.request, None, None)
key = self.workspace.participant_policy
term = particip_vocab.by_value.get(key)
self.assertEqual(viewlet.participant_policy(), term.title)