Skip to content

Commit

Permalink
Sharing tab shows participation policy description
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapolas K committed Jul 4, 2014
1 parent e1a8ab9 commit 2f0bc25
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
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)

0 comments on commit 2f0bc25

Please sign in to comment.