I’ve created a new view for a folder (based on Tabular view) the only the Title and Date for regular viewers, but if the logged in user had the “Editor” role, it shows an additional column. That column needs to list the users who have been given “Reviewer” role to that specific item. For instance, the columns would be:
Title | Date | (Reviewers)
Folder 1 | 10/04 | Johnny, Steve, Mary Sue
Folder 2 | 10/13 | Sam, Betty, Johnny
I’ve been able to hide/show the final column based on the authenticated user’s role, but I can’t seem to figure out how to list just the users who have reviewer access. I’ve tried using searchForMembers(), but in addition to being very slow, I can only get it to echo the entire list of Members, or narrowed based on site-wide roles, but I need to get just people who have been manually given Reviewer role on the specific folder.
Here’s the code for the entire column:
<td tal:define="is_manager python:test(here.portal_membership.getAuthenticatedMember().has_role('Manager'), 1, 0);"
tal:condition="is_manager">
<tal:block tal:define="results python:item.portal_membership.searchForMembers(roles=['Member']);">
<tal:block tal:condition="results"
tal:repeat="user results">
<tal:block tal:define="fullname python:user.getProperty('fullname')">
<span tal:replace="fullname">Full Name</span><span>, </span>
</tal:block>
</tal:block>
</tal:block>
</td>
It works when I have roles=[‘Member’], but if I change it to “Reviewer” I get nothing – I think because nobody is assigned as a Reviewer for the entire site, only for specific items. I’ve also tried using .listMembers() in various ways, but it seems that’s restricted and I can’t use it in the page template. Is there a way around this, or is this the “wrong way” to go about this in the first place?
I’ve answered to a nearly identical question 2 day ago:
List folders that a user has Reviewer access to in Plone 4
the updated code should look like this:
I’d suggest to put this kind of logic in the file python and not in the page template.