Skip to content

Commit bbc4dc2

Browse files
committed
docs: document bulk_draft_changes_for
1 parent c7aa0a2 commit bbc4dc2

File tree

1 file changed

+26
-0
lines changed
  • openedx_learning/apps/authoring/publishing

1 file changed

+26
-0
lines changed

openedx_learning/apps/authoring/publishing/api.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,32 @@ def bulk_draft_changes_for(
14191419
) -> DraftChangeLogContext:
14201420
"""
14211421
Context manager to do a single batch of Draft changes in.
1422+
1423+
Each publishable entity that is edited in this context will be tied to a
1424+
single DraftChangeLogRecord, representing the cumulative changes made to
1425+
that entity. Upon closing of the context, side effects of these changes will
1426+
be calcuated, which may result in more DraftChangeLogRecords being created
1427+
or updated. The resulting DraftChangeLogRecords and DraftChangeSideEffects
1428+
will be tied together into a single DraftChangeLog, representing the
1429+
collective changes to the learning package that happened in this context.
1430+
All changes will be committed in a single atomic transaction.
1431+
1432+
Example::
1433+
1434+
with bulk_draft_changes_for(learning_package.id):
1435+
for section in course:
1436+
update_section_drafts(learning_package.id, section)
1437+
1438+
If you make a change to an entity *without* using this context manager, then
1439+
the individual change (and its side effects) will be automatically wrapped
1440+
in a one-off change context. For example, this::
1441+
1442+
update_one_component(component.learning_package, component)
1443+
1444+
is identical to this::
1445+
1446+
with bulk_draft_changes_for(component.learning_package.id):
1447+
update_one_component(component.learning_package.id, component)
14221448
"""
14231449
return DraftChangeLogContext(
14241450
learning_package_id,

0 commit comments

Comments
 (0)