Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge down hotfixes to unstable #4071

Merged
merged 13 commits into from
May 30, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self, name, app_label):
super(Migration, self).__init__(name, 'django_celery_results')

dependencies = [
('contentcuration', '0141_soft_delete_user'),
('contentcuration', '0140_delete_task'),
('django_celery_results', '0011_taskresult_periodic_task_name'),
]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 3.2.18 on 2023-04-26 18:55
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('contentcuration', '0141_add_task_signature'),
]

operations = [
migrations.RemoveConstraint(
model_name='file',
name='file_media_duration_int',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.18 on 2023-05-03 15:28
from django.db import migrations
from django.db import models


class Migration(migrations.Migration):

dependencies = [
('contentcuration', '0142_remove_file_file_media_duration_int'),
]

operations = [
migrations.AddConstraint(
model_name='file',
constraint=models.CheckConstraint(check=models.Q(models.Q(('duration__gt', 0), ('preset__in', ['audio', 'audio_dependency', 'high_res_video', 'low_res_video', 'video_dependency'])), ('duration__isnull', True), _connector='OR'), name='file_media_duration_int'),
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class Migration(migrations.Migration):

dependencies = [
('contentcuration', '0140_delete_task'),
('contentcuration', '0143_file_file_media_duration_int'),
]

operations = [
Expand Down
15 changes: 13 additions & 2 deletions contentcuration/contentcuration/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2179,7 +2179,13 @@ class StagedFile(models.Model):
FILE_DISTINCT_INDEX_NAME = "file_checksum_file_size_idx"
FILE_MODIFIED_DESC_INDEX_NAME = "file_modified_desc_idx"
FILE_DURATION_CONSTRAINT = "file_media_duration_int"
MEDIA_PRESETS = [format_presets.AUDIO, format_presets.VIDEO_HIGH_RES, format_presets.VIDEO_LOW_RES]
MEDIA_PRESETS = [
format_presets.AUDIO,
format_presets.AUDIO_DEPENDENCY,
format_presets.VIDEO_HIGH_RES,
format_presets.VIDEO_LOW_RES,
format_presets.VIDEO_DEPENDENCY,
]


class File(models.Model):
Expand Down Expand Up @@ -2331,7 +2337,12 @@ class Meta:
models.Index(fields=["-modified"], name=FILE_MODIFIED_DESC_INDEX_NAME),
]
constraints = [
models.CheckConstraint(check=(Q(preset__in=MEDIA_PRESETS, duration__gt=0) | Q(duration__isnull=True)), name=FILE_DURATION_CONSTRAINT)
# enforces that duration is null when not a media preset, but the duration may be null for media presets
# but if not-null, should be greater than 0
models.CheckConstraint(
check=(Q(preset__in=MEDIA_PRESETS, duration__gt=0) | Q(duration__isnull=True)),
name=FILE_DURATION_CONSTRAINT
)
]


Expand Down
2 changes: 1 addition & 1 deletion contentcuration/kolibri_public/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Migration(migrations.Migration):
initial = True

dependencies = [
("contentcuration", "0142_add_task_signature"),
("contentcuration", "0141_add_task_signature"),
]

operations = [
Expand Down