6
6
7
7
from django .conf import settings
8
8
from django .db import models , router , transaction
9
- from django .db .models import QuerySet
10
9
from django .urls import NoReverseMatch , reverse
11
10
from django .utils import timezone
12
11
from django .utils .functional import cached_property
25
24
from sentry .db .models import BoundedPositiveIntegerField , region_silo_model , sane_repr
26
25
from sentry .db .models .fields .slug import SentryOrgSlugField
27
26
from sentry .db .models .manager .base import BaseManager
27
+ from sentry .db .models .manager .base_query_set import BaseQuerySet
28
28
from sentry .db .models .utils import slugify_instance
29
29
from sentry .db .postgres .transactions import in_test_hide_transaction_boundary
30
30
from sentry .hybridcloud .outbox .base import ReplicatedRegionModel
@@ -86,14 +86,14 @@ def as_choices(cls):
86
86
87
87
88
88
class OrganizationManager (BaseManager ["Organization" ]):
89
- def get_for_user_ids (self , user_ids : Collection [int ]) -> QuerySet :
89
+ def get_for_user_ids (self , user_ids : Collection [int ]) -> BaseQuerySet [ Organization ] :
90
90
"""Returns the QuerySet of all organizations that a set of Users have access to."""
91
91
return self .filter (
92
92
status = OrganizationStatus .ACTIVE ,
93
93
member_set__user_id__in = user_ids ,
94
94
)
95
95
96
- def get_for_team_ids (self , team_ids : Sequence [int ]) -> QuerySet :
96
+ def get_for_team_ids (self , team_ids : Sequence [int ]) -> BaseQuerySet [ Organization ] :
97
97
"""Returns the QuerySet of all organizations that a set of Teams have access to."""
98
98
from sentry .models .team import Team
99
99
@@ -102,7 +102,7 @@ def get_for_team_ids(self, team_ids: Sequence[int]) -> QuerySet:
102
102
id__in = Team .objects .filter (id__in = team_ids ).values ("organization" ),
103
103
)
104
104
105
- def get_for_user (self , user , scope = None , only_visible = True ):
105
+ def get_for_user (self , user , scope = None , only_visible = True ) -> list [ Organization ] :
106
106
"""
107
107
Returns a set of all organizations a user has access to.
108
108
"""
@@ -121,7 +121,7 @@ def get_for_user(self, user, scope=None, only_visible=True):
121
121
return [r .organization for r in results if scope in r .get_scopes ()]
122
122
return [r .organization for r in results ]
123
123
124
- def get_organizations_where_user_is_owner (self , user_id : int ) -> QuerySet :
124
+ def get_organizations_where_user_is_owner (self , user_id : int ) -> BaseQuerySet [ Organization ] :
125
125
"""
126
126
Returns a QuerySet of all organizations where a user has the top priority role.
127
127
The default top priority role in Sentry is owner.
0 commit comments