update id
This commit is contained in:
@@ -51,17 +51,18 @@ class Course(BaseModel):
|
||||
|
||||
|
||||
@router.put('/<course_id>')
|
||||
def edit_course(course_id: str):
|
||||
def put_course(course_id: str):
|
||||
event = router.current_event
|
||||
|
||||
if not event.decoded_body:
|
||||
raise BadRequestError('Invalid request body')
|
||||
|
||||
body = BytesIO(event.decoded_body.encode())
|
||||
course = Course.model_validate(
|
||||
{'id': course_id, 'cert': {}} | parse(event.headers, body),
|
||||
)
|
||||
now_ = now()
|
||||
body = parse(
|
||||
event.headers,
|
||||
BytesIO(event.decoded_body.encode()),
|
||||
)
|
||||
course = Course.model_validate({'id': course_id, 'cert': {}} | body)
|
||||
|
||||
if course.rawfile:
|
||||
object_key = f'certs/templates/{course_id}.html'
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from aws_lambda_powertools import Logger
|
||||
from aws_lambda_powertools.event_handler.api_gateway import Router
|
||||
from aws_lambda_powertools.event_handler.exceptions import NotFoundError
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer, SortKey, TransactKey
|
||||
|
||||
from boto3clients import dynamodb_client
|
||||
from config import ENROLLMENT_TABLE
|
||||
@@ -20,7 +19,6 @@ dyn = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
|
||||
|
||||
@router.get('/<enrollment_id>')
|
||||
def get_enrollment(enrollment_id: str):
|
||||
return dyn.collection.get_item(
|
||||
KeyPair(enrollment_id, '0'),
|
||||
exc_cls=NotFoundError,
|
||||
return dyn.collection.get_items(
|
||||
TransactKey(enrollment_id) + SortKey('0') + SortKey('ORG') + SortKey('LOCK'),
|
||||
)
|
||||
|
||||
4
api.saladeaula.digital/app/routes/orgs/__init__.py
Normal file
4
api.saladeaula.digital/app/routes/orgs/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
from .custom_pricing import router as custom_pricing
|
||||
|
||||
__all__ = ['custom_pricing']
|
||||
17
api.saladeaula.digital/app/routes/orgs/custom_pricing.py
Normal file
17
api.saladeaula.digital/app/routes/orgs/custom_pricing.py
Normal file
@@ -0,0 +1,17 @@
|
||||
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
|
||||
|
||||
router = Router()
|
||||
dyn = DynamoDBPersistenceLayer(USER_TABLE, dynamodb_client)
|
||||
|
||||
|
||||
@router.get('/<org_id>/custompricing')
|
||||
def get_custom_pricing(org_id: str):
|
||||
return dyn.collection.query(
|
||||
PartitionKey(f'CUSTOM_PRICING#ORG#{org_id}'),
|
||||
table_name=COURSE_TABLE,
|
||||
limit=100,
|
||||
)
|
||||
Reference in New Issue
Block a user