add filter
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
from datetime import date, datetime, time, timedelta
|
||||
from decimal import Decimal
|
||||
from http import HTTPStatus
|
||||
from typing import Annotated, TypedDict
|
||||
from uuid import uuid4
|
||||
@@ -49,7 +48,6 @@ class Course(BaseModel):
|
||||
id: UUID4
|
||||
name: str
|
||||
access_period: int
|
||||
unit_price: Decimal = Field(exclude=True)
|
||||
|
||||
|
||||
class DeduplicationWindow(BaseModel):
|
||||
@@ -177,6 +175,14 @@ def enroll_now(enrollment: Enrollment, context: Context):
|
||||
)
|
||||
|
||||
with dyn.transact_writer() as transact:
|
||||
transact.condition(
|
||||
key=KeyPair(
|
||||
pk='SUBSCRIPTION',
|
||||
sk=f'ORG#{org.id}',
|
||||
),
|
||||
cond_expr='attribute_exists(sk)',
|
||||
exc_cls=SubscriptionRequiredError,
|
||||
)
|
||||
transact.put(
|
||||
item={
|
||||
'id': enrollment.id,
|
||||
@@ -276,6 +282,14 @@ def enroll_later(enrollment: Enrollment, context: Context):
|
||||
pk = f'SCHEDULED#ORG#{org.id}'
|
||||
sk = f'{scheduled_for.isoformat()}#{lock_hash}'
|
||||
|
||||
transact.condition(
|
||||
key=KeyPair(
|
||||
pk='SUBSCRIPTION',
|
||||
sk=f'ORG#{org.id}',
|
||||
),
|
||||
cond_expr='attribute_exists(sk)',
|
||||
exc_cls=SubscriptionRequiredError,
|
||||
)
|
||||
transact.put(
|
||||
item={
|
||||
'id': pk,
|
||||
|
||||
Reference in New Issue
Block a user