class SectionForm(wt.Form): title = wt.StringField(validators=(wt.validators.required(), )) forum = wt.SelectField(choices=[(forum.id, forum.title) for forum in Forum.all()], coerce=int) # TODO(a.telishev): Section relates from forum parent = wt.SelectField(choices=[(section.id, section.title) for section in Section.all()], coerce=int)
for subsection_title in section_data['subsections']: Section.create( **{ 'forum': forum.id, 'parent': section.id, 'title': subsection_title, 'created_at': datetime.datetime.now(), 'created_by': admin.id, }) # Create threads print('Create threads...') current_threads_count = Thread.count() if current_threads_count < THREADS_COUNT: forums = Forum.all() users = User.all() for i in range(THREADS_COUNT - current_threads_count): if i and (i % 100000 == 0): print(f' - Created {i} threads') user = random.choice(users) forum = random.choice(forums) section = random.choice(Section.filter(forum=forum.id)) ThreadFactory.create( author_id=user.id, forum_id=forum.id, section_id=section.id, )
def __init__(self, category): self.forums = [] forums = Forum.all().filter('category =',category).order('-datetime').fetch(10, offset=0) for forum in forums: self.forums.append(ForumViewModel(forum))