-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
ref(teams): Use ProjectTeam relation instead of project.team #6807
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
Conversation
src/sentry/models/deletedproject.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if these should just be removed and project/org is detailed enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think it'd be fair to drop this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure what the implications are of just removing these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2ae9b5e to
806a1a4
Compare
Security concerns found
Generated by 🚫 danger |
f07fa2c to
78d3c8e
Compare
src/sentry/api/bases/project.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL what prefetch_related does
5967658 to
7e1172a
Compare
7e1172a to
a3e5145
Compare
| ).select_related('team') | ||
| ) | ||
|
|
||
| # TODO(jess): decide if we should only include teams the user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gonna say it's ok to include teams a user doesn't have access to since we allow users to see team names and request access to teams they don't have access to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think that's reasonable. Teams aren't private, at least knowing they exist. Only the contents within.
| group = self.group | ||
|
|
||
| headers = { | ||
| 'X-Sentry-Team': project.team.slug, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Talked to Ted about these. I tried to figure out how we'd include multiple values for the same header key without much luck. Since Ted discovered that gmail doesn't even allow filtering on custom headers, we figured it was probably not worth the hassle of customizing this for each recipient and decided to just remove these.
92552a7 to
8700242
Compare
mattrobenolt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this looks fine from a high level. There's a lot of stuff going on and mass rewriting of every usage, so it's hard to get a grasp if this will 100% work, but this is best we can do without just trying it.
🦄
src/sentry/api/bases/project.py
Outdated
| if not result: | ||
| return result | ||
|
|
||
| return any([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the [] bit isn't needed. You can just do return any(has_team_permission(request, team, self.scope_map) for team in project.teams.all())
There's also value in that wihtout the [] it's lazily evaluated as a generator and will return when the first one is truthy.
| raise ResourceDoesNotExist | ||
|
|
||
| if request.access.has_team_scope(project.team, 'project:write'): | ||
| has_team_scope = any([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: same here with any()
| ).select_related('team') | ||
| ) | ||
|
|
||
| # TODO(jess): decide if we should only include teams the user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think that's reasonable. Teams aren't private, at least knowing they exist. Only the contents within.
| def get_attrs(self, item_list, user): | ||
| project_qs = list( | ||
| Project.objects.filter( | ||
| project_team_qs = list( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This is named as _qs implying it's a QuerSet, and it's just a list. I know this preexisted, but might as well change it since you already did.
src/sentry/models/team.py
Outdated
| key=lambda x: x.name.lower() | ||
| ) | ||
|
|
||
| teams_by_project = {p.id: set() for p in project_list} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this could be replaced by defaultdict(set)
c241a7e to
7ab0201
Compare
remove outdated todo fix tests add a few more todos, remove team slug from email headers update ProjectView to inherit from org view instead of team have project serializer use new relation fix mysql tests update test fixtures to use teams kwarg stop writing team to deleted project audit remove todo i handled in a different PR remove team x header make fixtures create_project backwards compatible for other repos matt pr feedback
7ab0201 to
1c8730a
Compare
#6147 needs to be merged first