每页用户权限 [英] Wagtail per page user permission

查看:93
本文介绍了每页用户权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的任务是使用户能够编辑自己的页面。

My task is to enable users to edit their own page.

我看到了如何将特定页面的权限授予组,但是我该如何做

I see how to give permissions to a particular page to a group, but how do I do this for the user?

我曾尝试使用django Guardian:

I'd tried use django guardian:

UserObjectPermission。 objects.assign_perm('change_custompage',user,obj = custompage)

但这没有给我结果

我还找到了 wagtailcore_grouppagepermission 表,并意识到权限原理与Django auth_permission

I also found the wagtailcore_grouppagepermission table and realized that the permissions principle is not the same as used in django auth_permission

我想授予编辑权限,并访问wagtail admin,我不需要任何其他操作

I want to give permissions to edit, and access wagtail admin, I do not need anything else

在此特定任务中,由于 struct_blocks 而需要w,我认为这是一个了不起的概念。

In this particular task, wagtail I need because of the struct_blocks, I think this is a terrific concept.

现在,我看到两个选择:要么是覆盖模板,要么可以使用ag中的 struct_block 的所有功能,或者

Now I see two options: either an override template and the ability to use all the power of the struct_block outside the wagtail, or something to solve with permissions.

推荐答案

两种可能性:


  • 为每个用户创建一个组-似乎不是一种非常复杂的方法,但是可以通过一些脚本轻松实现...

  • 将您的用户放入一个具有在包含您所有用户页面的父页面上添加权限,但不能添加编辑权限。在Wagtail的权限模型中, http://docs.wagtail.io/zh/ v1.10.1 / topics / permissions.html 中的添加权限还可以编辑自己创建的页面。 (如果您希望预先创建页面,而不是让用户创建页面,则需要将页面记录的 owner 字段设置为相关用户。)

  • Create a group for each user - might not seem like a very sophisticated approach, but easily achievable with a bit of scripting...
  • Put your users in a group that has add permission, but not edit permission, on the parent page that contains all of your users' pages. In Wagtail's permission model http://docs.wagtail.io/en/v1.10.1/topics/permissions.html, 'add' permission also includes the ability to edit pages that you have created yourself. (If you'd rather have the pages created in advance, rather than having your users create them, then you need to set the owner field of the page record to the relevant user.)

这篇关于每页用户权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆