Skip to content
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e4a589d
Create ChannelVersion model with token support
taoerman Dec 3, 2025
66f50b7
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Dec 3, 2025
31039f6
fix linting
taoerman Dec 3, 2025
82dad0f
fix code
taoerman Dec 4, 2025
7743900
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Dec 4, 2025
50f0355
fix code
taoerman Dec 4, 2025
64311a2
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Dec 4, 2025
50398cf
fix code
taoerman Dec 4, 2025
17c9e4c
fix code
taoerman Dec 4, 2025
4819470
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Dec 4, 2025
2573dcd
fix test
taoerman Dec 4, 2025
3339633
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Dec 4, 2025
2a4e5ef
fix bug
taoerman Dec 5, 2025
54867ca
Merge branch 'issue-5460-Create-ChannelVersion-model-with-token-suppo…
taoerman Dec 5, 2025
4b73ac1
fix bug
taoerman Dec 5, 2025
33e0391
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Dec 5, 2025
e355fb1
fix code
taoerman Dec 5, 2025
9792dab
fix code
taoerman Dec 5, 2025
ca6856f
Merge branch 'unstable' into issue-5460-Create-ChannelVersion-model-w…
taoerman Dec 5, 2025
b213fd0
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Dec 5, 2025
609e651
fix code
taoerman Dec 6, 2025
9c1fa51
fix linting
taoerman Dec 6, 2025
a7c0245
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Dec 6, 2025
458cc76
fix linting
taoerman Dec 6, 2025
a3c2798
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Dec 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,10 @@ const nonPublishedChannel = {
};

const publishedData = {
2: {
included_languages: ['en', null],
included_licenses: [1],
included_categories: [Categories.SCHOOL],
},
1: {
included_languages: ['en', null],
included_licenses: [1],
included_categories: [Categories.SCHOOL],
},
version: 2,
included_languages: ['en', null],
included_licenses: [1],
included_categories: [Categories.SCHOOL],
};

const submittedLatestSubmission = { channel_version: 2, status: CommunityLibraryStatus.PENDING };
Expand Down Expand Up @@ -152,7 +146,7 @@ describe('SubmitToCommunityLibrarySidePanel', () => {
it('when channel is not published', async () => {
const wrapper = await makeWrapper({
channel: nonPublishedChannel,
publishedData: {},
publishedData: null,
latestSubmission: null,
});

Expand Down Expand Up @@ -304,12 +298,10 @@ describe('SubmitToCommunityLibrarySidePanel', () => {

const channel = { ...publishedNonPublicChannel, publishing: true };
const publishedDataWithVersion3 = {
...publishedData,
3: {
included_languages: ['en', null],
included_licenses: [1],
included_categories: [Categories.SCHOOL],
},
version: 3,
included_languages: ['en', null],
included_licenses: [1],
included_categories: [Categories.SCHOOL],
};
const wrapper = await makeWrapper({
channel,
Expand Down Expand Up @@ -437,7 +429,7 @@ describe('SubmitToCommunityLibrarySidePanel', () => {
it('when channel is not published', async () => {
const wrapper = await makeWrapper({
channel: nonPublishedChannel,
publishedData: {},
publishedData: null,
latestSubmission: null,
});

Expand Down Expand Up @@ -473,7 +465,7 @@ describe('SubmitToCommunityLibrarySidePanel', () => {
it('when channel is not published', async () => {
const wrapper = await makeWrapper({
channel: nonPublishedChannel,
publishedData: {},
publishedData: null,
latestSubmission: null,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { useFetch } from '../../../../composables/useFetch';
import { Channel } from 'shared/data/resources';

export function usePublishedData(channelId) {
return useFetch({ asyncFetchFunc: () => Channel.getPublishedData(channelId) });
return useFetch({ asyncFetchFunc: () => Channel.getVersionDetail(channelId) });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting that we should also update this here to use the new info (since this would directly return the latestPublishedData object).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, Thanks!

}
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,7 @@
});
const latestPublishedData = computed(() => {
if (!publishedData.value || !displayedVersion.value) return undefined;
return publishedData.value[displayedVersion.value];
return publishedData.value;
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we don't actually need to create a computed property to wrap another computed property without doing any other computation. For this, I think it'd be best just to rename the publishedData property to something like versionDetail and use this property instead of the latestPublishedData property.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that there are some fields that have changed, like the community_library_invalid_licenses -> non_distributable_licenses_included and community_library_special_permissions -> special_permissions_included

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I have deleted the redundant computed property and changed the outdated filed names to the new one.

// Watch for when publishing completes - fetch publishedData to get the new version's data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1412,8 +1412,8 @@ export const Channel = new CreateModelResource({
.then(response => response.data.languages);
return uniq(compact(localLanguages.concat(remoteLanguages)));
},
async getPublishedData(id) {
const response = await client.get(window.Urls.channel_published_data(id));
async getVersionDetail(id) {
const response = await client.get(window.Urls.channel_version_detail(id));
return response.data;
},
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,293 @@
# Generated by Django 3.2.24 on 2025-12-03 03:00
import uuid

import django.contrib.postgres.fields
import django.db.models.deletion
from django.db import migrations
from django.db import models

import contentcuration.models


class Migration(migrations.Migration):

dependencies = [
("contentcuration", "0159_update_community_library_submission_date_updated"),
]

operations = [
migrations.CreateModel(
name="ChannelVersion",
fields=[
(
"id",
contentcuration.models.UUIDField(
default=uuid.uuid4,
primary_key=True,
serialize=False,
),
),
("version", models.PositiveIntegerField(blank=True, null=True)),
("version_notes", models.TextField(blank=True, null=True)),
("size", models.PositiveIntegerField(blank=True, null=True)),
("date_published", models.DateTimeField(blank=True, null=True)),
("resource_count", models.PositiveIntegerField(blank=True, null=True)),
(
"kind_count",
django.contrib.postgres.fields.ArrayField(
base_field=models.JSONField(),
blank=True,
null=True,
size=None,
validators=[contentcuration.models.validate_kind_count_item],
),
),
(
"included_licenses",
django.contrib.postgres.fields.ArrayField(
base_field=models.IntegerField(
choices=[
(1, "CC BY"),
(2, "CC BY-SA"),
(3, "CC BY-ND"),
(4, "CC BY-NC"),
(5, "CC BY-NC-SA"),
(6, "CC BY-NC-ND"),
(7, "All Rights Reserved"),
(8, "Public Domain"),
(9, "Special Permissions"),
]
),
blank=True,
null=True,
size=None,
),
),
(
"included_categories",
django.contrib.postgres.fields.ArrayField(
base_field=models.CharField(
choices=[
(
"d&WXdXWF.qs0Xlaxq.0t5msbL5",
"d&WXdXWF.qs0Xlaxq.0t5msbL5",
),
(
"d&WXdXWF.K80UMYnW.ViBlbQR&",
"d&WXdXWF.K80UMYnW.ViBlbQR&",
),
(
"d&WXdXWF.qs0Xlaxq.nG96nHDc",
"d&WXdXWF.qs0Xlaxq.nG96nHDc",
),
("d&WXdXWF.5QAjgfv7", "d&WXdXWF.5QAjgfv7"),
(
"d&WXdXWF.i1IdaNwr.mjSF4QlF",
"d&WXdXWF.i1IdaNwr.mjSF4QlF",
),
(
"d&WXdXWF.i1IdaNwr.uErN4PdS",
"d&WXdXWF.i1IdaNwr.uErN4PdS",
),
(
"d&WXdXWF.qs0Xlaxq.8rJ57ht6",
"d&WXdXWF.qs0Xlaxq.8rJ57ht6",
),
(
"d&WXdXWF.i1IdaNwr.#r5ocgid",
"d&WXdXWF.i1IdaNwr.#r5ocgid",
),
(
"d&WXdXWF.K80UMYnW.F863vKiF",
"d&WXdXWF.K80UMYnW.F863vKiF",
),
("d&WXdXWF.e#RTW9E#", "d&WXdXWF.e#RTW9E#"),
("PbGoe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"d&WXdXWF.5QAjgfv7.4LskOFXj",
"d&WXdXWF.5QAjgfv7.4LskOFXj",
),
(
"d&WXdXWF.e#RTW9E#.P7s8FxQ8",
"d&WXdXWF.e#RTW9E#.P7s8FxQ8",
),
("l7DsPDlm", "l7DsPDlm"),
(
"d&WXdXWF.kHKJ&PbV.KFJOCr&6",
"d&WXdXWF.kHKJ&PbV.KFJOCr&6",
),
],
max_length=100,
),
blank=True,
null=True,
size=None,
),
),
(
"included_languages",
django.contrib.postgres.fields.ArrayField(
base_field=models.CharField(max_length=100),
blank=True,
null=True,
size=None,
validators=[contentcuration.models.validate_language_code],
),
),
(
"non_distributable_licenses_included",
django.contrib.postgres.fields.ArrayField(
base_field=models.IntegerField(
choices=[
(1, "CC BY"),
(2, "CC BY-SA"),
(3, "CC BY-ND"),
(4, "CC BY-NC"),
(5, "CC BY-NC-SA"),
(6, "CC BY-NC-ND"),
(7, "All Rights Reserved"),
(8, "Public Domain"),
(9, "Special Permissions"),
]
),
blank=True,
null=True,
size=None,
),
),
(
"channel",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="channel_versions",
to="contentcuration.channel",
),
),
(
"secret_token",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="contentcuration.secrettoken",
),
),
(
"special_permissions_included",
models.ManyToManyField(
blank=True,
related_name="channel_versions",
to="contentcuration.AuditedSpecialPermissionsLicense",
),
),
],
options={
"unique_together": {("channel", "version")},
},
),
migrations.AddField(
model_name="channel",
name="version_info",
field=models.OneToOneField(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="contentcuration.channelversion",
),
),
]
Loading