update
This commit is contained in:
@@ -24,13 +24,11 @@ course_layer = DynamoDBPersistenceLayer(COURSE_TABLE, dynamodb_client)
|
||||
|
||||
@router.get('/<id>/custompricing', compress=True)
|
||||
def get_custom_pricing(id: str):
|
||||
result = course_layer.collection.query(
|
||||
return course_layer.collection.query(
|
||||
PartitionKey(f'CUSTOM_PRICING#ORG#{id}'),
|
||||
limit=100,
|
||||
)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
class CustomPricing(BaseModel):
|
||||
course_id: UUID4
|
||||
@@ -38,7 +36,7 @@ class CustomPricing(BaseModel):
|
||||
|
||||
|
||||
@router.post('/<id>/custompricing', compress=True)
|
||||
def post_custom_pricing(id: str, custom_princing: CustomPricing):
|
||||
def add_custom_pricing(id: str, custom_princing: CustomPricing):
|
||||
now_ = now()
|
||||
|
||||
with course_layer.transact_writer() as transact:
|
||||
@@ -61,18 +59,18 @@ def post_custom_pricing(id: str, custom_princing: CustomPricing):
|
||||
return JSONResponse(status_code=HTTPStatus.CREATED)
|
||||
|
||||
|
||||
class DeleteCustomPricing(BaseModel):
|
||||
class RemoveCustomPricing(BaseModel):
|
||||
course_id: UUID4
|
||||
|
||||
|
||||
@router.delete('/<id>/custompricing', compress=True)
|
||||
def delete_custom_pricing(id: str, custom_princing: DeleteCustomPricing):
|
||||
pair = KeyPair(
|
||||
def remove_custom_pricing(id: str, custom_princing: RemoveCustomPricing):
|
||||
key = KeyPair(
|
||||
f'CUSTOM_PRICING#ORG#{id}',
|
||||
f'COURSE#{custom_princing.course_id}',
|
||||
)
|
||||
|
||||
if course_layer.delete_item(pair):
|
||||
if course_layer.delete_item(key):
|
||||
return JSONResponse(status_code=HTTPStatus.OK)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user