Пример #1
0
def make_approve_task(team_video, language_code, user):
    """Move a video through the tasks process to the approve stage, then return
    that task.

    assumptions:
        - there are no Tasks or SubtitleVersions for this video+language
        - approve is enabled for the team
    """
    team = team_video.team
    assert team.get_workflow().approve_allowed != 0
    task = Task(team=team, team_video=team_video, assignee=None,
         language=language_code, type=Task.TYPE_IDS['Translate'])
    task.save()
    v = pipeline.add_subtitles(team_video.video, language_code, None,
                               complete=False, visibility='private')
    task.assignee = user
    task.new_subtitle_version = v
    task = task.complete()
    if task.type == Task.TYPE_IDS['Review']:
        task.assignee = user
        task.approved = Task.APPROVED_IDS['Approved']
        return task.complete()
    else:
        # approve task
        return task
Пример #2
0
def _create_necessary_tasks(version, team_video, workflow, committer,
                            complete):
    """Create any necessary tasks for the newly added version.

    By the time we call this function we know that:

    * There are no existing open tasks for this version/language.
    * The committer cannot bypass moderation.

    So we may (or may not) need to create a task for this version/language.

    """
    from apps.teams.models import Task

    if complete:
        # If the subtitles are complete, then the new task will be either
        # a review or approve, depending on the team.
        if workflow.review_allowed:
            task_type = Task.TYPE_IDS['Review']
        elif workflow.approve_allowed:
            task_type = Task.TYPE_IDS['Approve']
        else:
            # Note that we may not have selected either of these, if the team
            # does not require review or approval.  That's okay, we're done in
            # that case.
            return
    else:
        # Otherwise the new task will be a subtitle or translate, depending
        # on the type of subs.
        # TODO: More advanced logic here?
        if version.subtitle_language.is_primary_audio_language():
            task_type = Task.TYPE_IDS['Subtitle']
        else:
            task_type = Task.TYPE_IDS['Translate']

    # We now know the type of task we need to create, so go ahead and make it.
    task = Task(team=team_video.team,
                team_video=team_video,
                language=version.language_code,
                type=task_type,
                new_subtitle_version=version)

    # Assign it to the correct user.
    if task.get_type_display() in ('Subtitle', 'Translate'):
        # If it's a subtitle/translate task, then someone just added
        # some incomplete subtitles.  We'll assign it to them by
        # default.
        task.assignee = committer
    else:
        # Otherwise it's a review/approve task, so we'll see if anyone
        # has reviewed or approved this before.  If so, assign it back
        # to them.  Otherwise just leave it unassigned.
        task.assignee = task._find_previous_assignee(task.get_type_display())

    task.save()
Пример #3
0
def make_review_task(team_video, language_code, user):
    """Move a video through the tasks process to the review stage, then return
    that task.

    assumptions:
        - there are no Tasks or SubtitleVersions for this video+language
        - review is enabled for the team
    """
    team = team_video.team
    task = Task(team=team, team_video=team_video, assignee=None,
         language=language_code, type=Task.TYPE_IDS['Translate'])
    task.save()
    v = pipeline.add_subtitles(team_video.video, language_code, None,
                               complete=False, visibility='private')
    task.assignee = user
    task.new_subtitle_version = v
    return task.complete()