Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent organization member lists, return Person instead of OrganizationMember #764

Merged
merged 4 commits into from
Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions docker-app/qfieldcloud/core/querysets_utils.py
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,
Expand All @@ -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)


def get_project_deltas(project):
Expand Down
Loading