Skip to content

Commit

Permalink
fix(backend): change get user's presentations query
Browse files Browse the repository at this point in the history
  • Loading branch information
Adibov committed Nov 30, 2023
1 parent 5b2df2e commit 701d34e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ jobs:
key: ${{ secrets.SSH_PRIVATE_KEY }}
envs: SECRET_KEY,EMAIL_HOST_PASSWORD,ZIFY_AUTH
script: |
docker compose -f AAISS-2023/docker-compose.yml up -d --pull always --force-recreate --no-build
docker compose -f AAISS-2023/docker-compose.yml pull
docker compose -f AAISS-2023/docker-compose.yml up -d --force-recreate --no-build
4 changes: 2 additions & 2 deletions backend/backend_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def create_payment_for_user(user: User):
presentations: list[Presentation] = []
for workshop in user.registered_workshops.all():
try:
workshop_registration = workshop.workshopregistration_set.get(workshop_id=workshop.id)
workshop_registration = workshop.workshopregistration_set.get(workshop_id=workshop.id, user=user)
if workshop_registration.status != WorkshopRegistration.StatusChoices.AWAITING_PAYMENT:
continue
if workshop.remaining_capacity <= 0:
Expand All @@ -402,7 +402,7 @@ def create_payment_for_user(user: User):
for presentation in user.participated_presentations.all():
try:
presentation_participation = presentation.presentationparticipation_set.get(
presentation_id=presentation.id)
presentation_id=presentation.id, user=user)
if presentation_participation.status != PresentationParticipation.StatusChoices.AWAITING_PAYMENT:
continue
if presentation.remaining_capacity <= 0:
Expand Down
3 changes: 2 additions & 1 deletion backend/backend_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ class PaymentViewSet(viewsets.GenericViewSet):
def payment(self, request):
account = request.user
call_back = request.data.get('call_back')
if call_back is None:
return Response(new_detailed_response(status.HTTP_400_BAD_REQUEST, "call_back field is required"))
try:
user = User.objects.get(account=account)
except ObjectDoesNotExist:
Expand Down Expand Up @@ -248,7 +250,6 @@ def verify(self, request):
response = ZIFYRequest().verify_payment(payment.track_id)
if response['status'] == ZIFY_STATUS_OK:
payment.update_payment_status(Payment.PaymentStatus.PAYMENT_CONFIRMED)
# FIXME: redirect to payment success page
return Response(new_detailed_response(status.HTTP_200_OK, "Payment verified successfully", payment.pk))
else:
payment.update_payment_status(Payment.PaymentStatus.PAYMENT_REJECTED)
Expand Down

0 comments on commit 701d34e

Please sign in to comment.