Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -71,9 +71,9 @@ describe('fileUpload', () => {
});
describe('computed', () => {
it('should map the files to the correct presets', () => {
expect(wrapper.vm.primaryFileMapping[0].file.id).toBe('file-3');
expect(wrapper.vm.primaryFileMapping[1].file.id).toBe('file-1');
expect(wrapper.vm.primaryFileMapping).toHaveLength(2);
expect(wrapper.vm.primaryFileMapping[1].file.id).toBe('file-3');
expect(wrapper.vm.primaryFileMapping[2].file.id).toBe('file-1');
Comment on lines +74 to +75
Copy link
Member

Choose a reason for hiding this comment

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

Were these failing before or just not testing what they were supposed to test?

Copy link
Member

Choose a reason for hiding this comment

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

They were just brittle to the order of file presets - because the bloompub preset happened to go before epub and pdf, (because alphabetical) it moved them each down a place.

expect(wrapper.vm.primaryFileMapping).toHaveLength(3);
});
it('should disallow file removal if there is only one primary file', () => {
const testFiles2 = [
Expand All @@ -95,7 +95,7 @@ describe('fileUpload', () => {
describe('methods', () => {
let uploadItem;
beforeEach(() => {
uploadItem = wrapper.findAll(FileUploadItem).at(1);
uploadItem = wrapper.findAll(FileUploadItem).at(2);
});
it('should automatically select the first file on load', () => {
expect(wrapper.vm.selected).toBe('file-3');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,23 @@ const FormatPresetsMap = new Map([
order: 2,
kind_id: 'audio',
allowed_formats: ['png', 'jpg', 'jpeg'],
associated_mimetypes: ['image/jpeg', 'image/png'],
associated_mimetypes: ['image/png', 'image/jpeg'],
},
],
[
'bloompub',
{
id: 'bloompub',
readable_name: 'Bloom Document',
multi_language: false,
supplementary: false,
thumbnail: false,
subtitle: false,
display: true,
order: 1,
kind_id: 'document',
allowed_formats: ['bloompub', 'bloomd'],
associated_mimetypes: ['application/bloompub+zip'],
},
],
[
Expand All @@ -61,7 +77,7 @@ const FormatPresetsMap = new Map([
order: 0,
kind_id: null,
allowed_formats: ['png', 'jpg', 'jpeg'],
associated_mimetypes: ['image/jpeg', 'image/png'],
associated_mimetypes: ['image/png', 'image/jpeg'],
},
],
[
Expand Down Expand Up @@ -93,7 +109,7 @@ const FormatPresetsMap = new Map([
order: 3,
kind_id: 'document',
allowed_formats: ['png', 'jpg', 'jpeg'],
associated_mimetypes: ['image/jpeg', 'image/png'],
associated_mimetypes: ['image/png', 'image/jpeg'],
},
],
[
Expand Down Expand Up @@ -141,7 +157,7 @@ const FormatPresetsMap = new Map([
order: 4,
kind_id: 'exercise',
allowed_formats: ['svg', 'json', 'graphie'],
associated_mimetypes: ['image/svg', '.graphie', 'application/json'],
associated_mimetypes: ['application/json', 'image/svg', '.graphie'],
},
],
[
Expand All @@ -157,7 +173,7 @@ const FormatPresetsMap = new Map([
order: 3,
kind_id: 'exercise',
allowed_formats: ['png', 'jpg', 'jpeg', 'gif', 'svg'],
associated_mimetypes: ['image/svg', 'image/gif', 'image/jpeg', 'image/png'],
associated_mimetypes: ['image/png', 'image/jpeg', 'image/svg', 'image/gif'],
},
],
[
Expand All @@ -173,7 +189,7 @@ const FormatPresetsMap = new Map([
order: 2,
kind_id: 'exercise',
allowed_formats: ['png', 'jpg', 'jpeg'],
associated_mimetypes: ['image/jpeg', 'image/png'],
associated_mimetypes: ['image/png', 'image/jpeg'],
},
],
[
Expand Down Expand Up @@ -205,7 +221,7 @@ const FormatPresetsMap = new Map([
order: 2,
kind_id: 'h5p',
allowed_formats: ['png', 'jpg', 'jpeg'],
associated_mimetypes: ['image/jpeg', 'image/png'],
associated_mimetypes: ['image/png', 'image/jpeg'],
},
],
[
Expand Down Expand Up @@ -253,7 +269,7 @@ const FormatPresetsMap = new Map([
order: 2,
kind_id: 'html5',
allowed_formats: ['png', 'jpg', 'jpeg'],
associated_mimetypes: ['image/jpeg', 'image/png'],
associated_mimetypes: ['image/png', 'image/jpeg'],
},
],
[
Expand All @@ -272,6 +288,22 @@ const FormatPresetsMap = new Map([
associated_mimetypes: ['.zip'],
},
],
[
'imscp_zip',
{
id: 'imscp_zip',
readable_name: 'IMSCP Zip',
multi_language: false,
supplementary: false,
thumbnail: false,
subtitle: false,
display: true,
order: 1,
kind_id: 'html5',
allowed_formats: ['zip'],
associated_mimetypes: ['.zip'],
},
],
[
'low_res_video',
{
Expand Down Expand Up @@ -317,7 +349,7 @@ const FormatPresetsMap = new Map([
order: 2,
kind_id: 'exercise',
allowed_formats: ['png', 'jpg', 'jpeg'],
associated_mimetypes: ['image/jpeg', 'image/png'],
associated_mimetypes: ['image/png', 'image/jpeg'],
},
],
[
Expand All @@ -333,7 +365,7 @@ const FormatPresetsMap = new Map([
order: 3,
kind_id: 'slideshow',
allowed_formats: ['png', 'jpg', 'jpeg'],
associated_mimetypes: ['image/jpeg', 'image/png'],
associated_mimetypes: ['image/png', 'image/jpeg'],
},
],
[
Expand Down Expand Up @@ -365,7 +397,7 @@ const FormatPresetsMap = new Map([
order: 2,
kind_id: 'slideshow',
allowed_formats: ['png', 'jpg', 'jpeg'],
associated_mimetypes: ['image/jpeg', 'image/png'],
associated_mimetypes: ['image/png', 'image/jpeg'],
},
],
[
Expand All @@ -381,7 +413,7 @@ const FormatPresetsMap = new Map([
order: 1,
kind_id: 'topic',
allowed_formats: ['png', 'jpg', 'jpeg'],
associated_mimetypes: ['image/jpeg', 'image/png'],
associated_mimetypes: ['image/png', 'image/jpeg'],
},
],
[
Expand Down Expand Up @@ -429,7 +461,7 @@ const FormatPresetsMap = new Map([
order: 3,
kind_id: 'video',
allowed_formats: ['png', 'jpg', 'jpeg'],
associated_mimetypes: ['image/jpeg', 'image/png'],
associated_mimetypes: ['image/png', 'image/jpeg'],
},
],
[
Expand Down Expand Up @@ -461,7 +493,7 @@ const FormatPresetsMap = new Map([
order: 2,
kind_id: 'zim',
allowed_formats: ['png', 'jpg', 'jpeg'],
associated_mimetypes: ['image/jpeg', 'image/png'],
associated_mimetypes: ['image/png', 'image/jpeg'],
},
],
]);
Expand All @@ -474,6 +506,7 @@ export const FormatPresetsNames = {
AUDIO: 'audio',
AUDIO_DEPENDENCY: 'audio_dependency',
AUDIO_THUMBNAIL: 'audio_thumbnail',
BLOOMPUB: 'bloompub',
CHANNEL_THUMBNAIL: 'channel_thumbnail',
DOCUMENT: 'document',
DOCUMENT_THUMBNAIL: 'document_thumbnail',
Expand All @@ -488,6 +521,7 @@ export const FormatPresetsNames = {
HTML5_DEPENDENCY: 'html5_dependency',
HTML5_THUMBNAIL: 'html5_thumbnail',
HTML5_ZIP: 'html5_zip',
IMSCP_ZIP: 'imscp_zip',
LOW_RES_VIDEO: 'low_res_video',
QTI: 'qti',
QTI_THUMBNAIL: 'qti_thumbnail',
Expand Down
1 change: 1 addition & 0 deletions contentcuration/contentcuration/frontend/shared/mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export const constantStrings = createTranslator('ConstantStrings', {
mp3: 'MP3 audio',
pdf: 'PDF document',
epub: 'EPub document',
bloompub: 'BloomPub document',
jpg: 'JPG image',
jpeg: 'JPEG image',
png: 'PNG image',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
ref="fileUpload"
style="display: none;"
type="file"
:accept="acceptedMimetypes"
:accept="acceptedFileTypes"
:multiple="allowMultiple"
data-test="upload-dialog"
@change="handleFiles($event.target.files)"
Expand Down Expand Up @@ -129,8 +129,12 @@
: !fp.supplementary && (!this.displayOnly || fp.display)
);
},
acceptedMimetypes() {
return flatMap(this.acceptedFiles, f => f.associated_mimetypes).join(',');
acceptedFileTypes() {
return uniq(
flatMap(this.acceptedFiles, f => f.associated_mimetypes).concat(
this.acceptedExtensions.map(ext => `.${ext}`)
)
).join(',');
},
acceptedExtensions() {
return uniq(flatMap(this.acceptedFiles, f => f.allowed_formats));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.24 on 2024-09-17 16:37
from django.db import migrations
from django.db import models


class Migration(migrations.Migration):

dependencies = [
('contentcuration', '0149_unpublishable_change_field'),
]

operations = [
migrations.AlterField(
model_name='fileformat',
name='extension',
field=models.CharField(choices=[('mp4', 'MP4 Video'), ('webm', 'WEBM Video'), ('vtt', 'VTT Subtitle'), ('mp3', 'MP3 Audio'), ('pdf', 'PDF Document'), ('jpg', 'JPG Image'), ('jpeg', 'JPEG Image'), ('png', 'PNG Image'), ('gif', 'GIF Image'), ('json', 'JSON'), ('svg', 'SVG Image'), ('perseus', 'Perseus Exercise'), ('graphie', 'Graphie Exercise'), ('zip', 'HTML5 Zip'), ('h5p', 'H5P'), ('zim', 'ZIM'), ('epub', 'ePub Document'), ('bloompub', 'Bloom Document'), ('bloomd', 'Bloom Document')], max_length=40, primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='formatpreset',
name='id',
field=models.CharField(choices=[('high_res_video', 'High Resolution'), ('low_res_video', 'Low Resolution'), ('video_thumbnail', 'Thumbnail'), ('video_subtitle', 'Subtitle'), ('video_dependency', 'Video (dependency)'), ('audio', 'Audio'), ('audio_thumbnail', 'Thumbnail'), ('audio_dependency', 'audio (dependency)'), ('document', 'Document'), ('epub', 'ePub Document'), ('document_thumbnail', 'Thumbnail'), ('exercise', 'Exercise'), ('exercise_thumbnail', 'Thumbnail'), ('exercise_image', 'Exercise Image'), ('exercise_graphie', 'Exercise Graphie'), ('channel_thumbnail', 'Channel Thumbnail'), ('topic_thumbnail', 'Thumbnail'), ('html5_zip', 'HTML5 Zip'), ('html5_dependency', 'HTML5 Dependency (Zip format)'), ('html5_thumbnail', 'HTML5 Thumbnail'), ('h5p', 'H5P Zip'), ('h5p_thumbnail', 'H5P Thumbnail'), ('zim', 'Zim'), ('zim_thumbnail', 'Zim Thumbnail'), ('qti', 'QTI Zip'), ('qti_thumbnail', 'QTI Thumbnail'), ('slideshow_image', 'Slideshow Image'), ('slideshow_thumbnail', 'Slideshow Thumbnail'), ('slideshow_manifest', 'Slideshow Manifest'), ('imscp_zip', 'IMSCP Zip'), ('bloompub', 'Bloom Document')], max_length=150, primary_key=True, serialize=False),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 3.2.24 on 2024-06-12 18:47

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('content', '0020_alter_file_preset'),
]

operations = [
migrations.AlterField(
model_name='file',
name='extension',
field=models.CharField(blank=True, choices=[('mp4', 'MP4 Video'), ('webm', 'WEBM Video'), ('vtt', 'VTT Subtitle'), ('mp3', 'MP3 Audio'), ('pdf', 'PDF Document'), ('jpg', 'JPG Image'), ('jpeg', 'JPEG Image'), ('png', 'PNG Image'), ('gif', 'GIF Image'), ('json', 'JSON'), ('svg', 'SVG Image'), ('perseus', 'Perseus Exercise'), ('graphie', 'Graphie Exercise'), ('zip', 'HTML5 Zip'), ('h5p', 'H5P'), ('zim', 'ZIM'), ('epub', 'ePub Document'), ('bloompub', 'bloom Document')], max_length=40),
),
migrations.AlterField(
model_name='file',
name='preset',
field=models.CharField(blank=True, choices=[('high_res_video', 'High Resolution'), ('low_res_video', 'Low Resolution'), ('video_thumbnail', 'Thumbnail'), ('video_subtitle', 'Subtitle'), ('video_dependency', 'Video (dependency)'), ('audio', 'Audio'), ('audio_thumbnail', 'Thumbnail'), ('audio_dependency', 'audio (dependency)'), ('document', 'Document'), ('epub', 'ePub Document'), ('document_thumbnail', 'Thumbnail'), ('exercise', 'Exercise'), ('exercise_thumbnail', 'Thumbnail'), ('exercise_image', 'Exercise Image'), ('exercise_graphie', 'Exercise Graphie'), ('channel_thumbnail', 'Channel Thumbnail'), ('topic_thumbnail', 'Thumbnail'), ('html5_zip', 'HTML5 Zip'), ('html5_dependency', 'HTML5 Dependency (Zip format)'), ('html5_thumbnail', 'HTML5 Thumbnail'), ('h5p', 'H5P Zip'), ('h5p_thumbnail', 'H5P Thumbnail'), ('zim', 'Zim'), ('zim_thumbnail', 'Zim Thumbnail'), ('qti', 'QTI Zip'), ('qti_thumbnail', 'QTI Thumbnail'), ('slideshow_image', 'Slideshow Image'), ('slideshow_thumbnail', 'Slideshow Thumbnail'), ('slideshow_manifest', 'Slideshow Manifest'), ('imscp_zip', 'IMSCP Zip'), ('bloompub', 'Bloom Document')], max_length=150),
),
migrations.AlterField(
model_name='localfile',
name='extension',
field=models.CharField(blank=True, choices=[('mp4', 'MP4 Video'), ('webm', 'WEBM Video'), ('vtt', 'VTT Subtitle'), ('mp3', 'MP3 Audio'), ('pdf', 'PDF Document'), ('jpg', 'JPG Image'), ('jpeg', 'JPEG Image'), ('png', 'PNG Image'), ('gif', 'GIF Image'), ('json', 'JSON'), ('svg', 'SVG Image'), ('perseus', 'Perseus Exercise'), ('graphie', 'Graphie Exercise'), ('zip', 'HTML5 Zip'), ('h5p', 'H5P'), ('zim', 'ZIM'), ('epub', 'ePub Document'), ('bloompub', 'bloom Document')], max_length=40),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.24 on 2024-09-15 14:14

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('content', '0021_auto_20240612_1847'),
]

operations = [
migrations.AlterField(
model_name='file',
name='extension',
field=models.CharField(blank=True, choices=[('mp4', 'MP4 Video'), ('webm', 'WEBM Video'), ('vtt', 'VTT Subtitle'), ('mp3', 'MP3 Audio'), ('pdf', 'PDF Document'), ('jpg', 'JPG Image'), ('jpeg', 'JPEG Image'), ('png', 'PNG Image'), ('gif', 'GIF Image'), ('json', 'JSON'), ('svg', 'SVG Image'), ('perseus', 'Perseus Exercise'), ('graphie', 'Graphie Exercise'), ('zip', 'HTML5 Zip'), ('h5p', 'H5P'), ('zim', 'ZIM'), ('epub', 'ePub Document'), ('bloompub', 'Bloom Document'), ('bloomd', 'Bloom Document')], max_length=40),
),
migrations.AlterField(
model_name='localfile',
name='extension',
field=models.CharField(blank=True, choices=[('mp4', 'MP4 Video'), ('webm', 'WEBM Video'), ('vtt', 'VTT Subtitle'), ('mp3', 'MP3 Audio'), ('pdf', 'PDF Document'), ('jpg', 'JPG Image'), ('jpeg', 'JPEG Image'), ('png', 'PNG Image'), ('gif', 'GIF Image'), ('json', 'JSON'), ('svg', 'SVG Image'), ('perseus', 'Perseus Exercise'), ('graphie', 'Graphie Exercise'), ('zip', 'HTML5 Zip'), ('h5p', 'H5P'), ('zim', 'ZIM'), ('epub', 'ePub Document'), ('bloompub', 'Bloom Document'), ('bloomd', 'Bloom Document')], max_length=40),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.24 on 2024-06-12 18:47

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('kolibri_public', '0003_alter_file_preset'),
]

operations = [
migrations.AlterField(
model_name='file',
name='preset',
field=models.CharField(blank=True, choices=[('high_res_video', 'High Resolution'), ('low_res_video', 'Low Resolution'), ('video_thumbnail', 'Thumbnail'), ('video_subtitle', 'Subtitle'), ('video_dependency', 'Video (dependency)'), ('audio', 'Audio'), ('audio_thumbnail', 'Thumbnail'), ('audio_dependency', 'audio (dependency)'), ('document', 'Document'), ('epub', 'ePub Document'), ('document_thumbnail', 'Thumbnail'), ('exercise', 'Exercise'), ('exercise_thumbnail', 'Thumbnail'), ('exercise_image', 'Exercise Image'), ('exercise_graphie', 'Exercise Graphie'), ('channel_thumbnail', 'Channel Thumbnail'), ('topic_thumbnail', 'Thumbnail'), ('html5_zip', 'HTML5 Zip'), ('html5_dependency', 'HTML5 Dependency (Zip format)'), ('html5_thumbnail', 'HTML5 Thumbnail'), ('h5p', 'H5P Zip'), ('h5p_thumbnail', 'H5P Thumbnail'), ('zim', 'Zim'), ('zim_thumbnail', 'Zim Thumbnail'), ('qti', 'QTI Zip'), ('qti_thumbnail', 'QTI Thumbnail'), ('slideshow_image', 'Slideshow Image'), ('slideshow_thumbnail', 'Slideshow Thumbnail'), ('slideshow_manifest', 'Slideshow Manifest'), ('imscp_zip', 'IMSCP Zip'), ('bloompub', 'Bloom Document')], max_length=150),
),
migrations.AlterField(
model_name='localfile',
name='extension',
field=models.CharField(blank=True, choices=[('mp4', 'MP4 Video'), ('webm', 'WEBM Video'), ('vtt', 'VTT Subtitle'), ('mp3', 'MP3 Audio'), ('pdf', 'PDF Document'), ('jpg', 'JPG Image'), ('jpeg', 'JPEG Image'), ('png', 'PNG Image'), ('gif', 'GIF Image'), ('json', 'JSON'), ('svg', 'SVG Image'), ('perseus', 'Perseus Exercise'), ('graphie', 'Graphie Exercise'), ('zip', 'HTML5 Zip'), ('h5p', 'H5P'), ('zim', 'ZIM'), ('epub', 'ePub Document'), ('bloompub', 'bloom Document')], max_length=40),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.24 on 2024-09-15 14:14

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('kolibri_public', '0004_auto_20240612_1847'),
]

operations = [
migrations.AlterField(
model_name='localfile',
name='extension',
field=models.CharField(blank=True, choices=[('mp4', 'MP4 Video'), ('webm', 'WEBM Video'), ('vtt', 'VTT Subtitle'), ('mp3', 'MP3 Audio'), ('pdf', 'PDF Document'), ('jpg', 'JPG Image'), ('jpeg', 'JPEG Image'), ('png', 'PNG Image'), ('gif', 'GIF Image'), ('json', 'JSON'), ('svg', 'SVG Image'), ('perseus', 'Perseus Exercise'), ('graphie', 'Graphie Exercise'), ('zip', 'HTML5 Zip'), ('h5p', 'H5P'), ('zim', 'ZIM'), ('epub', 'ePub Document'), ('bloompub', 'Bloom Document'), ('bloomd', 'Bloom Document')], max_length=40),
),
]
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jsonschema==4.17.3
# via -r requirements.in
kombu==5.2.4
# via celery
le-utils==0.2.5
le-utils==0.2.7
# via -r requirements.in
packaging==24.0
# via
Expand Down