Ejemplo n.º 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
Ejemplo n.º 2
0
 def test_sent_back(self):
     self.setup_team()
     # go through the subtitle task phase
     task = Task(team=self.team,
                 team_video=self.team_video,
                 language='en',
                 type=Task.TYPE_IDS['Subtitle'],
                 assignee=self.user)
     lang = self.add_completed_subtitles('en', [
         (0, 1000, "Hello, ", {
             'new_paragraph': True
         }),
         (1500, 2500, "World"),
     ],
                                         visibility='private')
     task.new_subtitle_version = lang.get_tip(public=False)
     review_task = task.complete()
     # have the video get sent back in the review phase
     self.assertEquals(review_task.type, Task.TYPE_IDS['Review'])
     review_task.assignee = self.user
     review_task.approved = Task.APPROVED_IDS['Rejected']
     new_subtitle_task = review_task.complete()
     # now in the approval phase
     self.assertEquals(new_subtitle_task.type, Task.TYPE_IDS['Subtitle'])
     self.assertEquals(
         views.LanguageList(self.video).items, [
             ('English', 'needs-review', ['original', 'needs editing'
                                          ], lang.get_absolute_url()),
         ])
Ejemplo n.º 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()
Ejemplo n.º 4
0
    def test_translation_tasks_not_blocked(self):
        # test that translation tasks are not blocked if the admin unpublishes
        # the version

        # make a translation task
        task = Task(team=self.team,
                    team_video=self.team_video,
                    assignee=self.user,
                    type=Task.TYPE_IDS['Translate'],
                    language='ru')
        task.save()
        # complete the translation task to create an approval task
        lang = self.make_dependent_language('ru', self.versions[-1])
        task.new_subtitle_version = lang.get_tip()
        approve_task = task.complete()
        # complete the parent subtitles language, so that that's not an issue
        # for is_blocked().
        self.language.subtitles_complete = True
        self.language.save()
        # unpublish the last version and check that that doesn't block the
        # approval task
        self.versions[-1].visibility_override = 'private'
        self.versions[-1].save()
        self.assertEquals(approve_task.is_blocked(), False)