chore: create csu on settled | transmitted
This commit is contained in:
parent
93c9f73a46
commit
54428d78d7
|
|
@ -5,6 +5,8 @@ from rest_framework.decorators import api_view, permission_classes
|
||||||
from rest_framework.permissions import IsAuthenticated
|
from rest_framework.permissions import IsAuthenticated
|
||||||
from rest_framework.response import Response
|
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 (
|
from vbv_lernwelt.shop.models import (
|
||||||
BillingAddress,
|
BillingAddress,
|
||||||
CheckoutInformation,
|
CheckoutInformation,
|
||||||
|
|
@ -75,9 +77,21 @@ def transaction_webhook(request):
|
||||||
checkout_info.webhook_history.append(transaction)
|
checkout_info.webhook_history.append(transaction)
|
||||||
checkout_info.save(update_fields=["state", "webhook_history"])
|
checkout_info.save(update_fields=["state", "webhook_history"])
|
||||||
|
|
||||||
if transaction_status == ["settled", "transmitted"]:
|
if transaction_status in ["settled", "transmitted"]:
|
||||||
# FIXME create CSU
|
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"})
|
return JsonResponse({"status": "ok"})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue