コード例 #1
0
 def handle(self, *args, **kwargs):
     print 'Run update_metadata command'
     targets = Video.objects.all()
     percent_printed = 0
     num = targets.count()
     count = 0
     print "%s videos to go " % num
     must_return = False
     for x in targets.iterator():
         try:
             update_metadata(x.pk)
             percent = (((count * 1.0) / num) * 100)
             count += 1
             if int(percent) > percent_printed:
                 percent_printed = int(percent)
                 print "Done %2s %%" % (percent_printed)
         except (KeyboardInterrupt, SystemExit):
             must_return = True
         except:
             print "failed for pk %s" % x.pk
             logger.exception("metadata import")
         if must_return:
             print "stopped at %s" % count
             return
         sleep(0.2)
コード例 #2
0
 def handle(self, *args, **kwargs):
     print 'Run update_metadata command'
     targets = Video.objects.all()
     percent_printed = 0
     num = targets.count()
     count = 0
     print "%s videos to go " % num
     must_return = False
     for x in targets.iterator():
         try:
             update_metadata(x.pk)
             percent =  (((count * 1.0) / num) * 100)
             count +=1          
             if int(percent) > percent_printed:
                 percent_printed = int(percent)
                 print "Done %2s %%" % (percent_printed)
         except (KeyboardInterrupt, SystemExit):
             must_return = True
         except:
             print "failed for pk %s"  % x.pk
             logger.exception("metadata import")
         if must_return:
             print "stopped at %s" % count
             return
         sleep(0.2)
コード例 #3
0
        def test_contribuitors_do_bypass_moderation(self):
            lang = self.video.subtitle_language()
            member, created = TeamMember.objects.get_or_create(user=self.user, team=self.team)
            member.role=TeamMember.ROLE_MANAGER
            member.save()
            add_moderation(self.video, self.team, self.user)
            joe_doe = User(username="******", password="******", email="*****@*****.**")
            joe_doe.save()
            joe_member, c = TeamMember.objects.get_or_create(user=joe_doe, team=self.team)
            joe_member.save()
            v0 = self._create_versions(lang, 1, user=joe_doe)[0]
            self.assertEquals(v0.moderation_status,WAITING_MODERATION)
            joe_member.promote_to_contributor()
            joe_doe = refresh_obj(joe_doe)

            self.assertTrue(self.team.is_contributor(joe_doe, authenticated=False))
            v1 = self._create_versions(lang, 1, user=joe_doe)[0]
            metadata_manager.update_metadata(self.video.pk)
            v1 = refresh_obj(v1)
            self.assertEquals(v1.moderation_status, APPROVED)
コード例 #4
0
ファイル: teams.py プロジェクト: appsembler/unisubs
    def test_complete_contents(self):
        request = RequestMockup(User.objects.all()[0])
        create_two_sub_session(request, completed=True)

        team, new_team_video = self._create_new_team_video()
        en = new_team_video.video.subtitle_language()
        en.is_complete = True
        en.save()
        video = Video.objects.get(id=en.video.id)
        self.assertEqual(True, video.is_complete)

        # We have to update the metadata here to make sure the video is marked
        # as complete for Solr.
        metadata_manager.update_metadata(video.pk)

        reset_solr()

        search_record_list = self._complete_search_record_list(team)
        self.assertEqual(1, len(search_record_list))
        search_record = search_record_list[0]
        self.assertEqual(1, len(search_record.video_completed_langs))
        self.assertEqual('en', search_record.video_completed_langs[0])