Usage

Contents under construction; this page is mainly a feature teaser.

The best sample code is currently found in:

Checking permissions for a user and content object

@@ TODO. It goes a little something like this:

if not request.user.has_perm('wiki.view_document', doc):
    raise PermissionDenied

Using the get_object_or_404_or_403 shortcut

@@ TODO. It goes a little something like this:

from teamwork.shortcuts import get_object_or_404_or_403
# ...
doc = get_object_or_404_or_403('wiki.add_revision', request.user,
    Document, locale=document_locale, slug=document_slug)

Base policy in settings.py

@@ TODO. Example. Here’s an inadequate sample:

TEAMWORK_BASE_POLICIES = {
    'anonymous': (
        'wiki.view_document',),
    'authenticated': (
        'wiki.view_document', 'wiki.add_document', 'wiki.add_revision'),
}

Setting a Policy on a Site

@@ TODO. Example test.

Setting a Policy on a content object

@@ TODO. Example test.

Creating Teams and Roles

@@ TODO. Example test.

Granting Team ownership of content Objects

@@ TODO. Example model and test.

Assigning Roles to Users

@@ TODO. Example test.

Filtering permissions with per-object logic

@@ TODO. Example model and test.

Supporting content hierarchies and Permission inheritance

@@ TODO. Example test and model.