列出用户在 Plone 4 中具有审阅者访问权限的文件夹
我的网站中有一个文件夹,其中包含数百个子文件夹。每个子文件夹代表一个文档提交,并且其中包含与提交相关的项目。每个子文件夹的默认页面是自定义页面模板(基于文档),该模板根据查看用户的角色显示略有不同的信息。例如,具有管理者角色的用户看到的内容与具有审阅者角色或编辑者角色的用户略有不同。站点上的用户被分配给不同的文件夹不同的角色 - 例如,管理员可以将用户 A 分配为文件夹 1-5 的审阅者,将用户 B 分配为文件夹 6-10 的审阅者。
我想在用户的仪表板中创建一个 portlet,显示他们已被分配审阅者访问权限的所有文件夹,或者如果更简单的话,我也可以只在仪表板中添加一个转到页面模板的链接。我最初以为我会创建一个集合,但没有内置的“挂钩”来显示用户被分配特定角色的内容。
我不能简单地限制它,使内容不可见,除非您具有审阅者角色,因为它需要由所有经过身份验证的用户查看。
我一直在使用标准视图(folder_listing)模板来尝试找到正确的代码。我尝试在“entry”槽的开头定义一个“roles”变量:
tal:define="member context/portal_membership/getAuthenticatedMember;
roles python:member.getRolesInContext(item);"
并使用该项目的条件来仅显示用户具有审阅者角色的项目:
tal:condition="python:'Reviewer' in roles"
这是完整页面模板的链接:< a href="http://www.tempfiles.net/download/201110/214265/folder_listing.html" rel="nofollow">http://www.tempfiles.net/download/201110/214265/folder_listing.html
当我使用它时,我没有得到任何结果。我对其进行了稍微修改,以便它只是在页面中向我显示它所扮演的角色,并且我不认为它会拉动当前项目的角色。
如果能朝着正确的方向推动,我们将不胜感激!
I have a folder in my site that contains hundreds of subfolders. Each subfolder represents a document submission, and has items in it that are related to the submission. The default page for each subfolder is a custom page template (based on Document) that displays slightly different information depending on what the viewing users Role is. For instance, users with Manager role see something slightly different than users with Reviewer role or Editor role. Users on the site are assigned different roles to different folders - for instance, the Manager can assign User A as a Reviewer on folders 1-5, and User B as a Reviewer on folders 6-10.
I'd like to create a portlet in the user's dashboard that displays all folders that they have been assigned Reviewer access to, or I'd be OK with just a link in the dashboard that goes to a Page Template if that's easier. I originally thought I'd create a collection, but there is no built in "hook" to display content that a user is assigned a certain role on.
I can't simply restrict it so that the content is not viewable unless you have reviewer role, because it needs to be viewable by all authenticated users.
I've been playing with the standard view (folder_listing) template to try and find the right code. I've tried defining a "roles" variable at the beginning of the "entry" slot:
tal:define="member context/portal_membership/getAuthenticatedMember;
roles python:member.getRolesInContext(item);"
and use a condition to the item to display only items that the user has reviewer role on:
tal:condition="python:'Reviewer' in roles"
Here is a link to the full page template: http://www.tempfiles.net/download/201110/214265/folder_listing.html
When I use that, I just get no result. I've modified it slightly so that it just shows me in the page what role it's getting, and I don't think it's pulling the role of the current item.
A push in the right direction would be greatly appreciated!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为问题在于
getRolesInContext
正如其名称所示,需要上下文,而不仅仅是大脑。您应该尝试提供真实的对象:否则,如果您只想查找本地分配的角色,您可以使用此代码:
此(未经测试的)代码受到 共享视图 在 plone.app.workflow 包中。
您可以将此代码放在自定义 portlet 中,也可以放在 Renderer 类的方法中。
I think the problem is that
getRolesInContext
, as the name says, expects a context, not only a brain. You should try to provide the real object:Otherwise if you want to find only local assigned roles you could use this code:
This (untested) code is inspired to the sharing view in plone.app.workflow package.
You can put this code in a custom portlet, maybe in a method in the Renderer class.