NOTE: This is not ready for work yet -- see the note at the bottom.
In a recent PR, there was a need for code like this:
current_draft: Optional[Draft] = getattr(entity, "draft", None)
current_published: Optional[Published] = getattr(entity, "published", None)
This is because creating a new PublishableEntity does not populate these other models:
https://github.com/openedx/openedx-learning/blob/ae597431892807b65243eba0b835e515c58da077/openedx_learning/apps/authoring/publishing/api.py#L183-L205
I think I originally wanted to distinguish between never published and published-but-since-unpublished. But now we have a whole PublishLog to track that.
Problem: The Published model actually has a non-nullable reference to a PublishLogRecord that points to how this particular version became the published version. If we initialize a Published entry to null, we would have to make this field nullable as well. Is that tradeoff worth it, or should we just make helpers on PublishableEntity to return the draft and published versions instead?
NOTE: This is not ready for work yet -- see the note at the bottom.
In a recent PR, there was a need for code like this:
This is because creating a new
PublishableEntitydoes not populate these other models:https://github.com/openedx/openedx-learning/blob/ae597431892807b65243eba0b835e515c58da077/openedx_learning/apps/authoring/publishing/api.py#L183-L205
I think I originally wanted to distinguish between never published and published-but-since-unpublished. But now we have a whole
PublishLogto track that.Problem: The
Publishedmodel actually has a non-nullable reference to aPublishLogRecordthat points to how this particular version became the published version. If we initialize aPublishedentry to null, we would have to make this field nullable as well. Is that tradeoff worth it, or should we just make helpers onPublishableEntityto return the draft and published versions instead?