Socket
Socket
Sign inDemoInstall

djangocms-blog-view-restrictions

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

djangocms-blog-view-restrictions

Control who can view your djangocms-blog posts


Maintainers
1

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 %}

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc