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
File details
Details for the file djangocms_blog_view_restrictions-0.3.0.tar.gz
.
File metadata
- Download URL: djangocms_blog_view_restrictions-0.3.0.tar.gz
- Upload date:
- Size: 18.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb593733b4184b6a5c82d33cf34c8bde6d85a0e662b24203fa579325a0430327 |
|
MD5 | d8ffb989b36e22b01523ce6b13cc6865 |
|
BLAKE2b-256 | 825f83298bb46a825f7e2c7784704f3a3377c32545ee41841f867436ce7232f8 |
File details
Details for the file djangocms_blog_view_restrictions-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: djangocms_blog_view_restrictions-0.3.0-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae0647ef8aceffcf4c4b5c1c381245c16bc3e54964a1ca163b096307664efd14 |
|
MD5 | 8094151dc07c154569ea5c1e59ccf2e1 |
|
BLAKE2b-256 | 6452263c61805d523622eb9d3741c76c49d8f6a1fc6d2c9c32e84699c21c272d |