-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inconsistent organization member lists, return
Person
instead of `O…
…rganizationMember` (#764) Co-authored-by: Ivan Ivanov <[email protected]>
- Loading branch information
1 parent
012c08a
commit fe8338a
Showing
1 changed file
with
10 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
from functools import reduce | ||
from operator import and_, or_ | ||
|
||
from django.db.models import Q, QuerySet | ||
from django.db.models import F, Q, QuerySet | ||
from django.db.models import Value as V | ||
from django.db.models.functions import StrIndex | ||
from qfieldcloud.core.models import ( | ||
Delta, | ||
Organization, | ||
OrganizationMember, | ||
Person, | ||
Project, | ||
ProjectCollaborator, | ||
Team, | ||
|
@@ -24,8 +25,14 @@ def get_team_members(team): | |
return TeamMember.objects.filter(team=team) | ||
|
||
|
||
def get_organization_members(organization): | ||
return OrganizationMember.objects.filter(organization=organization) | ||
def get_organization_members(organization) -> QuerySet[Person]: | ||
org_members = Person.objects.filter( | ||
organizationmember__organization=organization | ||
).annotate(role=F("organizationmember__role")) | ||
owner = Person.objects.filter(pk=organization.organization_owner.id).annotate( | ||
role=V("owner") | ||
) | ||
return org_members.union(owner) | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
suricactus
Author
Collaborator
|
||
|
||
def get_project_deltas(project): | ||
|
@why-not-try-calmer , @suricactus IMO a method named
get_organization_members
should return aQuerySet[OrganizationMember]
(and notPerson
) . Also then it would have probably not broken anything ...