diff --git a/.editorconfig b/.editorconfig index 1f49431c53..8db7923734 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,5 +1,8 @@ root = true +[*] +max_line_length = 100 + [*.js] indent_size = 2 diff --git a/Makefile b/Makefile index b7575fe74e..be4a0b7b51 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ migrate: # 4) Remove the management command from this `deploy-migrate` recipe # 5) Repeat! deploy-migrate: - python contentcuration/manage.py export_channels_to_kolibri_public + echo "Nothing to do here!" contentnodegc: python contentcuration/manage.py garbage_collect diff --git a/contentcuration/contentcuration/db/models/manager.py b/contentcuration/contentcuration/db/models/manager.py index 4d833caf8f..db1e3a77bf 100644 --- a/contentcuration/contentcuration/db/models/manager.py +++ b/contentcuration/contentcuration/db/models/manager.py @@ -487,6 +487,7 @@ def _copy_tags(self, source_copy_id_map): tag_id_map[tag.id] = new_tag.id tags_to_create.append(new_tag) + # TODO: Can cleanup the above and change the below to use ignore_conflicts=True ContentTag.objects.bulk_create(tags_to_create) mappings_to_create = [ @@ -499,7 +500,10 @@ def _copy_tags(self, source_copy_id_map): for mapping in node_tags_mappings ] - self.model.tags.through.objects.bulk_create(mappings_to_create) + # In the case that we are copying a node that is in the weird state of having a tag + # that is duplicated (with a channel tag and a null channel tag) this can cause an error + # so we ignore conflicts here to ignore the duplicate tags. + self.model.tags.through.objects.bulk_create(mappings_to_create, ignore_conflicts=True) def _copy_assessment_items(self, source_copy_id_map): from contentcuration.models import File diff --git a/contentcuration/contentcuration/frontend/administration/pages/Channels/ChannelActionsDropdown.vue b/contentcuration/contentcuration/frontend/administration/pages/Channels/ChannelActionsDropdown.vue index e243a8fd98..491706777c 100644 --- a/contentcuration/contentcuration/frontend/administration/pages/Channels/ChannelActionsDropdown.vue +++ b/contentcuration/contentcuration/frontend/administration/pages/Channels/ChannelActionsDropdown.vue @@ -146,6 +146,9 @@ channel() { return this.getChannel(this.channelId); }, + name() { + return this.channel.name; + }, searchChannelEditorsLink() { return { name: RouteNames.USERS, diff --git a/contentcuration/contentcuration/frontend/administration/pages/Channels/ChannelDetails.vue b/contentcuration/contentcuration/frontend/administration/pages/Channels/ChannelDetails.vue index a7029e2710..b867ee36e8 100644 --- a/contentcuration/contentcuration/frontend/administration/pages/Channels/ChannelDetails.vue +++ b/contentcuration/contentcuration/frontend/administration/pages/Channels/ChannelDetails.vue @@ -19,7 +19,7 @@ - + This channel has been deleted @@ -102,6 +102,9 @@ channel() { return this.getChannel(this.channelId); }, + isDeleted() { + return this.channel && Boolean(this.channel?.deleted); + }, channelWithDetails() { if (!this.channel || !this.details) { return {}; diff --git a/contentcuration/contentcuration/frontend/channelEdit/__tests__/utils.spec.js b/contentcuration/contentcuration/frontend/channelEdit/__tests__/utils.spec.js index 1ea5215eb8..ac4ef7539e 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/__tests__/utils.spec.js +++ b/contentcuration/contentcuration/frontend/channelEdit/__tests__/utils.spec.js @@ -8,6 +8,7 @@ import { importedChannelLink, secondsToHms, getCompletionCriteriaLabels, + getCompletionDataFromNode, } from '../utils'; import router from '../router'; import { RouteNames } from '../constants'; @@ -475,6 +476,76 @@ describe('channelEdit utils', () => { }); describe(`getCompletionCriteriaLabels`, () => { + describe(`setting default values for completion and duration`, () => { + describe(`for audio and video content`, () => { + it(`returns 'When time spent is equal to duration' completion label and duration label equal to the file length in hh:mm:ss format`, () => { + expect( + getCompletionCriteriaLabels( + { + extra_fields: { + options: {}, + }, + kind: 'audio', + }, + [{ duration: 100 }] + ) + ).toEqual({ + completion: 'When time spent is equal to duration', + duration: '01:40', + }); + }); + it(`returns 'When time spent is equal to duration' completion label and duration label equal to the file length in hh:mm:ss format`, () => { + expect( + getCompletionCriteriaLabels( + { + extra_fields: { + options: {}, + }, + kind: 'video', + }, + [{ duration: 100 }] + ) + ).toEqual({ + completion: 'When time spent is equal to duration', + duration: '01:40', + }); + }); + }); + describe(`for documents`, () => { + it(`returns 'Viewed in its entirety' completion label and empty duration label`, () => { + expect( + getCompletionCriteriaLabels( + { + extra_fields: { + options: {}, + }, + kind: 'document', + }, + [] + ) + ).toEqual({ + completion: 'Viewed in its entirety', + duration: '-', + }); + }); + }); + describe(`for exercises`, () => { + it(`sets the Completion Criteria model to 'mastery'`, () => { + expect( + getCompletionDataFromNode( + { + extra_fields: { + options: {}, + }, + kind: 'exercise', + }, + [] + ).completionModel + ).toEqual('mastery'); + }); + }); + }); + describe(`for 'reference' completion criteria`, () => { it(`returns 'Reference material' completion label and empty duration label`, () => { expect( diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/AssessmentItemToolbar.vue b/contentcuration/contentcuration/frontend/channelEdit/components/AssessmentItemToolbar.vue index 6c37c32c3b..cb04a42302 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/AssessmentItemToolbar.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/AssessmentItemToolbar.vue @@ -15,7 +15,7 @@ v-on="on" @click="clickItem(action)" > - + {{ config[action].icon }} diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/ContentNodeListItem/index.vue b/contentcuration/contentcuration/frontend/channelEdit/components/ContentNodeListItem/index.vue index 6ca94fa902..ba6d555b85 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/ContentNodeListItem/index.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/ContentNodeListItem/index.vue @@ -97,7 +97,7 @@ > {{ category(node.categories) }} - +