Reference

Data Model

class django_roles_access.models.TemplateAccess(*args, **kwargs)[source]

Implements content security.

This model let administrator to add or remove Groups (roles) from roles attribute. In templates, users belonging to any added group will pass the check.

exception DoesNotExist
exception MultipleObjectsReturned
flag

Template’s flag, text label, to identify each template access object. Flag must be unique.

roles

One or more roles (django.contrib.auth.models.Group()) with access.

class django_roles_access.models.ViewAccess(*args, **kwargs)[source]

Implements security in views having a name.

The view name is view attribute value. The security for view name is configured with next two attributes: type (type of security) and roles (only if type is By role).

exception DoesNotExist
exception MultipleObjectsReturned
roles

One or more roles (django.contrib.auth.models.Group()) with access. This attributes can always be empty. If the type selected is By role and no roles are added to this attribute, then checkviewaccess will report an ERROR.

type

The type of access as defined by ACCESS_TYPES

view

View’s name to be secured. Value can be just a view name ‘objects_a’, with application name: ‘app_name:index’, or a nested configurations with namespaces: ‘namespace_1:namespace_2:index’.

Decorator

django_roles_access.decorator.access_by_role(view)[source]

Check if logged user can access the decorated function or method.

Mixin

class django_roles_access.mixin.RolesMixin[source]

A mixin that user access_by_role decorator for dispatch method.

Middleware