<commit_before>from saylua.models.role import Role
from saylua.utils import is_devserver
from saylua.modules.forums.models.db import Board, BoardCategory, ForumThread, ForumPost
from saylua.models.user import User
from saylua.modules.pets.soulnames import soulname

# To run this import setup in the interactive console and run it as such
# After that, edit a user's role to be admin to create the first admin
# Then, flush the memcache to make sure the user's role is updated
#
# from saylua.provisioner import setup
# setup()


def setup():
    # Create the role 'admin' with all privileges
    admin_role = Role(id='admin')
    admin_dict = admin_role.to_dict()
    for entry in admin_dict:
        setattr(admin_role, entry, True)
    admin_role.put()
    print('Admin Role Created')

    # Add the 'user' role
    user_role = Role(id='user')
    user_role.can_post_threads = True
    user_role.can_comment = True
    user_role.put()
    print('User Role Created')

    # Add the 'moderator' role
    moderator_role = Role(id='moderator')
    moderator_role.can_post_threads = True
    moderator_role.can_move_threads = True
    moderator_role.can_comment = True
    moderator_role.put()
    print('Moderator Role Created')

    #Add placeholders if on the dev server
    if is_devserver():
        print('Adding Placeholder Users')
        users = []
        for i in range(4):
            display_name = soulname(7)
            username = display_name
            #The following hash corresponds to the password 'password' so you can use that to test
            phash = '$2a$01$c1I8kCq3L1YgMDu4Hb.4COFJBWMqnjnZhyBvfaBPOOuVfPimvLAQq'
            email = username + '@' + username + '.biz'
            new_user = User(display_name=display_name, usernames=[username], phash=phash,
                email=email)
            users.append(new_user.put().id()) #Add users to database, and their IDs to a list

        print('Adding Placeholder Board Categories')
        categories = ['Saylua Talk', 'Help', 'Real Life', 'Your Pets']
        for category in categories:
            BoardCategory(title=category).put()

        print('Adding Placeholder Boards')


<commit_msg>Added boards to provisioner, still using old key format<commit_after>from saylua.models.role import Role
from saylua.utils import is_devserver
from saylua.modules.forums.models.db import Board, BoardCategory, ForumThread, ForumPost
from saylua.models.user import User
from saylua.modules.pets.soulnames import soulname

# To run this import setup in the interactive console and run it as such
# After that, edit a user's role to be admin to create the first admin
# Then, flush the memcache to make sure the user's role is updated
#
# from saylua.provisioner import setup
# setup()


def setup():
    # Create the role 'admin' with all privileges
    admin_role = Role(id='admin')
    admin_dict = admin_role.to_dict()
    for entry in admin_dict:
        setattr(admin_role, entry, True)
    admin_role.put()
    print('Admin Role Created')

    # Add the 'user' role
    user_role = Role(id='user')
    user_role.can_post_threads = True
    user_role.can_comment = True
    user_role.put()
    print('User Role Created')

    # Add the 'moderator' role
    moderator_role = Role(id='moderator')
    moderator_role.can_post_threads = True
    moderator_role.can_move_threads = True
    moderator_role.can_comment = True
    moderator_role.put()
    print('Moderator Role Created')

    #Add placeholders if on the dev server
    if is_devserver():
        print('Adding Placeholder Users')
        users = []
        for i in range(4):
            display_name = soulname(7)
            username = display_name
            #The following hash corresponds to the password 'password' so you can use that to test
            phash = '$2a$01$c1I8kCq3L1YgMDu4Hb.4COFJBWMqnjnZ<KEY>'
            email = username + '@' + username + '.biz'
            new_user = User(display_name=display_name, usernames=[username], phash=phash,
                email=email)
            users.append(new_user.put().id()) #Add users to database, and their IDs to a list

        print('Adding Placeholder Boards')
        categories = ['Saylua Talk', 'Help', 'Real Life', 'Your Pets']
        category_keys = []
        for category in categories:
            category_key = BoardCategory(title=category).put().urlsafe() #Keys currently in old form

            for n in range(4):
                title = soulname(7)
                url_title = title
                description = "A board for talking about " + title
                new_board = Board(title=title, url_title=url_title,
                        category_key=category_key, description=description)
                new_board.put()



{'fraction_non_alphanumeric': 0.08700231725300189, 'fraction_numerical': 0.005055824731409311, 'mean_word_length': 2.9046052631578947, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4188257', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1380, 'n_words': 432}