如何修改Wagtail CMS,以便任何用户都可以在自己的博客下发布博客文章 [英] How to modify wagtail CMS so that any user can post blog posts under their own blog

查看:111
本文介绍了如何修改Wagtail CMS,以便任何用户都可以在自己的博客下发布博客文章的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的网站,即Django App。
我已经安装了Wagtail,现在可以通过 www.example.com/cms 访问Wagtail CMS。 Wagtail在我的数据库上正常工作,当我依次进入设置用户时,所有现有用户都可见,在wagtail CMS管理页面中。

I have an existing website that is a Django App. I have installed Wagtail, and the Wagtail CMS is now accessible at www.example.com/cms. Wagtail is working correctly with my database, and all the existing users are visible when I go to settings and then users, in the wagtail CMS admin page.

我想使用Wagtail将博客功能添加到我的网站。

I want to use Wagtail to add blog functionality to my website.

要求


  1. 我希望任何用户能够创建一个新博客并将帖子添加到他们的博客中。

  2. 我希望用户创建的博客在 www.example.com/blogs上可见/ username /

  1. I want any user to be able to create a new blog and add posts to their blog.
  2. I want the blog created by a user to be visible at www.example.com/blogs/username/

如何设置Wagtail来完成此操作?

How can I set Wagtail up to accomplish this?

我在 http://docs.wagtail.io/en/v1.9/ ,但无法弄清楚从哪里开始进行修改。我还安装了示例博客项目( https://github.com/wagtail/wagtaildemo ),但是我也无法从中弄清楚如何完成上述的1和2。

I have checked the documentation at http://docs.wagtail.io/en/v1.9/ but could not figure out where to start with my modifications. I have also installed the example blog project (https://github.com/wagtail/wagtaildemo) but I was also unable to figure out how to accomplish 1 and 2 above from this.

任何完整的答案或一般性的提示,都非常欢迎。

Any complete answers, or general pointers, very welcome.

推荐答案

Wagtail内置的权限模型支持以下设置: http://docs.wagtail.io/en/stable/topics/permissions.html

The permission model built into Wagtail supports this kind of setup: http://docs.wagtail.io/en/stable/topics/permissions.html

为博客创建索引页面后,您将为该博客创建一个组(Wagtail管理员中的设置->组)-可能只包含一个用户,并且位于页面权限下部分,在该索引页面上为其分配添加和发布权限。从那时起,权限沿着树传播,添加权限包含编辑您自己创建的页面的能力,因此,这样的作用是使用户可以控制他们博客的子页面。

After creating the index page for a blog, you'd create a group (Settings -> Groups in the Wagtail admin) for that blog - possibly just containing a single user - and under the 'Page permissions' section, assign it 'add' and 'publish' permission on that index page. Permissions propagate down the tree from that point, and 'add' permission encompasses the ability to edit pages that you've created yourself, so this would have the effect of giving the user control over the subpages of their blog.

这与您描述的设置不太匹配,因为它涉及现有Wagtail管理员用户必须进行初始设置,而不是用户自己创建 博客。但是,由于所有这些配置都是通过创建/更新标准Django模型(例如 Group PagePermission )在内部完成的,因此从原理上讲,可以使用脚本编写此过程-例如,您可以在网站前端为设置我的博客实现Django视图,该视图运行以下步骤:

This doesn't quite match the setup you've described, since it involves an existing Wagtail admin user having to do the initial setup, rather than users creating their own blog. However, since all of this configuration is done internally by creating / updating standard Django models such as Group and PagePermission, it would be possible in principle to script this process - for example, you could implement a Django view for "Set up my blog" on your site front-end, which runs the following steps:


  • / blogs 下创建BlogIndexPage,标题/子句匹配 request.user.username (有关如何以编程方式创建页面的信息,请参见 https://stackoverflow.com/a/43041179/1853523

  • 为当前用户创建一个用户组( django.contrib.auth.models.Group ),并将其分配为 wagtailadmin.access_admin 权限(以便他们可以登录到Wagtail管理员)

  • 创建 wagtailcore.PagePermission 与新创建的组和博客索引页面相对应的对象,以及添加 permi会话并同样具有发布权限

  • Create a BlogIndexPage under /blogs with a title/slug matching request.user.username (see https://stackoverflow.com/a/43041179/1853523 for how to create pages programmatically)
  • Create a user group (django.contrib.auth.models.Group) for the current user, and assign them wagtailadmin.access_admin permission (so that they can log in to Wagtail admin)
  • Create a wagtailcore.PagePermission object corresponding to the newly-created group and blog index page, and 'add' permission; and likewise for 'publish' permission

这篇关于如何修改Wagtail CMS,以便任何用户都可以在自己的博客下发布博客文章的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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