from django.core.management.base import BaseCommand
from datasets.models import *
import random


class Command(BaseCommand):
    help = 'Generates fake Dataset, Sound, Annotations and Votes data'

    def handle(self, *args, **options):

        # Create a fake dataset
        dataset, _ = Dataset.objects.get_or_create(
            name='A fake dataset',
            short_name='fsd',
            description='A textual description for the fake dataset',
        )

        # Create sounds and add them to dataset
        for i in range(0, 10):
            sound, _ = Sound.objects.get_or_create(
                name='Fake sound #{0}'.format(i),
                freesound_id=1234 + i,
            )
            SoundDataset.objects.get_or_create(
                dataset=dataset,
                sound=sound
            )

        # Create annotations
        possible_fake_annotations = ['label1', 'label2', 'label3', 'label4']
        for i in range(0, 20):
            sound_dataset = random.choice(list(SoundDataset.objects.all()))
            annotation, _ = Annotation.objects.get_or_create(
                sound_dataset=sound_dataset,
                type='AU',
                algorithm='Fake algorithm name',
                value=random.choice(possible_fake_annotations)
            )

        # Add votes for annotations
        possible_vote_options = [-1, 1]
        for i in range(0, 20):
            annotation = random.choice(list(Annotation.objects.all()))
            vote, _ = Vote.objects.get_or_create(
                annotation=annotation,
                vote=random.choice(possible_vote_options)
            )

@@ -538,19 +538,20 @@
 ge(0, 10
+0
 ):%0A
-
         
@@ -892,46 +892,255 @@
 = %5B'
-label1', 'label2', 'label3', 'label4'%5D
+/m/0z9c', '/m/07q2z82', '/m/0mkg', '/t/dd00093', '/m/042v_gx'%5D%0A        try:%0A            taxonomy = dataset.taxonomy%0A            possible_fake_annotations = %5Bnode%5B'id'%5D for node in dataset.taxonomy.get_all_nodes()%5D%0A        except:%0A            pass%0A
 %0A   
@@ -1154,33 +1154,34 @@
 r i in range(0, 
-2
+50
 0):%0A            
@@ -1607,17 +1607,19 @@
 ange(0, 
-2
+100
 0):%0A    

Generate fake data using taoxnomy