Skip to content

Commit c6033cd

Browse files
committed
Reapplied last fixes before transition to public repo
1 parent fe616b3 commit c6033cd

23 files changed

+351
-38
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from django.db import migrations, models
2+
3+
4+
class Migration(migrations.Migration):
5+
6+
dependencies = [
7+
('core', '0014_auto_20230213_0505'),
8+
]
9+
10+
operations = [
11+
migrations.AddField(
12+
model_name='tenant',
13+
name='audescribe_active',
14+
field=models.BooleanField(default=False),
15+
),
16+
]

pipeline/core/models/tenant.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Tenant(models.Model):
2121
aws_active = models.BooleanField(default=True)
2222
mllp_active = models.BooleanField(default=True)
2323
deepl_active = models.BooleanField(default=False)
24+
audescribe_active = models.BooleanField(default=False)
2425

2526
def get_secret(self, key, raise_exception=True, default=None):
2627
if key in self.secrets:
@@ -57,6 +58,9 @@ def active_cloud_services(self):
5758
if self.deepl_active:
5859
l.append(Subtitle.Origin.DEEPL)
5960

61+
if self.audescribe_active:
62+
l.append(Subtitle.Origin.AUDESCRIBE)
63+
6064
l.append(TranslationService.MANUAL)
6165

6266
return l

pipeline/mooclink/services/audescribe_transcription_service.py

Whitespace-only changes.

pipeline/mooclink/services/aws_translation_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def fetch_translation_jobs(self, video_id):
176176
if len(video.workflow_data['waiting_job_ids']) == 0:
177177
video.workflow_status = None
178178
if periodic_task_id := video.workflow_data.get('periodic_task_id'):
179-
PeriodicTask.objects.get(pk=periodic_task_id).delete()
179+
PeriodicTask.objects.filter(pk=periodic_task_id).delete()
180180
video.workflow_data['cleared'] = True
181181

182182
video.save()
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import json
2+
from datetime import datetime, timedelta
3+
4+
from django_celery_beat.models import IntervalSchedule, PeriodicTask
5+
6+
7+
class PeriodicTaskService:
8+
9+
@classmethod
10+
def create_periodic_task(cls, service_type, task, video, start_time=None, end_time=None):
11+
schedule, created = IntervalSchedule.objects.get_or_create(
12+
every=10,
13+
period=IntervalSchedule.MINUTES,
14+
)
15+
16+
if PeriodicTask.objects.filter(name=f"Check AWS StandaloneTranslation for video={video.pk}").count():
17+
return
18+
19+
periodic = PeriodicTask.objects.create(
20+
interval=schedule,
21+
name=f'Check AWS StandaloneTranslation for video={video.pk}',
22+
task=task,
23+
start_time=datetime.now() + timedelta(minutes=15),
24+
kwargs=json.dumps({
25+
'tenant_id': video.tenant_id,
26+
'video_id': video.pk,
27+
})
28+
)
29+
30+
return periodic
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{% extends "subtitles/base.html" %}
2+
{% block content %}
3+
{% load static %}
4+
{% load utils %}
5+
<link rel="stylesheet" href="{% static 'subtitles/css/mooclink.css' %}">
6+
7+
<div class="container-fluid">
8+
<h1>Pending Videos</h1>
9+
10+
<table class="table table-sm">
11+
<thead>
12+
<tr>
13+
<th>Video</th>
14+
<th>Service</th>
15+
<th>Started</th>
16+
<th>Action</th>
17+
</tr>
18+
</thead>
19+
<tbody>
20+
{% for video in pending_videos %}
21+
<tr>
22+
<td>
23+
<a href="{% tenant_url 'mooclink.video.index' course_id=video.course_section.course.ext_id video_id=video.ext_id tenant=video.tenant %}" target="_blank">
24+
{{ video }}
25+
</a>
26+
</td>
27+
<td>{{ video.workflow_status }}</td>
28+
<td>{{ video.job_initiated }}</td>
29+
<td>
30+
<button form="cancellation-form" type="submit" name="video_id" value="{{ video.id }}"
31+
class="btn btn-danger btn-sm"
32+
onclick="confirm('Please confirm the cancellation of job for video `{{ video }}`')">
33+
Cancel
34+
</button>
35+
</td>
36+
</tr>
37+
{% endfor %}
38+
</tbody>
39+
</table>
40+
41+
<h2>Orphaned Periodic Tasks</h2>
42+
<table class="table table-sm">
43+
<thead>
44+
<tr>
45+
<th>Video</th>
46+
<th>Started</th>
47+
<th>Action</th>
48+
</tr>
49+
</thead>
50+
<tbody>
51+
{% for orphaned in orphaned_tasks %}
52+
<tr>
53+
<td>
54+
<a href="{% tenant_url 'mooclink.video.index' course_id=orphaned.video.course_section.course.ext_id video_id=orphaned.video.ext_id tenant=orphaned.video.tenant %}" target="_blank">
55+
{{ orphaned.video }}
56+
</a>
57+
</td>
58+
<td>{{ orphaned.task.start_time }}</td>
59+
<td>
60+
<button type="submit" class="btn btn-sm btn-danger" name="periodic_task_id"
61+
value="{{ orphaned.task.pk }}" form="cancellation-form">Cancel
62+
</button>
63+
</td>
64+
</tr>
65+
{% endfor %}
66+
</tbody>
67+
</table>
68+
</div>
69+
<form action="{% url "mooclink.jobs.reset" %}" method="post" id="cancellation-form">
70+
{% csrf_token %}
71+
</form>
72+
{% endblock %}

pipeline/mooclink/templates/mooclink/course/overview.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ <h1 class="mt-2">{{ course.title }}</h1>
6767
{% if perms.subtitles.change_settings %}
6868
<option value="remove-assignment">Remove Assignments</option>
6969
{% endif %}
70+
<option value="download-vtt-files">Download VTT-Files</option>
7071
</select>
7172
<div class="input-group-append">
7273
<button class="btn btn-outline-primary" type="submit">GO</button>

pipeline/mooclink/templates/mooclink/course/settings.html

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
<div class="container-fluid">
88
<h1>{{ course.title }}</h1>
99

10-
<form action="{% tenant_url 'mooclink.course.settings' course_id=course.ext_id tenant=course.tenant %}" method="post"
10+
<form action="{% tenant_url 'mooclink.course.settings' course_id=course.ext_id tenant=course.tenant %}"
11+
method="post"
1112
id="delete-assigned-language-form">
1213
{% csrf_token %}
1314
<input type="hidden" name="action" value="delete_assigned_language">
1415
</form>
1516

1617
<h2 class="mt-3">Settings</h2>
17-
<form action="{% tenant_url 'mooclink.course.settings' course_id=course.ext_id tenant=course.tenant %}" method="post">
18+
<form action="{% tenant_url 'mooclink.course.settings' course_id=course.ext_id tenant=course.tenant %}"
19+
method="post">
1820
{% csrf_token %}
1921
<h4>Transcription</h4>
2022
<table>
@@ -26,7 +28,8 @@ <h4>Transcription</h4>
2628
<td>
2729
<select name="course-language" class="form-control">
2830
{% for lang in available_languages %}
29-
<option value="{{ lang.iso_code }}" {% if lang == course.language %}selected{% endif %}>{{ lang }}</option>
31+
<option value="{{ lang.iso_code }}"
32+
{% if lang == course.language %}selected{% endif %}>{{ lang }}</option>
3033
{% endfor %}
3134
</select>
3235
</td>
@@ -36,7 +39,13 @@ <h4>Transcription</h4>
3639
{% for transcription_service in supported_translation_services %}
3740
<option value="{{ transcription_service }}"
3841
{% if course.transcription_service == transcription_service %}
39-
selected{% endif %}>{{ transcription_service }}</option>
42+
selected{% endif %}>
43+
{% if transcription_service == "AUDESCR" %}
44+
AUDESCRIBE
45+
{% else %}
46+
{{ transcription_service }}
47+
{% endif %}
48+
</option>
4049
{% endfor %}
4150
</select>
4251
</td>
@@ -55,7 +64,8 @@ <h4 class="mt-3">Translation</h4>
5564
<tr>
5665
<td>{{ lang.iso_language }}</td>
5766
<td>
58-
<select name="service-provider-{{ lang.pk }}" class="form-control" id="service-provider" required>
67+
<select name="service-provider-{{ lang.pk }}" class="form-control" id="service-provider"
68+
required>
5969
{{ lang.translation_service }}
6070
<option value="">-- Please Select --</option>
6171
{% for translation_service in supported_translation_services %}
@@ -65,7 +75,8 @@ <h4 class="mt-3">Translation</h4>
6575
{% endfor %}
6676
</select>
6777
</td>
68-
<td><input type="checkbox" class="form-control" name="mandatory-{{ lang.pk }}"{% if lang.required %}
78+
<td><input type="checkbox" class="form-control" name="mandatory-{{ lang.pk }}"
79+
{% if lang.required %}
6980
checked{% endif %}></td>
7081
<td>
7182
<button type="submit" name="delete_asid" value="{{ lang.pk }}" class="btn btn-danger btn-sm"
@@ -87,7 +98,8 @@ <h4 class="mt-3">Translation</h4>
8798
</table>
8899
<div class="mt-3">
89100
<button type="submit" class="btn btn-primary">Save</button>
90-
<a href="{% tenant_url 'mooclink.course.overview' course_id=course.ext_id tenant=course.tenant %}" class="btn btn-secondary">Back</a>
101+
<a href="{% tenant_url 'mooclink.course.overview' course_id=course.ext_id tenant=course.tenant %}"
102+
class="btn btn-secondary">Back</a>
91103
</div>
92104
</form>
93105
</div>

pipeline/mooclink/templates/mooclink/partials/subtitle_actions.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@
2424
Publish
2525
</button>
2626
{% endif %}
27+
<button class="btn btn-outline-primary mr-1" type="submit" name="action" value="download_vtt">Download VTT</button>

pipeline/mooclink/templates/mooclink/partials/subtitle_legend.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
<div class="row">
2-
<div class="col-2">
3-
<h4>Legend</h4>
4-
51
<div class="row">
62
<div class="col-2">
73
<h4>Legend</h4>

0 commit comments

Comments
 (0)