-
-
Notifications
You must be signed in to change notification settings - Fork 303
6009: add organizations to invitation querysets and sync #6039
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
base: unstable
Are you sure you want to change the base?
Changes from all commits
cf2a01e
2045c38
475ba8e
adf1830
bd756fe
683d1ca
22b1f51
eb4a8b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1895,6 +1895,40 @@ class Meta: | |
| def __str__(self): | ||
| return self.name | ||
|
|
||
| @classmethod | ||
| def filter_edit_queryset(cls, queryset, user): | ||
| if user.is_anonymous: | ||
| return queryset.none() | ||
|
|
||
| if user.is_admin: | ||
| return queryset | ||
|
|
||
| return queryset.filter( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. praise: Checking |
||
| user_roles__user=user, | ||
| user_roles__role=ORGANIZATION_ADMIN, | ||
| user_roles__status=ORGANIZATION_ROLE_STATUS_ACTIVE, | ||
| deleted=False, | ||
| ).distinct() | ||
|
|
||
| @classmethod | ||
| def filter_view_queryset(cls, queryset, user): | ||
| if user.is_anonymous: | ||
| return queryset.none() | ||
|
|
||
| if user.is_admin: | ||
| return queryset | ||
|
|
||
| return queryset.filter( | ||
| user_roles__user=user, | ||
| user_roles__role__in=[ | ||
| ORGANIZATION_ADMIN, | ||
| ORGANIZATION_EDITOR, | ||
| ORGANIZATION_VIEWER, | ||
| ], | ||
| user_roles__status=ORGANIZATION_ROLE_STATUS_ACTIVE, | ||
| deleted=False, | ||
| ).distinct() | ||
|
|
||
|
|
||
| class OrganizationRole(models.Model): | ||
| """ | ||
|
|
@@ -3807,7 +3841,14 @@ def filter_edit_queryset(cls, queryset, user): | |
| return queryset | ||
|
|
||
| return queryset.filter( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. blocking: This grants an active Multi-admin orgs are the point of org-level roles, so "only the original inviter can revoke" is unlikely to be intended. Same shape for accept/decline over sync: gated on |
||
| Q(email__iexact=user.email) | Q(sender=user) | Q(channel__editors=user) | ||
| Q(email__iexact=user.email) | ||
| | Q(sender=user) | ||
| | Q(channel__editors=user) | ||
| | Q( | ||
| organization__user_roles__user=user, | ||
| organization__user_roles__role=ORGANIZATION_ADMIN, | ||
| organization__user_roles__status=ORGANIZATION_ROLE_STATUS_ACTIVE, | ||
| ) | ||
| ).distinct() | ||
|
|
||
| @classmethod | ||
|
|
@@ -3822,6 +3863,15 @@ def filter_view_queryset(cls, queryset, user): | |
| | Q(sender=user) | ||
| | Q(channel__editors=user) | ||
| | Q(channel__viewers=user) | ||
| | Q( | ||
| organization__user_roles__user=user, | ||
| organization__user_roles__role__in=[ | ||
| ORGANIZATION_ADMIN, | ||
| ORGANIZATION_EDITOR, | ||
| ORGANIZATION_VIEWER, | ||
| ], | ||
| organization__user_roles__status=ORGANIZATION_ROLE_STATUS_ACTIVE, | ||
| ) | ||
| ).distinct() | ||
|
|
||
|
|
||
|
|
||
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.
nitpick:
Organization.deletedis a soft-delete flag (line 1880) andCustomManagerdoesn't filter it, so neither of these classmethods excludes deleted orgs — and both call sites pass an unfiltered base queryset (Organization.objects.all()in the serializer field,Organization.objects.filter(id__in=...)inSyncView). An admin of a soft-deleted org can still create invitations into it, and accepting one creates a liveOrganizationRole.Channeldefersdeletedfiltering to its viewset, so either layer is consistent with the repo — but with noOrganizationviewset yet, these methods are currently the only gate.