add billing period
This commit is contained in:
@@ -40,29 +40,41 @@ class LifecycleEvents(str, Enum):
|
||||
"""Lifecycle events related to scheduling actions."""
|
||||
|
||||
# Reminder if the user does not access within 3 days
|
||||
# REMINDER_NO_ACCESS_3_DAYS = 'SCHEDULES#REMINDER_NO_ACCESS_3_DAYS'
|
||||
# REMINDER_NO_ACCESS_AFTER_3_DAYS = 'SCHEDULE#REMINDER_NO_ACCESS_AFTER_3_DAYS'
|
||||
DOES_NOT_ACCESS = 'schedules#does_not_access'
|
||||
|
||||
# When there is no activity 7 days after the first access
|
||||
# NO_ACTIVITY_7_DAYS = 'SCHEDULES#NO_ACTIVITY_7_DAYS'
|
||||
# REMINDER_NO_ACTIVITY_AFTER_7_DAYS = 'SCHEDULE#REMINDER_NO_ACTIVITY_AFTER_7_DAYS'
|
||||
NO_ACTIVITY = 'schedules#no_activity'
|
||||
|
||||
# Reminder 30 days before the access period expires
|
||||
# ACCESS_PERIOD_REMINDER_30_DAYS = 'SCHEDULES#ACCESS_PERIOD_REMINDER_30_DAYS'
|
||||
# REMINDER_ACCESS_PERIOD_BEFORE_30_DAYS = 'SCHEDULE#REMINDER_ACCESS_PERIOD_BEFORE_30_DAYS'
|
||||
ACCESS_PERIOD_ENDS = 'schedules#access_period_ends'
|
||||
|
||||
# Reminder for certificate expiration set to 30 days from now
|
||||
CERT_EXP_REMINDER_30_DAYS = 'SCHEDULES#CERT_EXP_REMINDER_30_DAYS'
|
||||
REMINDER_CERT_EXPIRATION_BEFORE_30_DAYS = (
|
||||
'SCHEDULE#REMINDER_CERT_EXPIRATION_BEFORE_30_DAYS'
|
||||
)
|
||||
|
||||
# Archive the course after the certificate expires
|
||||
# SET_AS_ARCHIVE = 'schedules#set_as_archive'
|
||||
# SET_AS_ARCHIVE = 'SCHEDULE#SET_AS_ARCHIVE'
|
||||
ARCHIVE_IT = 'schedules#archive_it'
|
||||
|
||||
# When the access period ends for a course without a certificate
|
||||
# SET_AS_EXPIRE = 'schedules#set_as_expire'
|
||||
# SET_AS_EXPIRE = 'SCHEDULE#SET_AS_EXPIRE'
|
||||
EXPIRATION = 'schedules#expiration'
|
||||
|
||||
|
||||
class DeduplicationConflictError(Exception):
|
||||
def __init__(self, *args):
|
||||
super().__init__('Enrollment already exists')
|
||||
|
||||
|
||||
class SlotDoesNotExistError(Exception):
|
||||
def __init__(self, *args):
|
||||
super().__init__('Slot does not exist')
|
||||
|
||||
|
||||
def enroll(
|
||||
enrollment: Enrollment,
|
||||
*,
|
||||
@@ -112,8 +124,8 @@ def enroll(
|
||||
},
|
||||
)
|
||||
# Enrollment expires by default when the access period ends.
|
||||
# When the course is finished, it is automatically removed,
|
||||
# and the `schedules#course_archived` event is created.
|
||||
# When the course is completed, it is automatically removed,
|
||||
# and the `SCHEDULE#SET_AS_ARCHIVE` event is created.
|
||||
transact.put(
|
||||
item={
|
||||
'id': enrollment.id,
|
||||
@@ -146,9 +158,7 @@ def enroll(
|
||||
transact.put(
|
||||
item={
|
||||
'id': enrollment.id,
|
||||
# Post-migration: uncomment the following line
|
||||
# 'sk': f'LINKED_ENTITIES#{entity.type}',
|
||||
'sk': f'linked_entities#{entity.type}',
|
||||
'sk': f'LINKED_ENTITIES#{entity.type}',
|
||||
'created_at': now_,
|
||||
f'{keyprefix}_id': entity.id,
|
||||
}
|
||||
@@ -166,10 +176,6 @@ def enroll(
|
||||
}
|
||||
)
|
||||
|
||||
class SlotDoesNotExistError(Exception):
|
||||
def __init__(self, *args):
|
||||
super().__init__('Slot does not exist')
|
||||
|
||||
transact.delete(
|
||||
key=KeyPair(slot.id, slot.sk),
|
||||
cond_expr='attribute_exists(sk)',
|
||||
@@ -194,10 +200,6 @@ def enroll(
|
||||
},
|
||||
)
|
||||
|
||||
class DeduplicationConflictError(Exception):
|
||||
def __init__(self, *args):
|
||||
super().__init__('Enrollment already exists')
|
||||
|
||||
# Prevents the user from enrolling in the same course again until
|
||||
# the deduplication window expires or is removed.
|
||||
if deduplication_window:
|
||||
|
||||
Reference in New Issue
Block a user