Exemplo n.º 1
0
def init_db():
    sites = Site.objects()
    sites.delete()
    # Should probably add something for setting up the site
    title = raw_input("What are you naming this site?\n")
    domain = raw_input("What is the site's domain?\n")
    motto = raw_input("What is the site's motto? (optional)\n")
    logo = raw_input("What is the relative path to the logo?\n \
            ex: '/static/uploads/brainBadge.png' \n")

    site = Site(title=title, motto=motto, domain=domain, logo=logo)
    try:
        site.save()
    except:
        print "Sorry, something went wrong..."
        userreponse = raw_input("try again? [Y,n]")
        if userresponse == 'Y' or userresponse == 'y' or userresponse == '\n':
            init_db()
    depends = [
            {   'title' : u'Flask',
                'url'   : u'http://flask.pocoo.org/',
                'imgurl': u'http://flask.pocoo.org/static/logo.png',
                'authors': ['Armin Ronacher'],
                },
            {   'title' : u'jQuery',
                'url'   : u'http://jquery.com/',
                'imgurl':
                u'http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif',
                'authors': ['John Resig'],
                },
            ]
    for dep in depends:
        dependency =\
        Dependency(title=dep['title'],authors=dep['authors'],url=dep['url'],\
            imgurl=dep['imgurl'])
        try:
            dependency.save()
        except:
            flash("problem")
Exemplo n.º 2
0
def reset_db():
    try:
        posts = Post.objects()
        sites = Site.objects()
        users = User.objects()
        images = Image.objects()
        deps = Dependency.objects()
        flatpages = FlatPage.objects()

        posts.delete()
        sites.delete()
        users.delete()
        deps.delete()
        flatpages.delete()
        return "all images, posts, sites, and users deleted successfully!"
    except:
        print "There was an error..."