add user if exists on konviva
This commit is contained in:
@@ -28,7 +28,7 @@ class LinkedEntity(str):
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Vacancy:
|
||||
class Slot:
|
||||
id: str
|
||||
sk: str
|
||||
|
||||
@@ -69,7 +69,7 @@ def enroll(
|
||||
enrollment: Enrollment,
|
||||
*,
|
||||
tenant: Tenant,
|
||||
vacancy: Vacancy | None = None,
|
||||
slot: Slot | None = None,
|
||||
author: Author | None = None,
|
||||
linked_entities: frozenset[LinkedEntity] = frozenset(),
|
||||
deduplication_window: DeduplicationWindow | None = None,
|
||||
@@ -83,14 +83,14 @@ def enroll(
|
||||
lock_hash = md5_hash('%s%s' % (user.id, course.id))
|
||||
|
||||
with persistence_layer.transact_writer() as transact:
|
||||
if vacancy:
|
||||
linked_entities = frozenset({vacancy.order_id}) | linked_entities
|
||||
if slot:
|
||||
linked_entities = frozenset({slot.order_id}) | linked_entities
|
||||
|
||||
transact.put(
|
||||
item={
|
||||
'sk': '0',
|
||||
'create_date': now_,
|
||||
'tenant': tenant_id,
|
||||
'created_at': now_,
|
||||
'tenant_id': tenant_id,
|
||||
**enrollment.model_dump(),
|
||||
},
|
||||
)
|
||||
@@ -157,14 +157,14 @@ def enroll(
|
||||
}
|
||||
)
|
||||
|
||||
if vacancy:
|
||||
if slot:
|
||||
transact.put(
|
||||
item={
|
||||
'id': enrollment.id,
|
||||
# Post-migration: uncomment the following line
|
||||
# 'sk': 'metadata#parent_slot',
|
||||
'sk': 'parent_vacancy',
|
||||
'vacancy': asdict(vacancy),
|
||||
'vacancy': asdict(slot),
|
||||
'created_at': now_,
|
||||
}
|
||||
)
|
||||
@@ -174,7 +174,7 @@ def enroll(
|
||||
super().__init__('Slot does not exist')
|
||||
|
||||
transact.delete(
|
||||
key=KeyPair(vacancy.id, vacancy.sk),
|
||||
key=KeyPair(slot.id, slot.sk),
|
||||
cond_expr='attribute_exists(sk)',
|
||||
exc_cls=SlotDoesNotExistError,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user