使用 Workflow 实施配额

发布于 2024-11-18 13:05:15 字数 533 浏览 4 评论 0原文

需要有关实施简单配额系统的最佳实践的指导

我想限制会员向其会员文件夹添加自定义内容类型(称为令牌)的次数(我还创建了一个自定义会员文件夹)。

用例(限制会员可添加的令牌数量):

假设我们的自定义内容类型称为“令牌”。应该可以对可以添加的令牌数量设置限制。例如,限制设置为 2。 将两个令牌添加到其会员区后,他们不再有权添加 进一步的令牌。

我正在考虑的是

我正在研究 DCWorkflow 并想知道是否可以选择某种保护条件。我还查看了名为“quota”的插件的源代码,该插件使用 class/require zcml 指令(代码位于:http://svn.plone.org/svn/collective/quota/trunk/configure.zcml)。

看来我可能需要自定义成员文件夹,而不是“令牌”本身的工作流程。我将不胜感激对此的任何指示/指导。

Need guidance on best practice for implementing a simple quota system

I'd like to limit the number of times a Member can add a custom content type (called Token) to their Member Folder (I've also created a custom Member Folder).

Use Case (limit number of tokens addable by a Member):

Let's assume that our custom content type is called a 'Token'. It should be possible to set a limit on the number of tokens that can be added. E.g. the limit is set to 2.
After adding two tokens to their Member Area they no longer have permission to add
further tokens.

What I'm considering

I'm looking into DCWorkflow and wondering if some kind of guard condition may be an option. I also looked at the source code for an addon called 'quota' which uses a class/require zcml directive (code is here: http://svn.plone.org/svn/collective/quota/trunk/configure.zcml).

It seems that I may need to customize the Member Folder and not the workflow on the 'Token' itself. I would appreciate any pointers/guidance on this.

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

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

发布评论

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

评论(3

孤单情人 2024-11-25 13:05:15

我不认为这可以通过工作流程来实现,因为添加内容不是工作流程操作。我会为您的令牌类型使用自定义添加表单,并在用户已经拥有两个或更多令牌时禁止内容创建。

I don't believe this can be achieved with workflow, as adding content is not a workflow action. I would use a custom add form for your token type, and disallow content creation when the user already has two or more tokens.

我的黑色迷你裙 2024-11-25 13:05:15

您可以通过事件监控添加的内容类型对象的计数,并在对象计数超出限制时撤销添加权限。

活动文档:http://plone.org/products/ dexterity/documentation/manual/ Five.grok/core-components/events

权限撤销可以通过组来完成。只需从允许添加内容的组中删除用户即可。

You could monitor count of added content type objects with events and revoke the add permission when object count exceeds your limit.

Event docs: http://plone.org/products/dexterity/documentation/manual/five.grok/core-components/events

Permission revoking could be done for example with groups. Just remove user from the group that is allowed to add content.

洛阳烟雨空心柳 2024-11-25 13:05:15

您还可以重写成员文件夹的 allowedContentTypes 方法。

您可以根据需要从返回的列表中过滤任何 AT 类型。

好处是,您还可以获得经典的“添加新”下拉菜单,其中包含可添加类型的列表。

我在一个需要按组/角色限制项目数量的项目中做到了这一点。

You can also override the allowedContentTypes method of your Member Folder.

You can filter from the returned list any AT type based on whatever you want.

The good thing is that you get also the classic "add new" drop down menu updated with the list of addable types.

I did this in a project where I needed to limit number of items by group/role.

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