web2py 中的组成员资格表单

发布于 2024-12-29 14:44:59 字数 149 浏览 0 评论 0原文

web2py 有一个很好的 RBAC 系统以及许多内置的表单来管理用户。我找不到一个来管理群组成员身份的人。我意识到 appadmin 中有一个,但我需要在我的应用程序中使用一个。理想情况下,我希望在用户注册/个人资料页面中看到不同组的复选框。

我怎样才能做到这一点?

web2py has a nice RBAC system as well as many built-in forms to manage users. I can't see to find one to manage group membership. I realize there's one in appadmin, but I need to use one in my app. Ideally, I'd like to see checkboxes for the different groups in the user registration/profile page.

How can I accomplish this?

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

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

发布评论

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

评论(1

↘紸啶 2025-01-05 14:44:59

我认为没有为此内置任何标准,但您可以使用 Crud,或者使用 SQLFORM.grid / SQLFORM.smartgrid< /a>.例如:

def manage_groups():
    return dict(form=SQLFORM.grid(db.auth_membership))

或者

def manage_users():
    return dict(form=SQLFORM.smartgrid(db.auth_users))

如果您想在注册/个人资料页面上选择多个组,那就有点复杂,但仍然不太困难。您必须向表单添加复选框或多选,并且在提交表单时,控制器中有一些逻辑可以根据所选的成员资格处理对 db.auth_membership 的插入。

I don't think there's anything standard built in for this, but you could easily build your own using Crud, or even more easily with SQLFORM.grid / SQLFORM.smartgrid. For example:

def manage_groups():
    return dict(form=SQLFORM.grid(db.auth_membership))

or

def manage_users():
    return dict(form=SQLFORM.smartgrid(db.auth_users))

If you want to select multiple groups on a registration/profile page, that's a little more complicated, but still not too difficult. You'd have to add checkboxes or a multiselect to the form, and when the form is submitted, have some logic in the controller that handles the inserts into db.auth_membership based on the memberships selected.

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