From 2759b1170fa1d8b76667243b6fcf7deebf94d5f8 Mon Sep 17 00:00:00 2001 From: Michael Matloka Date: Tue, 12 Mar 2024 18:44:29 +0100 Subject: [PATCH 1/2] chore(api): Make dashboard collaborator and org invite endpoints public --- ee/api/dashboard_collaborator.py | 2 +- posthog/api/organization_invite.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ee/api/dashboard_collaborator.py b/ee/api/dashboard_collaborator.py index 0e070f0c2860c..998eeba8238f9 100644 --- a/ee/api/dashboard_collaborator.py +++ b/ee/api/dashboard_collaborator.py @@ -88,7 +88,7 @@ class DashboardCollaboratorViewSet( mixins.DestroyModelMixin, viewsets.GenericViewSet, ): - scope_object = "INTERNAL" + scope_object = "dashboard" permission_classes = [CanEditDashboardCollaborator] pagination_class = None queryset = DashboardPrivilege.objects.select_related("dashboard").filter(user__is_active=True) diff --git a/posthog/api/organization_invite.py b/posthog/api/organization_invite.py index 72345f6960759..cebf7e1f61e2d 100644 --- a/posthog/api/organization_invite.py +++ b/posthog/api/organization_invite.py @@ -83,7 +83,7 @@ class OrganizationInviteViewSet( mixins.ListModelMixin, viewsets.GenericViewSet, ): - scope_object = "INTERNAL" + scope_object = "organization_member" serializer_class = OrganizationInviteSerializer queryset = OrganizationInvite.objects.all() lookup_field = "id" @@ -96,7 +96,7 @@ def get_queryset(self): .order_by(self.ordering) ) - @action(methods=["POST"], detail=False) + @action(methods=["POST"], detail=False, required_scopes=["organization_member:write"]) def bulk(self, request: request.Request, **kwargs) -> response.Response: data = cast(Any, request.data) if not isinstance(data, list): From 4014b9f532beee0a0b23ebf73801fe676b2b1883 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 17:55:58 +0000 Subject: [PATCH 2/2] Update query snapshots --- posthog/api/test/__snapshots__/test_api_docs.ambr | 3 +++ 1 file changed, 3 insertions(+) diff --git a/posthog/api/test/__snapshots__/test_api_docs.ambr b/posthog/api/test/__snapshots__/test_api_docs.ambr index c378bbb274781..728dabc13af0e 100644 --- a/posthog/api/test/__snapshots__/test_api_docs.ambr +++ b/posthog/api/test/__snapshots__/test_api_docs.ambr @@ -26,6 +26,7 @@ '/home/runner/work/posthog/posthog/posthog/api/dashboards/dashboard_templates.py: Warning [DashboardTemplateViewSet]: could not derive type of path parameter "project_id" because it is untyped and obtaining queryset from the viewset failed. Consider adding a type to the path (e.g. ) or annotating the parameter type with @extend_schema. Defaulting to "string".', '/home/runner/work/posthog/posthog/posthog/api/dashboards/dashboard_templates.py: Warning [DashboardTemplateViewSet]: could not derive type of path parameter "id" because it is untyped and obtaining queryset from the viewset failed. Consider adding a type to the path (e.g. ) or annotating the parameter type with @extend_schema. Defaulting to "string".', '/home/runner/work/posthog/posthog/posthog/api/dashboards/dashboard.py: Warning [DashboardsViewSet]: could not derive type of path parameter "project_id" because model "posthog.models.dashboard.Dashboard" contained no such field. Consider annotating parameter with @extend_schema. Defaulting to "string".', + '/home/runner/work/posthog/posthog/ee/api/dashboard_collaborator.py: Warning [DashboardCollaboratorViewSet]: could not derive type of path parameter "project_id" because model "ee.models.dashboard_privilege.DashboardPrivilege" contained no such field. Consider annotating parameter with @extend_schema. Defaulting to "string".', '/home/runner/work/posthog/posthog/posthog/api/sharing.py: Warning [SharingConfigurationViewSet]: could not derive type of path parameter "project_id" because model "posthog.models.sharing_configuration.SharingConfiguration" contained no such field. Consider annotating parameter with @extend_schema. Defaulting to "string".', '/home/runner/work/posthog/posthog/posthog/api/early_access_feature.py: Warning [EarlyAccessFeatureViewSet]: could not derive type of path parameter "project_id" because model "posthog.models.early_access_feature.EarlyAccessFeature" contained no such field. Consider annotating parameter with @extend_schema. Defaulting to "string".', "/home/runner/work/posthog/posthog/posthog/api/event_definition.py: Error [EventDefinitionViewSet]: exception raised while getting serializer. Hint: Is get_serializer_class() returning None or is get_queryset() not working without a request? Ignoring the view for now. (Exception: 'AnonymousUser' object has no attribute 'organization')", @@ -88,6 +89,8 @@ '/home/runner/work/posthog/posthog/posthog/api/survey.py: Warning [SurveyViewSet]: could not derive type of path parameter "project_id" because model "posthog.models.feedback.survey.Survey" contained no such field. Consider annotating parameter with @extend_schema. Defaulting to "string".', 'Warning: encountered multiple names for the same choice set (HrefMatchingEnum). This may be unwanted even though the generated schema is technically correct. Add an entry to ENUM_NAME_OVERRIDES to fix the naming.', 'Warning: enum naming encountered a non-optimally resolvable collision for fields named "type". The same name has been used for multiple choice sets in multiple components. The collision was resolved with "Type7baEnum". add an entry to ENUM_NAME_OVERRIDES to fix the naming.', + 'Warning: enum naming encountered a non-optimally resolvable collision for fields named "level". The same name has been used for multiple choice sets in multiple components. The collision was resolved with "LevelD7eEnum". add an entry to ENUM_NAME_OVERRIDES to fix the naming.', + 'Warning: encountered multiple names for the same choice set (RestrictionLevelEnum). This may be unwanted even though the generated schema is technically correct. Add an entry to ENUM_NAME_OVERRIDES to fix the naming.', 'Warning: encountered multiple names for the same choice set (EffectivePrivilegeLevelEnum). This may be unwanted even though the generated schema is technically correct. Add an entry to ENUM_NAME_OVERRIDES to fix the naming.', 'Warning: encountered multiple names for the same choice set (MembershipLevelEnum). This may be unwanted even though the generated schema is technically correct. Add an entry to ENUM_NAME_OVERRIDES to fix the naming.', 'Warning: operationId "list" has collisions [(\'/api/organizations/\', \'get\'), (\'/api/organizations/{organization_id}/projects/\', \'get\')]. resolving with numeral suffixes.',