diff --git a/docker-app/qfieldcloud/core/models.py b/docker-app/qfieldcloud/core/models.py index 414e27f1a..d666356c1 100644 --- a/docker-app/qfieldcloud/core/models.py +++ b/docker-app/qfieldcloud/core/models.py @@ -1475,12 +1475,10 @@ def clean(self) -> None: if self.project.owner.is_organization: organization = Organization.objects.get(pk=self.project.owner.pk) if self.collaborator.is_person: - members_qs = organization.members.filter(member=self.collaborator) # type: ignore - # for organizations-owned projects, the candidate collaborator # must be a member of the organization or the organization's owner if not ( - members_qs.exists() + organization.members.filter(member=self.collaborator).exists() # type: ignore or self.collaborator == organization.organization_owner ): raise ValidationError( diff --git a/docker-app/qfieldcloud/core/tests/utils.py b/docker-app/qfieldcloud/core/tests/utils.py index 5b77020b0..7acf597b4 100644 --- a/docker-app/qfieldcloud/core/tests/utils.py +++ b/docker-app/qfieldcloud/core/tests/utils.py @@ -51,16 +51,11 @@ def setup_subscription_plans(): def set_subscription( - some_user: User | Iterable[User], + users: User | Iterable[User], code: str = None, **kwargs, ): - users: list[User] = [] - - if isinstance(some_user, User): - users.append(some_user) - else: - users += some_user + users: list[User] = [users] if isinstance(users, User) else users assert len( users ), "When iterable, the first argument must contain at least 1 element."