@@ -30,7 +30,14 @@ class BusinessHostSelector: account_privileges: list[str] = [], have_group: bool | None = None, ) -> list[BusinessAccount] | BusinessAccountDataSerializer: - accounts = self.user.host_account.accounts + if self.user.account_type == 'business_host': + host = self.user.host_account + elif self.user.account_type == 'business_admin': + host = self.user.business_account.parent_company + else: + raise Exception(_("You haven't rights to access host account information")) + + accounts = host.accounts if account_privileges: accounts = accounts.filter(account_privileges__in=account_privileges) if have_group is not None: @@ -68,7 +75,12 @@ class BusinessHostSelector: return host def detail(self): - host = self.user.host_account + if self.user.account_type == 'business_host': + host = self.user.host_account + elif self.user.account_type == 'business_admin': + host = self.user.business_account.parent_company + else: + raise Exception(_("You haven't rights to access host account information")) return BusinessHostSerializer( host, context={'worker_amount': host.accounts.count()} )