Exemplo n.º 1
0
def _set_version_moderation_status(version, team, user, status, updates_meta=True):
    if not user_can_moderate(version.language.video, user):
        raise SuspiciousOperation("User cannot approve this version")    
    version.moderation_status = status
    version.save()
    if updates_meta:
        video_cache.invalidate_cache(version.video.video_id)
        _update_search_index(version.video)
    return version    
Exemplo n.º 2
0
    def delete(self, *args, **kwargs):
        video_id = self.video_id
        super(SubtitleLanguage, self).delete(*args, **kwargs)
        #asynchronous call
        update_team_video.delay(video_id)

        if not self.video.subtitlelanguage_set.exclude(is_complete=False).exists():
            self.video.complete_date = None
            self.video.save()
            
        video_cache.invalidate_cache(self.video.video_id)
        self.video.update_languages_count()            
Exemplo n.º 3
0
def add_moderation( video, team, user):
    """
    Adds moderation and approves all 
    """
    if video.moderated_by :
        raise AlreadyModeratedException("Video is already moderated")
    if not team.can_add_moderation(user) :       
        raise SuspiciousOperation("User cannot set this video as moderated")
    video.moderated_by = team
    video.save()
    SubtitleVersion.objects.filter(language__video__id = video.pk, moderation_status=UNMODERATED).update(moderation_status=APPROVED)
    video_cache.invalidate_cache(video.video_id)
    _update_search_index(video)
    return True
Exemplo n.º 4
0
 def test_cache_delete_valid_chars(self):
     # this tests depends on memcache being available
     try:
         from memcache.Client import MemcachedKeyCharacterError
     except ImportError:
         return
     request = RequestMockup(self.user_0)
     session = create_two_sub_session(request)
     video = session.video
     # make sure we have video on cache
     video_id =  video_cache.get_video_id(video.get_absolute_url(video.get_video_url()))
     self.assertEquals(video_id, video.video_id)
     self.assertTrue(bool(video_id))
     try:
         video_cache.invalidate_cache(video_id)
     except MemcachedKeyCharacterError:
         self.fail("Cache invalidation should not fail")
Exemplo n.º 5
0
def remove_moderation( video,  team, user):
    """
    Removes the moderation lock for that video, sets all the sub versions to
    approved , invalidates the cache and updates the search index.
    """
    if not video.moderated_by:
        return None
    if not team.can_remove_moderation( user) :       
        raise SuspiciousOperation("User cannot unset this video as moderated")
    for lang in video.subtitlelanguage_set.all():
        latest = lang.latest_version(public_only=False)
        if latest and latest.moderation_status == REJECTED:
            # rollback to the last moderated status
            latest_approved = lang.latest_version(public_only=Tue)
            v = latest_approved.rollback(user)
            v.save()
        
    num = SubtitleVersion.objects.filter(language__video=video).update(moderation_status=UNMODERATED)
    video.moderated_by = None;
    video.save()
    video_cache.invalidate_cache(video.video_id)
    _update_search_index(video)
    return num
Exemplo n.º 6
0
def video_delete_handler(sender, instance, **kwargs):
    video_cache.invalidate_cache(instance.video_id)
Exemplo n.º 7
0
def _invalidate_cache(video):
    from widget import video_cache
    video_cache.invalidate_cache(video.video_id)
Exemplo n.º 8
0
def subtile_language_delete_handler(sender, instance, **kwargs):
    video_cache.invalidate_cache(instance.video.video_id)
Exemplo n.º 9
0
def video_delete_handler(sender, instance, **kwargs):
    video_cache.invalidate_cache(instance.video_id)
Exemplo n.º 10
0
def subtile_language_delete_handler(sender, instance, **kwargs):
    video_cache.invalidate_cache(instance.video.video_id)
    instance.video.update_languages_count()
Exemplo n.º 11
0
def _invalidate_cache(video):
    from widget import video_cache
    video_cache.invalidate_cache(video.video_id)