chore: create csu on settled | transmitted

This commit is contained in:
Livio Bieri 2023-11-17 15:45:54 +01:00 committed by Christian Cueni
parent 93c9f73a46
commit 54428d78d7
1 changed files with 17 additions and 3 deletions

View File

@ -5,6 +5,8 @@ from rest_framework.decorators import api_view, permission_classes
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from vbv_lernwelt.core.admin import User
from vbv_lernwelt.course.models import CourseSessionUser, CourseSession
from vbv_lernwelt.shop.models import (
BillingAddress,
CheckoutInformation,
@ -75,9 +77,21 @@ def transaction_webhook(request):
checkout_info.webhook_history.append(transaction)
checkout_info.save(update_fields=["state", "webhook_history"])
if transaction_status == ["settled", "transmitted"]:
# FIXME create CSU
...
if transaction_status in ["settled", "transmitted"]:
logger.info(
"Webhook: Create course session user", transaction_id=transaction_id
)
# FIXME make this "better"
cs_vv = CourseSession.objects.filter(
title="Versicherungsvermittler/-in"
).first()
CourseSessionUser.objects.get_or_create(
course_session=cs_vv,
user=User.objects.get(id=checkout_info.user_id),
role=CourseSessionUser.Role.MEMBER,
)
return JsonResponse({"status": "ok"})