def test_needs_approval(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() # go through the review phase self.assertEquals(review_task.type, Task.TYPE_IDS['Review']) review_task.assignee = self.user review_task.approved = Task.APPROVED_IDS['Approved'] approve_task = review_task.complete() # now in the approval phase self.assertEquals(approve_task.type, Task.TYPE_IDS['Approve']) self.assertEquals( views.LanguageList(self.video).items, [ ('English', 'needs-review', ['original', 'needs approval' ], lang.get_absolute_url()), ])
def _create_review_or_approve_task(self, subtitle_version): team_video = subtitle_version.video.get_team_video() lang = subtitle_version.subtitle_language.language_code workflow = Workflow.get_for_team_video(team_video) if workflow.review_allowed: type = Task.TYPE_IDS['Review'] can_do = partial(can_review, allow_own=True) elif workflow.approve_allowed: type = Task.TYPE_IDS['Approve'] can_do = can_approve else: return None # TODO: Dedupe this and Task._find_previous_assignee # Find the assignee. # # For now, we'll assign the review/approval task to whomever did # it last time (if it was indeed done), but only if they're # still eligible to perform it now. last_task = team_video.task_set.complete().filter( language=lang, type=type).order_by('-completed')[:1] assignee = None if last_task: candidate = last_task[0].assignee if candidate and can_do(team_video, candidate, lang): assignee = candidate task = Task(team=team_video.team, team_video=team_video, assignee=assignee, language=lang, type=type) task.set_expiration() task.new_subtitle_version = subtitle_version if task.get_type_display() in ['Review', 'Approve']: task.new_review_base_version = subtitle_version task.save()
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)