Skip to content
Browse files

Fix translation task creation.

* Ensure that deleted tasks don't block autocreation of new ones.
* Allow for autocreating only translate tasks, not transcribe tasks.

For https://unisubs.sifterapp.com/projects/12298/issues/590059/comments
  • Loading branch information...
1 parent 71c47a1 commit e3c0e138b0431fa9529e105cc19e88ed1647561a @sjl sjl committed
Showing with 23 additions and 12 deletions.
  1. +20 −10 apps/teams/models.py
  2. +3 −2 apps/teams/views.py
View
30 apps/teams/models.py
@@ -729,7 +729,7 @@ def _create_translation_tasks(team_video, subtitle_version):
# Don't create tasks for languages that already have one.
# Doesn't matter if it's complete or not.
- task_exists = Task.objects.filter(
+ task_exists = Task.objects.not_deleted().filter(
team=team_video.team, team_video=team_video, language=lang,
type=Task.TYPE_IDS['Translate']
).exists()
@@ -744,15 +744,25 @@ def _create_translation_tasks(team_video, subtitle_version):
def autocreate_tasks(team_video):
workflow = Workflow.get_for_team_video(team_video)
- if workflow.autocreate_subtitle:
- existing_subtitles = team_video.video.completed_subtitle_languages(public_only=True)
- if not existing_subtitles:
- Task(team=team_video.team, team_video=team_video,
- subtitle_version=None, language='',
- type=Task.TYPE_IDS['Subtitle']
- ).save()
- else:
- _create_translation_tasks(team_video, existing_subtitles[0].latest_version())
+ existing_subtitles = team_video.video.completed_subtitle_languages(public_only=True)
+
+ # We may need to create a transcribe task, if there are no existing subs.
+ if workflow.autocreate_subtitle and not existing_subtitles:
+ Task(team=team_video.team, team_video=team_video,
+ subtitle_version=None, language='',
+ type=Task.TYPE_IDS['Subtitle']
+ ).save()
+
+ # If there are existing subtitles, we may need to create translate tasks.
+ #
+ # TODO: This sets the "source version" for the translations to an arbitrary
+ # language's version. In practice this probably won't be a problem
+ # because most teams will transcribe one language and then send to a
+ # new team for translation, but we can probably be smarter about this
+ # if we spend some time.
+ if workflow.autocreate_translate and existing_subtitles:
+ _create_translation_tasks(team_video, existing_subtitles[0].latest_version())
+
def team_video_save(sender, instance, created, **kwargs):
"""Update the Solr index for this team video.
View
5 apps/teams/views.py
@@ -575,6 +575,7 @@ def move_video(request):
# We move the video by just switching the team, instead of deleting and
# recreating it.
team_video.team = team
+
# projects are always team dependent:
team_video.project = team.default_project
team_video.save()
@@ -600,8 +601,8 @@ def move_video(request):
if video.policy and video.policy.belongs_to_team:
video.policy.object_id = team.pk
- video.policy.save(updates_metadata=False)
-
+ video.policy.save(updates_metadata=False)
+
messages.success(request, _(u'The video has been moved to the new team.'))
else:
for e in flatten_errorlists(form.errors):

0 comments on commit e3c0e13

Please sign in to comment.
Something went wrong with that request. Please try again.