def submit_form(self, form, target): new_forum = Forum( name=form.cleaned_data['name'], slug=slugify(form.cleaned_data['name']), redirect=form.cleaned_data['redirect'], style=form.cleaned_data['style'], type='redirect', ) new_forum.set_description(form.cleaned_data['description']) new_forum.insert_at(form.cleaned_data['parent'], position='last-child', save=True) Forum.objects.populate_tree(True) if form.cleaned_data['perms']: new_forum.copy_permissions(form.cleaned_data['perms']) self.request.monitor['acl_version'] = int(self.request.monitor['acl_version']) + 1 return new_forum, Message(_('New Redirect has been created.'), 'success')
def submit_form(self, form, target): new_forum = Forum( name=form.cleaned_data['name'], slug=slugify(form.cleaned_data['name']), type='forum', attrs=form.cleaned_data['attrs'], show_details=form.cleaned_data['show_details'], style=form.cleaned_data['style'], closed=form.cleaned_data['closed'], prune_start=form.cleaned_data['prune_start'], prune_last=form.cleaned_data['prune_last'], ) new_forum.set_description(form.cleaned_data['description']) new_forum.insert_at(form.cleaned_data['parent'], position='last-child', save=True) Forum.objects.populate_tree(True) if form.cleaned_data['perms']: new_forum.copy_permissions(form.cleaned_data['perms']) self.request.monitor['acl_version'] = int(self.request.monitor['acl_version']) + 1 return new_forum, Message(_('New Forum has been created.'), 'success')
def submit_form(self, form, target): new_forum = Forum( name=form.cleaned_data['name'], slug=slugify(form.cleaned_data['name']), type=form.cleaned_data['role'], attrs=form.cleaned_data['attrs'], style=form.cleaned_data['style'], ) new_forum.set_description(form.cleaned_data['description']) if form.cleaned_data['role'] == 'redirect': new_forum.redirect = form.cleaned_data['redirect'] else: new_forum.closed = form.cleaned_data['closed'] new_forum.show_details = form.cleaned_data['show_details'] new_forum.insert_at(form.cleaned_data['parent'], position='last-child', save=True) Forum.objects.populate_tree(True) if form.cleaned_data['perms']: new_forum.copy_permissions(form.cleaned_data['perms']) self.request.monitor.increase('acl_version') self.request.session['forums_admin_preffs'] = { 'parent': form.cleaned_data['parent'].pk, 'perms': form.cleaned_data['perms'].pk if form.cleaned_data['perms'] else None, 'role': form.cleaned_data['role'], } if form.cleaned_data['role'] == 'category': return new_forum, Message(_('New Category has been created.'), 'success') if form.cleaned_data['role'] == 'forum': return new_forum, Message(_('New Forum has been created.'), 'success') if form.cleaned_data['role'] == 'redirect': return new_forum, Message(_('New Redirect has been created.'), 'success')
def load(): Forum(special='private_threads', name='private', slug='private', type='forum').insert_at(None, save=True) Forum(special='reports', name='reports', slug='reports', type='forum').insert_at(None, save=True) root = Forum(special='root', name='root', slug='root') root.insert_at(None, save=True) cat = Forum(type='category', name='First Category', slug='first-category') cat.insert_at(root, save=True) forum = Forum(type='forum', name='First Forum', slug='first-forum', threads=1, posts=1) forum.insert_at(cat, save=True) Forum(type='redirect', name='Project Homepage', slug='project-homepage', redirect='http://misago-project.org').insert_at(cat, position='last-child', save=True) Forum.objects.populate_tree(True) now = timezone.now() thread = Thread.objects.create( forum=forum, name='Welcome to Misago!', slug=slugify('Welcome to Misago!'), start=now, last=now, ) post = Post.objects.create( forum=forum, thread=thread, user_name='MisagoProject', ip='127.0.0.1', agent='', post='Welcome to Misago!', post_preparsed='Welcome to Misago!', date=now, ) thread.start_post = post thread.start_poster_name = 'MisagoProject' thread.start_poster_slug = 'misagoproject' thread.last_post = post thread.last_poster_name = 'MisagoProject' thread.last_poster_slug = 'misagoproject' thread.save(force_update=True) forum.last_thread = thread forum.last_thread_name = thread.name forum.last_thread_slug = thread.slug forum.last_thread_date = thread.last forum.last_poster = thread.last_poster forum.last_poster_name = thread.last_poster_name forum.last_poster_slug = thread.last_poster_slug forum.save(force_update=True) load_monitor_fixture(monitor_fixture)