Control who can view your djangocms-blog posts
Project description
Control who can view your djangocms blog posts
Install
-
Install the package
python3 -m pip install djangocms-blog-view-restrictions
-
Add it in your
INSTALLED_APPS
:"djangocms_blog_view_restrictions",
-
Run the migration:
python3 manage.py migrate djangocms_blog_view_restrictions
Usage
When creating/editing a blog post, a new "View restriction" section allows you to define multiple users/groups that are allowed to view the post. The user is allowed to view the post if any of the restrictions are met.
You are then responsible to hide partially or totally the post's content in your djangocms_blog/post_detail.html
template:
{% 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 %}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for djangocms_blog_view_restrictions-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c44fcf1077a0506b3028d0d4730218219222253ac119ab3ca2e37b8e9832b914 |
|
MD5 | 95a192205f4ba0fcf929b2e5d321fb25 |
|
BLAKE2b-256 | 9ca8a356ba76e7b2940ac4da18cd47e287006849b67ec0e7e07761e099292032 |
Close
Hashes for djangocms_blog_view_restrictions-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a11416f27b6ed056a0e635cf64ca7089e1117c1ac57249de798787ea3967d74 |
|
MD5 | b9fe0fba1d7c9c9a263de3062b0ab571 |
|
BLAKE2b-256 | 256fb0db224dffa0bf3a5beae157a4065934950b4db91f2979e35b549ea458ff |