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

Add org_id filter to integrations/ #88

Merged
merged 1 commit into from
Sep 27, 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
8 changes: 6 additions & 2 deletions apps/integrations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ class IntegrationsView(generics.ListCreateAPIView):
authentication_classes = []
serializer_class = IntegrationSerializer
queryset = Integration.objects.filter(is_active=True, is_beta=True)
filterset_fields = {'type': {'exact'}}
filterset_fields = {'type': {'exact'}, 'org_id': {'exact'}}

def get(self, request, *args, **kwargs):
# This block is for authenticating the user
access_token = self.request.META.get('HTTP_AUTHORIZATION').split(' ')[1]
try:
get_org_id_from_access_token(access_token)
org_id = get_org_id_from_access_token(access_token)

# Add validated org_id to query_params
request.query_params._mutable = True
request.query_params['org_id'] = org_id
return super().get(request, *args, **kwargs)
except Exception as error:
logger.info(error)
Expand Down