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 %}
Metadata
Release files for djangocms-blog-view-restrictions 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| djangocms_blog_view_restrictions-0.3.0.tar.gz | 18.9 kB | Without provenance | Details for djangocms_blog_view_restrictions-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| djangocms_blog_view_restrictions-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for djangocms_blog_view_restrictions-0.3.0-py3-none-any.whl |
Total release size: 39.4 kB
Release files / djangocms_blog_view_restrictions-0.3.0.tar.gz
| Download URL | djangocms_blog_view_restrictions-0.3.0.tar.gz |
|---|---|
| Size | 18.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eb593733b4184b6a5c82d33cf34c8bde6d85a0e662b24203fa579325a0430327
|
|
BLAKE2b-256 checksum How to use checksums |
825f83298bb46a825f7e2c7784704f3a3377c32545ee41841f867436ce7232f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.8
|
Release files / djangocms_blog_view_restrictions-0.3.0-py3-none-any.whl
| Download URL | djangocms_blog_view_restrictions-0.3.0-py3-none-any.whl |
|---|---|
| Size | 20.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ae0647ef8aceffcf4c4b5c1c381245c16bc3e54964a1ca163b096307664efd14
|
|
BLAKE2b-256 checksum How to use checksums |
6452263c61805d523622eb9d3741c76c49d8f6a1fc6d2c9c32e84699c21c272d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.8
|
Security for djangocms-blog-view-restrictions 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.