Skip to content

Commit

Permalink
Merge pull request #64 from dimagi/pkv/opportunity-api-user-filtering
Browse files Browse the repository at this point in the history
Opportunity filtering in opportunity API
  • Loading branch information
pxwxnvermx authored Aug 11, 2023
2 parents 9ea77bb + 548de58 commit 87b4c6c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions commcare_connect/opportunity/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@


class OpportunityViewSet(viewsets.ReadOnlyModelViewSet):
# TODO: Add filtering for CID users
queryset = Opportunity.objects.all()
serializer_class = OpportunitySerializer
# TODO: Add permission for CID users
permission_classes = [IsAuthenticated]

def get_queryset(self):
return Opportunity.objects.filter(opportunityaccess__user=self.request.user)
2 changes: 1 addition & 1 deletion config/api_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
router = SimpleRouter()

router.register("users", UserViewSet)
router.register("opportunity", OpportunityViewSet)
router.register("opportunity", OpportunityViewSet, basename="Opportunity")

app_name = "api"
urlpatterns = [
Expand Down

0 comments on commit 87b4c6c

Please sign in to comment.