add enrollments to order

This commit is contained in:
2026-01-25 20:47:21 -03:00
parent 3719842ae9
commit 0d1258f666
11 changed files with 303 additions and 64 deletions

View File

@@ -11,7 +11,7 @@ from pydantic import FutureDatetime
from api_gateway import JSONResponse
from boto3clients import dynamodb_client
from config import ENROLLMENT_TABLE
from middlewares.authentication_middleware import User as Authenticated
from routes.orgs import billing
from ...enrollments.enroll import Context, Enrollment, Org, Subscription, enroll_now
@@ -74,24 +74,20 @@ def proceed(
exc_cls=ScheduledNotFoundError,
)
billing_day = scheduled.get('subscription_billing_day')
ctx = cast(
Context,
{
'created_by': router.context['user'],
'org': Org(id=org_id, name=scheduled['org_name']),
**(
{'subscription': Subscription(billing_day=billing_day)}
if billing_day
else {}
),
},
)
ctx: Context = {
'created_by': router.context['user'],
'org': Org(id=org_id, name=scheduled['org_name']),
}
if billing_day:
ctx['subscription'] = Subscription(billing_day=billing_day)
try:
enrollment = enroll_now(
Enrollment(
user=scheduled['user'],
course=scheduled['course'],
seat=scheduled.get('seat'),
),
ctx,
)