GeezerVison is showing github.com — fix: populate channel snapshot fields on draft ChannelVersion during draft publish by rtibblesbot · Pull Request #5851 · learningequality/studio
Conversation
rtibblesbot
commented
Apr 18, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
Fixes the draft publish path to populate four channel-snapshot fields on the draft ChannelVersion row: channel_name, channel_description, channel_thumbnail_encoding, and channel_language.
ChannelVersion.save() has a snapshot branch gated on self._state.adding and self.version == self.channel.version, which never fires for drafts (version=None). This PR extends that condition to also trigger when self.version is None, so every save of a draft ChannelVersion row snapshots the current channel fields — covering both the first draft publish and subsequent refreshes that must overwrite stale values.
References
Fixes #5850. Related to #5841.
Reviewer guidance
The change is a one-line condition extension in ChannelVersion.save() in models.py: the existing snapshot branch (self._state.adding and self.version == self.channel.version) gains an or self.version is None guard so it also fires for draft rows. The snapshot field assignments (channel_name, channel_description, channel_tagline, channel_thumbnail_encoding, channel_language) are unchanged. The non-draft publish path is unaffected.
Two unit tests in DraftPublishChannelTestCase verify: (a) first draft publish populates all four fields, (b) a second draft publish overwrites stale values.
AI usage
Claude Code (claude-sonnet-4-6) implemented the fix and tests from a written plan. I reviewed the generated code for correctness, confirmed the non-draft publish path is unaffected, and verified the tests pass.
@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly
How was this generated?
- Ran pre-flight CI checks (lint, format, tests) and verified all pass
- Rebased onto the target branch and resolved any conflicts
- Reorganized commit history into clean, logical commits
- Audited the diff to ensure only issue-relevant files are changed
- Built PR body from the repository's PR template with evidence blocks

Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's simplify the code and not duplicate how we copy data from the Channel object to the ChannelVersion object - and remove an unnecessary test.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
rtibblesbot reacted with eyes emoji
|
|
version_obj.non_distributable_licenses_included = (
|
|
|
non_distributable_licenses_included
|
|
|
)
|
|
|
if is_draft:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused why this is even needed here, now that I look at the underlying code more closely - why don't we just loosen the condition that sets this exact setting in the ChannelVersion save method? That would require no changes here, we could just have it save when self.version is None or ... <existing conditions>.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done — moved the snapshot logic into ChannelVersion.save() by changing the condition to self.version is None or (self._state.adding and self.version == self.channel.version). The if-is_draft block in fill_published_fields is removed.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
{1: "v1 notes", 3: "v3 notes"},
|
|
|
)
|
|
|
|
|
|
def test_draft_channel_version_token_returns_snapshot_fields(self):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a totally unnecessary test addition, please remove.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Loosen the snapshot condition in ChannelVersion.save() to also fire when
version is None (draft rows), so every draft publish captures the current
channel name, description, thumbnail encoding, tagline, and language on
the draft ChannelVersion. Repeated draft publishes always reflect the
latest channel state.
Tests cover: first draft publish populates all four snapshot fields, and a
second draft publish after mutating channel metadata (including language
change from "en" to "fr") refreshes all four fields on the existing row.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, clean, minimal diff, and regression tested!
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
rtibbles
rtibbles approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|