Skip to content

rykerls/mezzanine_page_auth

 
 

Repository files navigation

Overview

Mezzanine Page Auth is a Mezzanine module for adding group-level permissions to Pages.

A fork of Mezzanine_Page_Auth

This repository contains fixes to make mezzanine_page_auth compatible with more modern versions of Mezzanine and Django.

Dependencies

This fork has been tested on... - Mezzanine 4.3.1 - Django 1.11.17 - Python 2.7.15

Installation

Install from HEAD of this repository:

$ pip install git+https://github.com/rykerls/mezzanine_page_auth.git#egg=mezzanine_page_auth

Add mezzanine_page_auth to your INSTALLED_APPS setting before all mezzanine apps:

INSTALLED_APPS = (
    # ...
    'mezzanine_page_auth',
    'mezzanine.boot',
    'mezzanine.conf',
    'mezzanine.core',
    # ...
)

You will then want to create the necessary tables.:

$ python manage.py migrate mezzanine_page_auth

Middleware

Enable PageAuthMiddleware middleware in your settings module as follows:

MIDDLEWARE_CLASSES = (
    # ...
    "mezzanine.core.middleware..."
    "mezzanine.pages.middleware..."
    "mezzanine_page_auth.middleware.PageAuthMiddleware",
    # ...
)

The order of MIDDLEWARE_CLASSES is important. You should include the PageAuthMiddleware middleware after other Mezzanine middlewares in the list.

Template Context Processors

Enable page_auth template context processors in your settings module as follows:

TEMPLATES = [
   {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [
            os.path.join(PROJECT_ROOT, "templates")
        ],
        "OPTIONS": {
            "context_processors": [
            #...
            "mezzanine_page_auth.context_processors.page_auth",
            ]
]

Add mezzanine_page_auth.context_processors.page_auth to the end of the context_processors list.

Mezzanine Settings

Configure EXTRA_MODEL_FIELDS Mezzanine setting in your settings module as follows:

EXTRA_MODEL_FIELDS = (
    # ...
    (
        "mezzanine.pages.models.Page.groups",
        "ManyToManyField",
        ("auth.Group",),
        {"blank": True, "null": True, "verbose_name": 'groups',
         'symmetrical': False, 'through': "mezzanine_page_auth.PageAuthGroup"},
    ),
    # ...
)

for inject field groups into Mezzanine’s models (reference to Field Injection Mezzanine documantation).

License

Mezzanine Page Auth is BSD licensed.

About

A Mezzanine module for adding group-level permission to individual pages.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 81.4%
  • HTML 18.6%