Skip to content

Commit

Permalink
[multitenancy] Avoid failure if org field not present
Browse files Browse the repository at this point in the history
Allow MultitenantAdminMixin to be used also on models
which do not have an own organization field (because
they rely on a parent item to determine the org)
  • Loading branch information
nemesifier committed Jun 15, 2018
1 parent 7975a3a commit dc977d2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions openwisp_utils/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def get_queryset(self, request):
objects associated to organizations he/she is associated with
"""
qs = super(MultitenantAdminMixin, self).get_queryset(request)
if not hasattr(self.model, 'organization'):
return qs
if request.user.is_superuser:
return qs
organizations = request.user.organizations_pk
Expand Down

0 comments on commit dc977d2

Please sign in to comment.