Note

This is a public alpha release, and therefore features and functionality may change and the software and documentation may contain technical bugs or other issues. If you discover any issues please consider registering a GitHub issue.

profiles.permissions module

Mixins for views to require certain permissions or ownership.

class profiles.permissions.HasViewPermissionMixin[source]

Bases: django.contrib.auth.mixins.UserPassesTestMixin

Mixin to reject users who do not have permission to view this DataSource.

test_func() → bool[source]
class profiles.permissions.OwnerPermissionMixin[source]

Bases: django.contrib.auth.mixins.PermissionRequiredMixin

Mixin to require that a user has the relevant global permission and is the owner of the relevant object.

TODO replace this with ‘django-guardian’ once it supports Django 2.1 or use ‘rules’

has_permission() → bool[source]

Require the the user has the relevant global permission and is the owner of this object.

Returns:Does the user have permission to perform this action?
owner_attribute = 'owner'
class profiles.permissions.SelfOrAdminPermissionMixin[source]

Bases: django.contrib.auth.mixins.UserPassesTestMixin

Mixin to require that a user is the linked object or an admin.

To be used e.g. for edit permission on user profiles

test_func() → bool[source]