From 608b29b6155a00f06df92328e1f8cea22a17efce Mon Sep 17 00:00:00 2001 From: why-not-try-calmer Date: Mon, 4 Sep 2023 11:14:14 +0200 Subject: [PATCH] accomodating comments --- docker-app/qfieldcloud/core/models.py | 4 +--- docker-app/qfieldcloud/core/tests/utils.py | 9 ++------- 2 files changed, 3 insertions(+), 10 deletions(-) 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."