Repository navigation
Description
- If you call
create_publishable_entity, specifyingcreated(timestamp) andcreated_byis mandatory, and gets set directly on the newPublishableEntitymodel.- If you do this within a
bulk_draft_changes_for/DraftChangeLogContext, thechanged_at/changed_byfrom the context does not override thecreated/created_byspecified oncreate_publishable_entity(). Note also that simply creating an entity without any version does not affect the changelog nor create a change log record (expected).
- If you do this within a
- If you call
create_publishable_entity_version, specifyingcreated(timestamp) andcreated_byis mandatory.- If you do this within a
bulk_draft_changes_for/DraftChangeLogContext, thechanged_at/changed_byfrom the context overrides the thecreated/created_byspecified here. But you still have to specify it.
- If you do this within a
- If you call
soft_delete_draft, specifyingdeleted_by(user id) is optional, and specifying a timestamp is not possible.- If you do this within a
bulk_draft_changes_for/DraftChangeLogContext, thechanged_at/changed_byfrom the context overrides the thedeleted_byspecified here.
- If you do this within a
- If you call
reset_drafts_to_published, specifyingreset_at/reset_byis optional.- If you do this within a
bulk_draft_changes_for/DraftChangeLogContext, thechanged_at/changed_byfrom the context overrides them, and they are ignored.
- If you do this within a
- If you call
set_draft_versiondirectly, specifyingset_at/set_byis optional.- If you do this within a
bulk_draft_changes_for/DraftChangeLogContext, thereset_at/reset_byfrom the context overrides them, and they are ignored.
- If you do this within a
The Containers and Components APIs also often accept/require created/created_by arguments, which are sometimes mandatory and sometimes optional, and follow the same patterns as above.
The create_x_and_version APIs are generally structured so that the created timestamp is mandatory, passing it through the layers so that the X and XVersion both have the same created timestamp. The created_by is more likely to be optional because it will still be consistently None even if omitted at the top level.
When the user ID is optional, the API cannot detect/model the difference between "I forgot to specify the user" and "this is a system action with no associated user" - both use user_id=None.
Names of the timestamp variable: changed_at, created, reset_at, set_at
Names of the user ID variable: changed_by, created_by, reset_by, set_by, deleted_by
Activity
bradenmacdonald commentedon Apr 16, 2026
Suggestion: make all the parameters optional, but throw an error if they are not specified when used outside of
bulk_draft_changes_for. Make the default value of the user_byparameters a sentinel value likeAUTO(get from the bulk context) so thatuser_id=Noneis always a very explicit choice.kdmccormick commentedon Apr 24, 2026
I propose that we should define, either in
openedx_django_libor inpublishing/api.py:and then all relevant API functions could take:
Notes:
int | AUTHOR_NONE, because there's nothing for it to get "AUTO" from.bradenmacdonald commentedon Apr 24, 2026
@kdmccormick I was thinking vaguely along similar lines and I really like your proposal. The main things I want to avoid are forgetting to specify the user (if we left the default as
None) and duplicate specifying in the bulk context and the individual APIs, and your suggestion fixes both. I think the<verbed>_by: Authorand<verbed>_at: Timestampalso make the fields more understandable because I do find the "verbed_by" and "verbed_at" to be slightly vague/ambiguous as descriptors.kdmccormick commentedon Apr 24, 2026
Great. As part of this, I'll also fix the Collections API
feat!: Consistently attribute changes with time and author
kdmccormick commentedon Apr 29, 2026
#573
feat!: Consistently attribute changes with time and author
feat!: Consistently attribute changes with time and author
feat!: Consistently attribute changes with time and author
feat!: Consistently attribute changes with time and author
feat!: Consistently attribute changes with time and author