Exemple #1
0
def new_thread(request, forumSlug):

    try:
        forum = SubForum.objects.get(slug=forumSlug)

    except SubForum.DoesNotExist:
        raise Http404("Sub-forum doesn't exist.")

    if request.method == 'POST':
        form = ThreadForm(request.POST)

        if form.is_valid():

            title = form.cleaned_data['title']
            content = form.cleaned_data['content']

            theThread = Thread(sub_forum=forum,
                               user=request.user,
                               title=title,
                               slug='',
                               text=content)
            utilities.unique_slugify(theThread, title)
            theThread.save()

            return HttpResponseRedirect(theThread.get_url())

    else:
        form = ThreadForm()

    context = {'forumSlug': forumSlug, 'form': form}

    return render(request, 'new/new_thread.html', context)
Exemple #2
0
def post(request):
    #if not request.user.is_authenticated():
    #    return redirect('/login/')
    if request.method == 'GET':
        return render(request, 'post.html')
    elif request.method == 'POST':
        subforum = Subforum.objects.get(name = request.POST['course'])
        title = request.POST['title']
        content = request.POST['text']
        thread = Thread(poster = request.user, content = content, title = title, subforum = subforum)
        thread.save()
        return redirect(thread.get_url())
Exemple #3
0
def post(request):
    #if not request.user.is_authenticated():
    #    return redirect('/login/')
    if request.method == 'GET':
        return render(request, 'post.html')
    elif request.method == 'POST':
        subforum = Subforum.objects.get(name=request.POST['course'])
        title = request.POST['title']
        content = request.POST['text']
        thread = Thread(poster=request.user,
                        content=content,
                        title=title,
                        subforum=subforum)
        thread.save()
        return redirect(thread.get_url())