You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
fill_published_fields is only called during non-draft channel publishes, leaving draft ChannelVersion objects (those with version=None) without computed metadata (resource count, size, kind count, languages, licenses, categories). Code that relies on this metadata being set breaks or returns stale values when a channel has only been published as a draft.
Complexity: Low Target branch: unstable
Context
fill_published_fields (in contentcuration/utils/publish.py) computes resource count, kind count, size, included languages, licenses, and categories, then writes them to:
The channel object's own fields (e.g. total_resource_count, published_size)
channel.published_data — a dict keyed by version number storing historical publish snapshots
channel.version_info — a ChannelVersion FK pointing to the currently-published version's record
Draft publishes create a ChannelVersion with version=None (via create_draft_channel_version), but this object is never populated with the computed metadata. For draft publishes, items 1, 2, and 3 above must not be updated — total_resource_count and published_size on the channel reflect the live published state, published_data tracks real published version snapshots, and version_info points to the live published version. None of these should be affected by a draft publish.
The Change
fill_published_fields should also be invoked when publishing a draft version. However, for draft publishes it must only populate the draft ChannelVersion object (the one with version=None) — setting its resource_count, size, kind_count, included_languages, included_licenses, included_categories, and related fields — without modifying channel.published_data, channel.version_info, channel.total_resource_count, or channel.published_size.
Two additional constraints for draft publishes:
Special permissions: on each draft publish, special_permissions_included on the draft ChannelVersion must be fully replaced (not accumulated) — a second draft publish should not carry over special permissions licenses from a previous draft publish that are no longer present.
Distributable flag: the call to AuditedSpecialPermissionsLicense.mark_channel_version_as_distributable (currently triggered when channel.public) must be skipped for draft publishes.
Acceptance Criteria
General
fill_published_fields (or equivalent extracted helper) is called during draft publishes
The draft ChannelVersion object (version=None) has resource_count, size, kind_count, included_languages, included_licenses, included_categories, and related fields populated after a draft publish
channel.published_data is not modified during a draft publish
channel.version_info is not updated during a draft publish
channel.total_resource_count and channel.published_size are not overwritten during a draft publish
A non-draft publish continues to work exactly as before — all channel fields, published_data, and version_info are still populated correctly
On a second consecutive draft publish, special_permissions_included on the draft ChannelVersion reflects only the current publish — licenses from the previous draft publish that are no longer present are removed
AuditedSpecialPermissionsLicense.mark_channel_version_as_distributable is not called during a draft publish, even if channel.public is True
Testing
Unit tests cover that draft ChannelVersion metadata fields are populated after a draft publish
Unit tests cover that channel.published_data, channel.version_info, channel.total_resource_count, and channel.published_size are unchanged after a draft publish
Unit test covers that a second draft publish replaces (not accumulates) special_permissions_included on the draft ChannelVersion
Unit test covers that mark_channel_version_as_distributable is not called during a draft publish for a public channel
Existing publish tests continue to pass
References
publish_channel and fill_published_fields — contentcuration/contentcuration/utils/publish.py
ChannelVersion model — contentcuration/contentcuration/models.py
Drafted with Claude Code. The issue structure, context, and acceptance criteria were derived from reading the relevant source files directly. Content was reviewed and edited for accuracy before submission.
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
fill_published_fieldsis only called during non-draft channel publishes, leaving draftChannelVersionobjects (those withversion=None) without computed metadata (resource count, size, kind count, languages, licenses, categories). Code that relies on this metadata being set breaks or returns stale values when a channel has only been published as a draft.Complexity: Low
Target branch: unstable
Context
fill_published_fields(incontentcuration/utils/publish.py) computes resource count, kind count, size, included languages, licenses, and categories, then writes them to:channelobject's own fields (e.g.total_resource_count,published_size)channel.published_data— a dict keyed by version number storing historical publish snapshotschannel.version_info— aChannelVersionFK pointing to the currently-published version's recordDraft publishes create a
ChannelVersionwithversion=None(viacreate_draft_channel_version), but this object is never populated with the computed metadata. For draft publishes, items 1, 2, and 3 above must not be updated —total_resource_countandpublished_sizeon the channel reflect the live published state,published_datatracks real published version snapshots, andversion_infopoints to the live published version. None of these should be affected by a draft publish.The Change
fill_published_fieldsshould also be invoked when publishing a draft version. However, for draft publishes it must only populate the draftChannelVersionobject (the one withversion=None) — setting itsresource_count,size,kind_count,included_languages,included_licenses,included_categories, and related fields — without modifyingchannel.published_data,channel.version_info,channel.total_resource_count, orchannel.published_size.Two additional constraints for draft publishes:
special_permissions_includedon the draftChannelVersionmust be fully replaced (not accumulated) — a second draft publish should not carry over special permissions licenses from a previous draft publish that are no longer present.AuditedSpecialPermissionsLicense.mark_channel_version_as_distributable(currently triggered whenchannel.public) must be skipped for draft publishes.Acceptance Criteria
General
fill_published_fields(or equivalent extracted helper) is called during draft publishesChannelVersionobject (version=None) hasresource_count,size,kind_count,included_languages,included_licenses,included_categories, and related fields populated after a draft publishchannel.published_datais not modified during a draft publishchannel.version_infois not updated during a draft publishchannel.total_resource_countandchannel.published_sizeare not overwritten during a draft publishpublished_data, andversion_infoare still populated correctlyspecial_permissions_includedon the draftChannelVersionreflects only the current publish — licenses from the previous draft publish that are no longer present are removedAuditedSpecialPermissionsLicense.mark_channel_version_as_distributableis not called during a draft publish, even ifchannel.publicisTrueTesting
ChannelVersionmetadata fields are populated after a draft publishchannel.published_data,channel.version_info,channel.total_resource_count, andchannel.published_sizeare unchanged after a draft publishspecial_permissions_includedon the draftChannelVersionmark_channel_version_as_distributableis not called during a draft publish for a public channelReferences
publish_channelandfill_published_fields—contentcuration/contentcuration/utils/publish.pyChannelVersionmodel —contentcuration/contentcuration/models.pycreate_draft_channel_version—contentcuration/contentcuration/utils/publish.pyAI usage
Drafted with Claude Code. The issue structure, context, and acceptance criteria were derived from reading the relevant source files directly. Content was reviewed and edited for accuracy before submission.