コード例 #1
0
ファイル: models.py プロジェクト: darad/freesound
def on_delete_sound(sender,instance, **kwargs):
    if instance.moderation_state == "OK" and instance.processing_state == "OK":
        try:
            DeletedSound.objects.get_or_create(sound_id=instance.id, user=instance.user)
        except User.DoesNotExist:
            deleted_user = User.objects.get(id=settings.DELETED_USER_ID)
            DeletedSound.objects.get_or_create(sound_id=instance.id, user=deleted_user)
        
    try:            
        if instance.geotag:
            instance.geotag.delete()
    except:
        pass
    if instance.pack:
        instance.pack.process()
    
    delete_sound_from_solr(instance)
    delete_object_files(instance, web_logger)
    if instance.similarity_state=='OK':
	try:
    		if Similarity.contains(instance.id):
        		Similarity.delete(instance.id)
	except:
		web_logger.warn("ommitting similarity deletion for deleted sound %d"%instance.id)
		
    web_logger.debug("Deleted sound with id %i"%instance.id)
コード例 #2
0
def on_delete_sound(sender, instance, **kwargs):
    if instance.moderation_state == "OK" and instance.processing_state == "OK":
        try:
            DeletedSound.objects.get_or_create(sound_id=instance.id,
                                               user=instance.user)
        except User.DoesNotExist:
            deleted_user = User.objects.get(id=settings.DELETED_USER_ID)
            DeletedSound.objects.get_or_create(sound_id=instance.id,
                                               user=deleted_user)

    try:
        if instance.geotag:
            instance.geotag.delete()
    except:
        pass
    if instance.pack:
        instance.pack.process()

    delete_sound_from_solr(instance)
    delete_object_files(instance, web_logger)
    if instance.similarity_state == 'OK':
        try:
            if Similarity.contains(instance.id):
                Similarity.delete(instance.id)
        except:
            web_logger.warn(
                "ommitting similarity deletion for deleted sound %d" %
                instance.id)

    web_logger.debug("Deleted sound with id %i" % instance.id)
コード例 #3
0
ファイル: models.py プロジェクト: djzikario/freesound
def on_delete_sound(sender,instance, **kwargs):
    if instance.moderation_state == "OK" and instance.processing_state == "OK":
        try:
            DeletedSound.objects.get_or_create(sound_id=instance.id, user=instance.user)
        except User.DoesNotExist:
            deleted_user = User.objects.get(id=settings.DELETED_USER_ID)
            DeletedSound.objects.get_or_create(sound_id=instance.id, user=deleted_user)
        
    try:            
        if instance.geotag:
            instance.geotag.delete()
    except:
        pass
    if instance.pack:
        instance.pack.process()
    
    delete_sound_from_solr(instance)
    delete_object_files(instance, web_logger)
    # N.B. be watchful of errors that might be thrown if the sound is not in the similarity index
    if Similarity.contains(instance.id):
        Similarity.delete(instance.id)
    web_logger.debug("Deleted sound with id %i"%instance.id)