add admins

This commit is contained in:
2025-11-11 19:03:48 -03:00
parent 39aedac972
commit fa87cf3e07
14 changed files with 219 additions and 12 deletions

View File

@@ -1,4 +1,5 @@
from .admins import router as admins
from .custom_pricing import router as custom_pricing
from .enrollments.scheduled import router as scheduled
__all__ = ['admins', 'custom_pricing']
__all__ = ['admins', 'custom_pricing', 'scheduled']

View File

@@ -2,7 +2,7 @@ from aws_lambda_powertools.event_handler.api_gateway import Router
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair
from boto3clients import dynamodb_client
from config import COURSE_TABLE, USER_TABLE
from config import USER_TABLE
router = Router()
dyn = DynamoDBPersistenceLayer(USER_TABLE, dynamodb_client)
@@ -11,7 +11,7 @@ dyn = DynamoDBPersistenceLayer(USER_TABLE, dynamodb_client)
@router.get('/<org_id>/admins')
def get_admins(org_id: str):
return dyn.collection.query(
# Post-migration: rename `admins` to `ADMIN`
KeyPair(org_id, 'admins#'),
table_name=COURSE_TABLE,
limit=100,
)

View File

@@ -2,16 +2,15 @@ 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, USER_TABLE
from config import COURSE_TABLE
router = Router()
dyn = DynamoDBPersistenceLayer(USER_TABLE, dynamodb_client)
dyn = DynamoDBPersistenceLayer(COURSE_TABLE, dynamodb_client)
@router.get('/<org_id>/custompricing')
@router.get('/<org_id>/custom-pricing')
def get_custom_pricing(org_id: str):
return dyn.collection.query(
PartitionKey(f'CUSTOM_PRICING#ORG#{org_id}'),
table_name=COURSE_TABLE,
limit=100,
)

View File

@@ -0,0 +1,22 @@
from aws_lambda_powertools import Logger
from aws_lambda_powertools.event_handler.api_gateway import Router
from layercake.dynamodb import DynamoDBPersistenceLayer, PartitionKey
from boto3clients import dynamodb_client
from config import ENROLLMENT_TABLE
logger = Logger(__name__)
router = Router()
dyn = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
@router.get('/<org_id>/enrollments/scheduled')
def scheduled(org_id: str):
start_key = router.current_event.get_query_string_value('start_key', None)
return dyn.collection.query(
# Post-migration: rename `scheduled_items` to `SCHEDULED#ORG#{org_id}`
key=PartitionKey(f'scheduled_items#{org_id}'),
start_key=start_key,
limit=150,
)