finish seat
This commit is contained in:
@@ -36,7 +36,7 @@ class User(BaseModel):
|
||||
def add(org_id: str, user: Annotated[User, Body(embed=True)]):
|
||||
now_ = now()
|
||||
org = dyn.collection.get_item(
|
||||
KeyPair(pk=org_id, sk='0'),
|
||||
KeyPair(org_id, '0'),
|
||||
exc_cls=OrgNotFoundError,
|
||||
)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Annotated
|
||||
from typing import Annotated, cast
|
||||
|
||||
from aws_lambda_powertools import Logger
|
||||
from aws_lambda_powertools.event_handler.api_gateway import Router
|
||||
@@ -11,8 +11,9 @@ 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 ...enrollments.enroll import Enrollment, Org, Subscription, enroll_now
|
||||
from ...enrollments.enroll import Context, Enrollment, Org, Subscription, enroll_now
|
||||
|
||||
logger = Logger(__name__)
|
||||
router = Router()
|
||||
@@ -72,12 +73,18 @@ def proceed(
|
||||
KeyPair(pk, sk),
|
||||
exc_cls=ScheduledNotFoundError,
|
||||
)
|
||||
org = Org(
|
||||
id=org_id,
|
||||
name=scheduled['org_name'],
|
||||
)
|
||||
subscription = Subscription(
|
||||
billing_day=scheduled['subscription_billing_day'],
|
||||
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 {}
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
try:
|
||||
@@ -86,11 +93,7 @@ def proceed(
|
||||
user=scheduled['user'],
|
||||
course=scheduled['course'],
|
||||
),
|
||||
{
|
||||
'org': org,
|
||||
'subscription': subscription,
|
||||
'created_by': router.context['user'],
|
||||
},
|
||||
ctx,
|
||||
)
|
||||
|
||||
with dyn.transact_writer() as transact:
|
||||
|
||||
@@ -2,10 +2,10 @@ from aws_lambda_powertools.event_handler.api_gateway import Router
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer, PartitionKey
|
||||
|
||||
from boto3clients import dynamodb_client
|
||||
from config import COURSE_TABLE
|
||||
from config import ENROLLMENT_TABLE
|
||||
|
||||
router = Router()
|
||||
dyn = DynamoDBPersistenceLayer(COURSE_TABLE, dynamodb_client)
|
||||
dyn = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
|
||||
|
||||
|
||||
@router.get('/<org_id>/seats')
|
||||
|
||||
@@ -38,9 +38,6 @@ class User(BaseModel):
|
||||
email: EmailStr
|
||||
|
||||
|
||||
# class OrgNotFoundError(NotFoundError): ...
|
||||
|
||||
|
||||
@router.post('/<org_id>/users')
|
||||
def add(
|
||||
org_id: str,
|
||||
|
||||
Reference in New Issue
Block a user