Skip to content

Commit

Permalink
Fix merge conflicts in requirements file
Browse files Browse the repository at this point in the history
  • Loading branch information
bjester committed Nov 1, 2023
2 parents c9ccae9 + 900c74a commit 729c9be
Show file tree
Hide file tree
Showing 31 changed files with 585 additions and 236 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/frontendlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
if: github.event.pull_request && github.event.pull_request.head.repo.full_name == github.repository
id: git-check
run: echo ::set-output name=modified::$(git diff-index --name-only HEAD)
- uses: tibdex/github-app-token@v1
- uses: tibdex/github-app-token@v2
if: github.event.pull_request && github.event.pull_request.head.repo.full_name == github.repository && steps.git-check.outputs.modified != ''
id: generate-token
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<VToolbarSideIcon @click="drawer = true" />
<VToolbarTitle>
{{ $tr('deploy') }} <span class="notranslate">{{ currentChannel.name }}</span>
<router-link :to="rootTreeRoute" class="body-1 pl-2" data-test="root-tree-link">
<KRouterLink :to="rootTreeRoute" class="body-1 pl-2" data-test="root-tree-link">
{{ $tr('backToViewing') }}
</router-link>
</KRouterLink>
</VToolbarTitle>

<VSpacer />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
v-if="$vuetify.breakpoint.smAndUp"
class="ml-4"
>
<router-link
<KRouterLink
:to="viewChannelDetailsLink"
@click="trackClickEvent('Summary')"
>
Expand All @@ -29,8 +29,8 @@
icon="info"
:text="$tr('channelDetails')"
/>
</router-link>
<router-link
</KRouterLink>
<KRouterLink
:to="editChannelLink"
@click="trackClickEvent('Edit channel')"
>
Expand All @@ -52,7 +52,7 @@
:text="$tr('editChannel')"
/>
</VBadge>
</router-link>
</KRouterLink>
</VToolbarItems>
<VSpacer />
<SavingIndicator v-if="!offline" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<VLayout align-center justify-start>
<Icon>build</Icon>
<span class="pl-1">
<router-link
<KRouterLink
:to="stagingTreeLink"
:style="{ 'text-decoration': 'underline' }"
data-test="staging-tree-link"
>{{ $tr('updatedResourcesReadyForReview') }}</router-link>
>{{ $tr('updatedResourcesReadyForReview') }}</KRouterLink>
(<time :datetime="channelModifiedDate">{{ prettyChannelModifiedDate }}</time>)
</span>
</VLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
</VTooltip>
<VSpacer />
<VFlex shrink>
<router-link
<KRouterLink
v-if="!libraryMode"
:to="channelDetailsLink"
>
Expand All @@ -103,7 +103,7 @@
@mouseleave.native="hideHighlight = false"
/>

</router-link>
</KRouterLink>

<IconButton
v-if="!allowEdit && channel.published"
Expand Down Expand Up @@ -144,19 +144,19 @@
data-test="edit-channel"
@click.stop
>
<VListTileAction>
<VListTileAvatar>
<Icon>edit</Icon>
</VListTileAction>
</VListTileAvatar>
<VListTileTitle>{{ $tr('editChannel') }}</VListTileTitle>
</VListTile>
<VListTile
v-if="allowEdit && channel.published"
data-test="token-listitem"
@click="tokenDialog = true"
>
<VListTileAction>
<VListTileAvatar>
<Icon>content_copy</Icon>
</VListTileAction>
</VListTileAvatar>
<VListTileTitle>{{ $tr('copyToken') }}</VListTileTitle>
</VListTile>
<VListTile
Expand All @@ -165,33 +165,33 @@
target="_blank"
@click.stop
>
<VListTileAction>
<VListTileAvatar>
<Icon class="rtl-flip">
launch
</Icon>
</VListTileAction>
</VListTileAvatar>
<VListTileTitle>{{ $tr('goToWebsite') }}</VListTileTitle>
</VListTile>
<VListTile
v-if="channel.demo_server_url"
:href="channel.demo_server_url"
target="_blank"
>
<VListTileAction>
<VListTileAvatar>
<Icon class="rtl-flip">
launch
</Icon>
</VListTileAction>
</VListTileAvatar>
<VListTileTitle>{{ $tr('viewContent') }}</VListTileTitle>
</VListTile>
<VListTile
v-if="allowEdit"
data-test="delete-channel"
@click.stop="deleteDialog = true"
>
<VListTileAction>
<VListTileAvatar>
<Icon>delete</Icon>
</VListTileAction>
</VListTileAvatar>
<VListTileTitle>{{ $tr('deleteChannel') }}</VListTileTitle>
</VListTile>
</VList>
Expand Down
2 changes: 2 additions & 0 deletions contentcuration/contentcuration/frontend/shared/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import Vuetify, {
VListTileContent,
VListTileSubTitle,
VListTileTitle,
VListTileAvatar,
VMenu,
VNavigationDrawer,
VPagination,
Expand Down Expand Up @@ -199,6 +200,7 @@ Vue.use(Vuetify, {
VListTileContent,
VListTileSubTitle,
VListTileTitle,
VListTileAvatar,
VMenu,
VNavigationDrawer,
VPagination,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Generated by Django 3.2.19 on 2023-09-14 05:08
import django.core.validators
import django.db.models.deletion
from celery import states
from django.conf import settings
from django.db import migrations
from django.db import models

def transfer_data(apps, schema_editor):
CustomTaskMetadata = apps.get_model('contentcuration', 'CustomTaskMetadata')
TaskResult = apps.get_model('django_celery_results', 'taskresult')

old_task_results = TaskResult.objects.filter(status__in=states.UNREADY_STATES)

for old_task_result in old_task_results:
CustomTaskMetadata.objects.create(
task_id=old_task_result.task_id,
user=old_task_result.user,
channel_id=old_task_result.channel_id,
progress=old_task_result.progress,
signature=old_task_result.signature,
)

class Migration(migrations.Migration):

dependencies = [
('contentcuration', '0144_soft_delete_user'),
]

operations = [
migrations.CreateModel(
name='CustomTaskMetadata',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('task_id', models.CharField(max_length=255, unique=True)),
('channel_id', models.UUIDField(blank=True, db_index=True, null=True)),
('progress', models.IntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)])),
('signature', models.CharField(max_length=32, null=True)),
('date_created', models.DateTimeField(auto_now_add=True, help_text='Datetime field when the custom_metadata for task was created in UTC', verbose_name='Created DateTime')),
('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='tasks', to=settings.AUTH_USER_MODEL)),
],
),
migrations.AddIndex(
model_name='customtaskmetadata',
index=models.Index(fields=['signature'], name='task_result_signature'),
),
migrations.RunPython(transfer_data),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by Django 3.2.19 on 2023-09-14 10:42
from django.db import migrations

class Migration(migrations.Migration):

replaces = [('django_celery_results', '0145_custom_task_metadata'),]

def __init__(self, name, app_label):
super(Migration, self).__init__(name, 'django_celery_results')

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

operations = [
migrations.RemoveField(
model_name='taskresult',
name='channel_id',
),
migrations.RemoveField(
model_name='taskresult',
name='progress',
),
migrations.RemoveField(
model_name='taskresult',
name='user',
),
migrations.RemoveField(
model_name='taskresult',
name='signature',
),
migrations.RemoveIndex(
model_name='taskresult',
name='task_result_signature_idx',
),
]
64 changes: 17 additions & 47 deletions contentcuration/contentcuration/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from datetime import datetime

import pytz
from celery import states as celery_states
from django.conf import settings
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.base_user import BaseUserManager
Expand Down Expand Up @@ -46,7 +45,6 @@
from django.dispatch import receiver
from django.utils import timezone
from django.utils.translation import gettext as _
from django_celery_results.models import TaskResult
from django_cte import With
from le_utils import proquint
from le_utils.constants import content_kinds
Expand All @@ -68,8 +66,8 @@
from contentcuration.constants import channel_history
from contentcuration.constants import completion_criteria
from contentcuration.constants import user_history
from contentcuration.constants.transcription_languages import CAPTIONS_LANGUAGES
from contentcuration.constants.contentnode import kind_activity_map
from contentcuration.constants.transcription_languages import CAPTIONS_LANGUAGES
from contentcuration.db.models.expressions import Array
from contentcuration.db.models.functions import ArrayRemove
from contentcuration.db.models.functions import Unnest
Expand Down Expand Up @@ -2081,11 +2079,11 @@ class Meta:

def __str__(self):
return "file_id: {file_id}, language: {language}".format(file_id=self.file_id, language=self.language)

def save(self, *args, **kwargs):
# Check if the language is supported by speech-to-text AI model.
if self.language and self.language.lang_code not in CAPTIONS_LANGUAGES:
raise ValueError(f"The language is currently not supported by speech-to-text model.")
raise ValueError("The language is currently not supported by speech-to-text model.")
super(CaptionFile, self).save(*args, **kwargs)


Expand All @@ -2107,6 +2105,7 @@ class CaptionCue(models.Model):
def __str__(self):
return "text: {text}, start_time: {starttime}, end_time: {endtime}".format(text=self.text, starttime=self.starttime, endtime=self.endtime)


ASSESSMENT_ID_INDEX_NAME = "assessment_id_idx"


Expand Down Expand Up @@ -2240,7 +2239,7 @@ class StagedFile(models.Model):

class File(models.Model):
"""
The bottom layer of the contentDB schema, defines the basic building brick for content.
The bottom layer of the contentDB schema, defines the basic build2086ing brick for content.
Things it can represent are, for example, mp4, avi, mov, html, css, jpeg, pdf, mp3...
"""
id = UUIDField(primary_key=True, default=uuid.uuid4)
Expand Down Expand Up @@ -2613,58 +2612,29 @@ def serialize_to_change_dict(self):
return self.serialize(self)


class TaskResultCustom(object):
"""
Custom fields to add to django_celery_results's TaskResult model
If adding fields to this class, run `makemigrations` then move the generated migration from the
`django_celery_results` app to the `contentcuration` app and override the constructor to change
the app_label. See `0141_add_task_signature` for an example
"""
class CustomTaskMetadata(models.Model):
# Task_id for reference
task_id = models.CharField(
max_length=255, # Adjust the max_length as needed
unique=True,
)
# user shouldn't be null, but in order to append the field, this needs to be allowed
user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name="tasks", on_delete=models.CASCADE, null=True)
channel_id = DjangoUUIDField(db_index=True, null=True, blank=True)
progress = models.IntegerField(null=True, blank=True, validators=[MinValueValidator(0), MaxValueValidator(100)])
# a hash of the task name and kwargs for identifying repeat tasks
signature = models.CharField(null=True, blank=False, max_length=32)

super_as_dict = TaskResult.as_dict

def as_dict(self):
"""
:return: A dictionary representation
"""
super_dict = self.super_as_dict()
super_dict.update(
user_id=self.user_id,
channel_id=self.channel_id,
progress=self.progress,
)
return super_dict

@classmethod
def contribute_to_class(cls, model_class=TaskResult):
"""
Adds fields to model, by default TaskResult
:param model_class: TaskResult model
"""
for field in dir(cls):
if not field.startswith("_") and field not in ('contribute_to_class', 'Meta'):
model_class.add_to_class(field, getattr(cls, field))

# manually add Meta afterwards
setattr(model_class._meta, 'indexes', getattr(model_class._meta, 'indexes', []) + cls.Meta.indexes)
date_created = models.DateTimeField(
auto_now_add=True,
verbose_name=_('Created DateTime'),
help_text=_('Datetime field when the custom_metadata for task was created in UTC')
)

class Meta:
indexes = [
# add index that matches query usage for signature
models.Index(
fields=['signature'],
name='task_result_signature_idx',
condition=Q(status__in=celery_states.UNREADY_STATES),
name='task_result_signature',
),
]


# trigger class contributions immediately
TaskResultCustom.contribute_to_class()
2 changes: 1 addition & 1 deletion contentcuration/contentcuration/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

import mock
from celery import states
from django_celery_results.models import TaskResult
from search.models import ContentNodeFullTextSearch

from contentcuration.models import ContentNode
from contentcuration.models import TaskResult


def clear_tasks(except_task_id=None):
Expand Down
Loading

0 comments on commit 729c9be

Please sign in to comment.