File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -57,15 +57,21 @@ def get_queryset(self, request):
5757 elif not self .multitenant_parent :
5858 return qs
5959 else :
60- qsarg = "{0}__organization__in" .format (self .multitenant_parent )
61- return qs .filter (** {qsarg : user .organizations_managed })
60+ qsarg = f"{ self .multitenant_parent } __organization"
61+ return qs .filter (
62+ Q (** {f"{ qsarg } __in" : user .organizations_managed }) | Q (** {qsarg : None })
63+ )
6264
6365 def _has_org_permission (self , request , obj , perm_func ):
6466 """
6567 Helper method to check object-level permissions for users
6668 associated with specific organizations.
6769 """
6870 perm = perm_func (request , obj )
71+ if obj and self .multitenant_parent :
72+ # In case of a multitenant parent, we need to check if the
73+ # user has permission on the parent object.
74+ obj = getattr (obj , self .multitenant_parent )
6975 if not request .user .is_superuser and obj and hasattr (obj , "organization_id" ):
7076 perm = perm and (
7177 obj .organization_id
You can’t perform that action at this time.
0 commit comments