Example #1
0
 def get_response(self, request, content):
     http_response = can_create_new_thread(request, content)
     if http_response:
         return http_response
     else:
         return HttpResponseRedirect(reverse('plugins.forum.views.create_new_thread',
                                             kwargs={'forum_slug': content.slug}))
Example #2
0
def create_new_thread(request, forum_slug):
    forum = get_object_or_404(Forum, slug=forum_slug)
    http_response = can_create_new_thread(request, forum)
    if http_response:
        return http_response
    if request.POST:
        form = CreateThreadForm(forum, request.POST)
        if form.is_valid():
            thread = form.save(commit=False)
            thread.slug = get_unique_slug(thread.name, forum.thread_set.all())
            thread.forum = forum
            thread.user = request.user
            thread.status = 'published'
            thread.save()
            workflow_status = thread.workflow_status.get_all_states().filter(slug='published')
            if workflow_status:
                thread.workflow_status = workflow_status[0]
                thread.save()
            return HttpResponseRedirect(thread.get_absolute_url())
    else:
        form = CreateThreadForm(forum)

    return render_to_response('forum/forum_create_thread.html', {
            'form': form, 'content': forum,
            }, context_instance=RequestContext(request))
Example #3
0
def create_new_thread(request, forum_slug):
    forum = get_object_or_404(Forum, slug=forum_slug)
    http_response = can_create_new_thread(request, forum)
    if http_response:
        return http_response
    if request.POST:
        form = CreateThreadForm(forum, request.POST)
        if form.is_valid():
            thread = form.save(commit=False)
            thread.slug = get_unique_slug(thread.name, forum.thread_set.all())
            thread.forum = forum
            thread.user = request.user
            thread.status = 'published'
            thread.save()
            workflow_status = thread.workflow_status.get_all_states().filter(
                slug='published')
            if workflow_status:
                thread.workflow_status = workflow_status[0]
                thread.save()
            return HttpResponseRedirect(thread.get_absolute_url())
    else:
        form = CreateThreadForm(forum)

    return render_to_response('forum/forum_create_thread.html', {
        'form': form,
        'content': forum,
    },
                              context_instance=RequestContext(request))
Example #4
0
 def get_response(self, request, content):
     http_response = can_create_new_thread(request, content)
     if http_response:
         return http_response
     else:
         return HttpResponseRedirect(
             reverse('plugins.forum.views.create_new_thread',
                     kwargs={'forum_slug': content.slug}))