控制谁可以查看您的djangocms博客帖子
项目描述
控制谁可以查看您的djangocms博客帖子
安装
-
安装此包
python3 -m pip install djangocms-blog-view-restrictions
-
将其添加到您的
INSTALLED_APPS
"djangocms_blog_view_restrictions",
-
运行迁移
python3 manage.py migrate djangocms_blog_view_restrictions
使用
在创建/编辑博客帖子时,一个新的“视图限制”部分允许您定义多个允许查看帖子的用户/组。如果满足任何限制条件,则用户被允许查看帖子。
然后您需要负责在您的 djangocms_blog/post_detail.html
模板中隐藏帖子内容(部分或全部)
{% extends "djangocms_blog/post_detail.html" %}
{% load blog_view_restrictions_tags %}
{% block content_blog %}
<article>
{{ post.abstract }}
{% if request.user|can_view_post:post %}
{% if post.app_config.use_placeholder %}
<div class="blog-content">{% render_placeholder post.content %}</div>
{% else %}
<div class="blog-content">{% render_model post "post_text" "post_text" "" "safe" %}</div>
{% endif %}
{% else %}
This post is for subscribers only.
{% endif %}
...
</article>
{% endblock content_blog %}
项目详情
关闭
djangocms_blog_view_restrictions-0.3.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | eb593733b4184b6a5c82d33cf34c8bde6d85a0e662b24203fa579325a0430327 |
|
MD5 | d8ffb989b36e22b01523ce6b13cc6865 |
|
BLAKE2b-256 | 825f83298bb46a825f7e2c7784704f3a3377c32545ee41841f867436ce7232f8 |
关闭
djangocms_blog_view_restrictions-0.3.0-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | ae0647ef8aceffcf4c4b5c1c381245c16bc3e54964a1ca163b096307664efd14 |
|
MD5 | 8094151dc07c154569ea5c1e59ccf2e1 |
|
BLAKE2b-256 | 6452263c61805d523622eb9d3741c76c49d8f6a1fc6d2c9c32e84699c21c272d |