Esempio n. 1
0
def index():
    categories = Category.get_all()
    user_count = Query(User).count()

    newest_user = Query(User).descending("created_at").first()
    return render_template("forum/index.html",
                           categories=categories,
                           user_count=user_count,
                           newest_user=newest_user)
Esempio n. 2
0
def create_test_data(users=5, categories=2, forums=2, topics=1, posts=1, create_settings=True):
    if create_settings:
        create_default_settings()
    # create 5 users
    for u in range(1, users + 1):
        username = "******" % u
        email = "*****@*****.**" % u
        user = User()
        user.set("username", username)
        user.set("password", "test")
        user.set("email", email)
        user.sign_up()

    # create 2 categories
    for i in range(1, categories + 1):
        category_title = "Test Category %s" % i
        category = Category(title=category_title,
                            description="Test Description")
        category.save()

        # create 2 forums in each category

    return "create success"