示例#1
0
def generate():
    objects = []

    # create event, venue and location objects
    for i in range(1, COMPETITION_COUNT + 1):
        start_date = timezone.now().date() + timedelta(days=random.randint(1, 30))
        end_date = start_date + timedelta(days=random.randint(1, 60))
        objects.append({
            "model": "competition.Competition",
            "fields": {
                "title": "Competition %s Title" % i,
                "description": "Competition %s description with some added \
text to verify truncates where needed." % i,
                "content": "Competition %s Content" % i,
                "state": "published",
                "image": random.sample(IMAGES, 1)[0],
                "start_date": str(start_date),
                "end_date": str(end_date),
                "question": "Competition %s question?" % i,
                "question_blurb": "Competition %s question blurb." % i,
                "correct_answer": "Competition %s answer." % i,
                "rules": "Competition %s rules." % i,
                "sites": {
                    "model": "sites.Site",
                    "fields": {
                        "name": "example.com",
                    }
                },
            },
        })

    load_json(objects)
示例#2
0
def generate():
    objects = []

    # gen imagebanner objects
    for i in range(1, BANNER_COUNT + 1):
        objects.append({
            "model": "banner.ImageBanner",
            "fields": {
                "title": "Image Banner %s Title" % i,
                "state": "published",
                "image": random.sample(IMAGES, 1)[0],
                "url": "http://www.google.com",
                "sites": {
                    "model": "sites.Site",
                    "fields": {
                        "name": "example.com"
                    }
                },
            },
        })

    # gen codebanner objects
    for i in range(1, BANNER_COUNT + 1):
        objects.append({
            "model": "banner.CodeBanner",
            "fields": {
                "title": "Code Banner %s Title" % i,
                "state": "published",
                "image": random.sample(IMAGES, 1)[0],
                "code": "<strong>strong tag</strong>",
                "sites": {
                    "model": "sites.Site",
                    "fields": {
                        "name": "example.com"
                    }
                },
            },
        })

    load_json(objects)
示例#3
0
def generate():
    objects = []

    # gen post objects
    for i in range(1, POST_COUNT + 1):
        objects.append({
            "model": "post.Post",
            "fields": {
                "title": "Post %s Title" % i,
                "description": "Post %s description with some added text to verify truncates where needed." % i,
                "state": "published",
                "image": random.sample(IMAGES, 1)[0],
                "content": "<strong>strong</strong><i>italic</i>",
                "sites": {
                    "model": "sites.Site",
                    "fields": { 
                        "name": "example.com"
                    }
                },
            },
        })

    load_json(objects)
示例#4
0
def generate():
    objects = []
    
    # generate music preferences objects
    for i in range(0, CONTRIBUTOR_COUNT):
        contributor_role = CONTRIBUTOR_ROLE[i]
        objects.append({
            "model": "music.MusicCreditOption",
            "fields": {
                "role_priority": contributor_role[0],
                "role_name": contributor_role[1],
                "music_preferences": {
                    "model": "preferences.MusicPreferences",
                },
            },
        })

    # generate track credit objects
    for i in range(1, CREDIT_COUNT + 1):
        contributor_role = random.choice(CONTRIBUTOR_ROLE)
        objects.append({
            "model": "music.Credit",
            "fields": {
                "role": contributor_role[0],
                "track": {
                    "model": "music.Track",
                    "fields": {
                        "title": "Track %s Title" % i,
                        "description": "Track %s description with some added text to verify truncates where needed." % i,
                        "state": "published",
                        "image": random.sample(IMAGES, 1)[0],
                        "video_embed": "",
                        "sites": {
                            "model": "sites.Site",
                            "fields": { 
                                "name": "example.com"
                            }
                        },
                        "album": {
                            "model": "music.Album",
                            "fields": {
                                "title": "Album %s Title" % i,
                                "description": "Album %s description with some added text to verify truncates where needed." % i,
                                "state": "published",
                                "image": random.sample(IMAGES, 1)[0],
                                "sites": {
                                    "model": "sites.Site",
                                    "fields": { 
                                        "name": "example.com"
                                    }
                                },
                            },
                        },
                    },
                },
                "contributor": {
                    "model": "music.TrackContributor",
                    "fields": {
                        "title": "Track Contributor %s Title" % i,
                        "description": "Track Contributor %s description with some added text to verify truncates where needed." % i,
                        "state": "published",
                        "image": random.sample(IMAGES, 1)[0],
                        "sites": {
                            "model": "sites.Site",
                            "fields": { 
                                "name": "example.com"
                            }
                        },
                    },
                },
            },
        })
    
    load_json(objects)
示例#5
0
def generate():
    objects = []
    
    # create event, venue and location objects
    for i in range(1, EVENT_COUNT + 1):
        objects.append({
            "model": "event.Event",
            "fields": {
                "title": "Event %s Title" % i,
                "description": "Event %s description with some added text to verify truncates where needed." % i,
                "content": "Event %s Content" % i,
                "state": "published",
                "image": random.sample(IMAGES, 1)[0],
                "sites": {
                    "model": "sites.Site",
                    "fields": { 
                        "name": "example.com",
                    }
                },
                "venue": {
                    "model": "event.Venue",
                    "fields": { 
                        "name": "Venue %s Title" % i,
                        "address": "Venue %s Address" % i,
                        "location": {
                            "model": "event.Location",
                            "fields": {
                                "city": "City %s Title" % i,
                                "province": "%s" % random.choice(PROVINCES)[0],
                            }
                        },
                    }
                },
            },
        })
    
    # create some entries for events
    for i in range(0, EVENT_COUNT + 1):
        start_date = datetime.now() + timedelta(days=random.randint(1, 30))
        end_date = start_date + timedelta(hours=random.randint(1, 48))
        objects.append({
            "model": "cal.Entry",
            "fields": {
                "start": str(start_date),
                "end": str(end_date),
                "content": {
                    "model": "event.Event",
                    "fields": {
                        "title": "Event %s Title" % random.randint(1, EVENT_COUNT),
                    }
                },
                "calendars": {
                    "model": "cal.Calendar",
                    "fields": {
                        "title": "Calendar 2 Title",
                        "state": "published",
                        "image": random.sample(IMAGES, 1)[0],
                        "sites": {
                            "model": "sites.Site",
                            "fields": { 
                                "name": "example.com"
                            },
                        },
                    },
                },
            },
        })
    
    load_json(objects)
示例#6
0
def generate():
    objects = []

    # gen gallery objects
    for i in range(1, GALLERY_COUNT + 1):
        objects.append({
            "model": "gallery.Gallery",
            "fields": {
                "title": "Gallery %s Title" % i,
                "state": "published",
                "image": random.sample(IMAGES, 1)[0],
                "sites": {
                    "model": "sites.Site",
                    "fields": { 
                        "name": "example.com"
                    }
                },
            },
        })
    # gen gallery content
    for i in range(1, (GALLERY_COUNT * 3)):
        objects.append({
            "model": "gallery.GalleryImage",
            "fields": {
                "title": "Gallery Image %s Title" % i,
                "state": "published",
                "gallery": {
                    "model": "gallery.Gallery",
                    "fields": { 
                        "title": "Gallery %s Title" % (i / 3 + 1)
                    }
                },
                "image": random.sample(IMAGES, 1)[0],
                "sites": {
                    "model": "sites.Site",
                    "fields": { 
                        "name": "example.com"
                    }
                },
            },
        })
        objects.append({
            "model": "gallery.VideoEmbed",
            "fields": {
                "title": "Video Embed %s Title" % i,
                "embed": "<object width=&#39;480&#39; height=&#39;385&#39;><param name=&#39;movie&#39; value=&#39;http://www.youtube.com/v/VdgI0j1odkY&hl=en_US&fs=1&&#39;></param><param name=&#39;allowFullScreen&#39; value=&#39;true&#39;></param><param name=&#39;allowscriptaccess&#39; value=&#39;always&#39;></param><embed src=&#39;http://www.youtube.com/v/VdgI0j1odkY&hl=en_US&fs=1&&#39; type=&#39;application/x-shockwave-flash&#39; allowscriptaccess=&#39;always&#39; allowfullscreen=&#39;true&#39; width=&#39;480&#39; height=&#39;385&#39;></embed></object>",
                "state": "published",
                "gallery": {
                    "model": "gallery.Gallery",
                    "fields": { 
                        "title": "Gallery %s Title" % (i / 3 + 1)
                    }
                },
                "image": random.sample(IMAGES, 1)[0],
                "sites": {
                    "model": "sites.Site",
                    "fields": { 
                        "name": "example.com"
                    }
                },
            },
        })
        objects.append({
            "model": "gallery.VideoFile",
            "fields": {
                "title": "Video File %s Title" % i,
                "state": "published",
                "file": random.sample(VIDEOS, 1)[0],
                "gallery": {
                    "model": "gallery.Gallery",
                    "fields": { 
                        "title": "Gallery %s Title" % (i / 3 + 1)
                    }
                },
                "image": random.sample(IMAGES, 1)[0],
                "sites": {
                    "model": "sites.Site",
                    "fields": { 
                        "name": "example.com"
                    }
                },
            },
        })

    
    load_json(objects)
    
    # fix embed escaping
    from gallery.models import VideoEmbed
    for obj in VideoEmbed.objects.all():
        obj.embed = obj.embed.replace("&#39;", '"')
        obj.save()
示例#7
0
def generate():
    objects = []

    # create radio show objects and calendar entries
    for i in range(1, SHOW_COUNT + 1):
        # create show
        objects.append({
            "model": "show.RadioShow",
            "fields": {
                "title": "Radio Show %s Title" % i,
                "description": "Radio Show %s Description" % i,
                "content": "Radio Show %s Content" % i,
                "state": "published",
                "image": random.sample(IMAGES, 1)[0],
                "sites": {
                    "model": "sites.Site",
                    "fields": { 
                        "name": "example.com"
                    }
                },
            },
        })

    # create credit preferences
    for option in CREDIT_OPTIONS:
        objects.append({
            "model": "show.CreditOption",
            "fields": {
                "show_preferences": {
                    "model": "preferences.ShowPreferences",
                    "fields": {},
                },
                "role_name" : option[1],
                "role_priority": option[0],
            }
        })

    # create some show credits
    for i in range(1, CREDIT_COUNT + 1):
        # create show
        objects.append({
            "model": "show.Credit",
            "fields": {
                "role": random.randint(1, len(CREDIT_OPTIONS)),
                "contributor": {
                    "model": "show.ShowContributor",
                    "fields": {
                        "title": "Contributor %s Title" % i,
                        "state": "published",
                        "profile": "<strong>strong</strong><i>italic</i>",
                        "image": random.sample(IMAGES, 1)[0],
                        "owner": {
                            "model": "auth.user",
                            "fields": {
                                "username": "******" % i,
                            }
                        },
                        "sites": {
                            "model": "sites.Site",
                            "fields": { 
                                "name": "example.com"
                            }
                        },
                    }
                },
                "show": {
                    "model": "show.RadioShow",
                    "fields": {
                        "title": "Radio Show %s Title" % random.randint(1, SHOW_COUNT)
                    }
                },
            },
        })
                            
    # create some entries for shows
    for i in range(0, 24, 4):
        start_hour = i
        end_hour = 23 if i + 4 == 24 else i + 4
        objects.append({
            "model": "cal.Entry",
            "fields": {
                "start": str(datetime.now().replace(hour=start_hour, minute=0, second=0, microsecond=0)),
                "end": str(datetime.now().replace(hour=end_hour, minute=0, second=0, microsecond=0)),
                "content": {
                    "model": "show.RadioShow",
                    "fields": {
                        "title": "Radio Show %s Title" % random.randint(1, SHOW_COUNT),
                    }
                },
                "repeat": "daily",
                "repeat_until": str((datetime.now() + timedelta(days=30)).date()),
                "calendars": {
                    "model": "cal.Calendar",
                    "fields": {
                        "title": "Calendar 1 Title",
                        "state": "published",
                        "sites": {
                            "model": "sites.Site",
                            "fields": { 
                                "name": "example.com"
                            },
                        },
                    },
                },
            },
        })

    # create some content for each contributor
    for i in range(1, (CREDIT_COUNT*10) + 1):
        # create show
        objects.append({
            "model": "panya.ModelBase",
            "fields": {
                "title": "Content %s Title" % i,
                "description": "Content %s Title" % i,
                "state": "published",
                "image": random.sample(IMAGES, 1)[0],
                "owner": {
                    "model": "auth.user",
                    "fields": {
                        "username": "******" % ((i % CREDIT_COUNT) + 1),
                    }
                },
                "sites": {
                    "model": "sites.Site",
                    "fields": { 
                        "name": "example.com"
                    }
                },
            }
        })
    
    load_json(objects)
示例#8
0
def generate():
    objects = []
    
    # generate chart track objects
    for i in range(1, CREDIT_COUNT + 1):
        contributor_role = random.choice(CONTRIBUTOR_ROLE)
        objects.append({
            "model": "music.Credit",
            "fields": {
                "role": contributor_role[0],
                "track": {
                    "model": "music.Track",
                    "fields": {
                        "title": "Chart Track %s Title" % i,
                        "description": "Chart Track %s description with some added text to verify truncates where needed." % i,
                        "state": "published",
                        "image": random.sample(IMAGES, 1)[0],
                        "video_embed": "",
                        "sites": {
                            "model": "sites.Site",
                            "fields": { 
                                "name": "example.com"
                            }
                        },
                        "album": {
                            "model": "music.Album",
                            "fields": {
                                "title": "Chart Album %s Title" % i,
                                "description": "Chart Album %s description with some added text to verify truncates where needed." % i,
                                "state": "published",
                                "image": random.sample(IMAGES, 1)[0],
                                "sites": {
                                    "model": "sites.Site",
                                    "fields": { 
                                        "name": "example.com"
                                    }
                                },
                            },
                        },
                    },
                },
                "contributor": {
                    "model": "music.TrackContributor",
                    "fields": {
                        "title": "Chart Track Contributor %s Title" % i,
                        "description": "Chart Track Contributor %s description with some added text to verify truncates where needed." % i,
                        "state": "published",
                        "image": random.sample(IMAGES, 1)[0],
                        "sites": {
                            "model": "sites.Site",
                            "fields": { 
                                "name": "example.com"
                            }
                        },
                    },
                },
            },
        })
    
    # gen chart entry objects
    for i in range(1, CHART_ENTRY_COUNT + 1):
        
        objects.append({
            "model": "chart.ChartEntry",
            "fields": {
                "previous_position": random.randint(1, 40),
                "current_position": i,
                "next_position": random.randint(1, 40),
                "remove": False,
                "chart": {
                    "model": "chart.Chart",
                    "fields": {
                        "title": "Chart 1 Title",
                        "state": "published",
                        "image": random.sample(IMAGES, 1)[0],
                        "sites": {
                            "model": "sites.Site",
                            "fields": { 
                                "name": "example.com"
                            }
                        },
                    }
                },
                "track": {
                    "model": "music.Track",
                    "fields": {
                        "title": "Chart Track %s Title" % i,
                    }
                },
            },
        })
    
    # create chart options
    objects.append({
        "model": "preferences.ChartPreferences",
        "fields": {
            "primary_chart": {
                "model": "chart.Chart",
                "fields": {
                    "title": "Chart 1 Title",
                }
            },
        }
    })
    
    load_json(objects)