Skip to content

Commit

Permalink
Merge pull request #197 from dimagi/pkv/fix-random-test-failure-claim…
Browse files Browse the repository at this point in the history
…-endpoint

Fix randomly failing test for Claim API Endpoint
  • Loading branch information
pxwxnvermx authored Nov 14, 2023
2 parents 364e82e + 2dcad77 commit 108ef00
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions commcare_connect/opportunity/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def post(self, *args, **kwargs):
opportunity_access = get_object_or_404(OpportunityAccess, user=self.request.user, opportunity=kwargs.get("pk"))
opportunity = opportunity_access.opportunity

if OpportunityClaim.objects.filter(opportunity_access=opportunity_access).exists():
return Response(status=200, data="Opportunity is already claimed")
if opportunity.remaining_budget <= 0:
return Response(status=200, data="Opportunity cannot be claimed. (Budget Exhausted)")
if opportunity.end_date < datetime.date.today():
Expand Down

0 comments on commit 108ef00

Please sign in to comment.