Admin Utilities
This section outlines the admin utilities provided by the OpenWISP Users module.
MultitenantAdminMixin
Full python path:
openwisp_users.multitenancy.MultitenantAdminMixin.
Adding this mixin to a ModelAdmin class makes it multitenant-capable,
allowing users to see only items of the organizations they manage or own.
This class has two important attributes:
multitenant_shared_relations: If the model has relations (e.g.,ForeignKey,OneToOne) to other multitenant models with anorganizationfield, list those model attributes here as a list of strings. See how it is used in OpenWISP Controller for a real-world example.multitenant_parent: If the admin model relies on a parent model with theorganizationfield, specify the field pointing to the parent here. See how it is used in OpenWISP Firmware Upgrader for a real-world example.
MultitenantOrgFilter
Full python path:
openwisp_users.multitenancy.MultitenantOrgFilter.
This auto complete admin filter displays only organizations the current
user can manage. Below is an example of adding the auto complete
organization filter in BookAdmin:
from django.contrib import admin
from openwisp_users.multitenancy import MultitenantOrgFilter
class BookAdmin(admin.ModelAdmin):
list_filter = [
MultitenantOrgFilter,
]
# other attributes