openedx / openedx/openedx-core

Creating a new PublishableEntity should automatically create a row in Draft and Published

Open
#362 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10
Forks
32
Avg merge
2d 17h
Merged PRs (30d)
12

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

This issue is explicitly not ready for work. Start by reading openedx_learning/apps/authoring/publishing/api.py around lines 183-205, then inspect PublishableEntity, Draft, Published, and PublishLogRecord. Done means choosing between automatic rows and helper methods, documenting that decision, and updating the affected model/API behavior consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
api, backend, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.