Plon 4:列出已被授予特定文件夹审阅者角色的成员

发布于 12-11 05:14 字数 1260 浏览 0 评论 0原文

我为文件夹创建了一个新视图(基于表格视图),只有常规查看者的标题和日期,但如果登录用户具有“编辑者”角色,它会显示一个附加列。该列需要列出已被授予该特定项目的“审阅者”角色的用户。例如,列将是:

Title    | Date  | (Reviewers)
Folder 1 | 10/04 | Johnny, Steve, Mary Sue
Folder 2 | 10/13 | Sam, Betty, Johnny

我已经能够根据经过身份验证的用户的角色隐藏/显示最后一列,但我似乎无法弄清楚如何仅列出具有审阅者访问权限的用户。我尝试过使用 searchForMembers(),但除了非常慢之外,我只能让它回显整个成员列表,或者根据站点范围的角色缩小范围,但我需要只获取手动添加的人员指定特定文件夹的审阅者角色。

这是整个专栏的代码:

<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>

当我有 Roles=['Member'] 时,它可以工作,但是如果我将其更改为“审阅者”,我什么也得不到 - 我想是因为没有人被指定为整个站点的审阅者,仅用于具体项目。我还尝试以各种方式使用 .listMembers() ,但似乎受到限制,我无法在页面模板中使用它。有没有办法解决这个问题,或者这是首先解决这个问题的“错误方法”?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

信仰2024-12-18 05:14:29

我两天前回答了一个几乎相同的问题:

列出用户在 Plone 4 中具有审阅者访问权限的文件夹

更新后的代码应如下所示:

from Products.CMFCore.utils import getToolByName

portal_url = getToolByName(context, "portal_url")
portal = portal_url.getPortalObject()
acl_users = portal.acl_users

res = []

local_roles = acl_users._getLocalRolesForDisplay(context)
for name, roles, rtype, rid in local_roles:
    if 'Reviewer' in roles:
        res.append((name,roles,rtype,rid))

我建议将这种文件 python 中的逻辑而不是页面模板中的逻辑。

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:

from Products.CMFCore.utils import getToolByName

portal_url = getToolByName(context, "portal_url")
portal = portal_url.getPortalObject()
acl_users = portal.acl_users

res = []

local_roles = acl_users._getLocalRolesForDisplay(context)
for name, roles, rtype, rid in local_roles:
    if 'Reviewer' in roles:
        res.append((name,roles,rtype,rid))

I'd suggest to put this kind of logic in the file python and not in the page template.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文