示例#1
0
文件: views.py 项目: cundi/MixBBS
def fast_topic_reply(request, tid):
    topic = Topic.objects.get(id=tid)
    id_forum = Forum.objects.get(topic__id=tid)
    if request.method == 'GET':
        form = FastTopicReplyForm(
            initial={
                'Content': '<p style="color:red">RE:' + topic.content + '</p>'
            })
        ctx = {
            'form': form,
            'topic': topic,
        }
        return render(request, 'deepin/fast_topic_rp.html', ctx)
    if request.method == 'POST':
        form = FastTopicReplyForm(request.POST)
        if form.is_valid():
            post = Post()
            content = form.cleaned_data['Content']
            post.content = content
            post.author = request.user
            post.topic = topic
            post.save()
            topic.replied_time = post.created
            topic.reply_count += 1
            id_forum.post_count += 1
            id_forum.topic_count += 1
            id_forum.save()
            return HttpResponseRedirect(
                reverse('bb:topic_view', kwargs={'pk': topic.id}))
示例#2
0
文件: views.py 项目: cundi/MixBBS
def fast_topic_reply(request, tid):
    topic = Topic.objects.get(id=tid)
    id_forum = Forum.objects.get(topic__id=tid)
    if request.method == 'GET':
        form = FastTopicReplyForm(initial={'Content': '<p style="color:red">RE:'+ topic.content + '</p>'})
        ctx = {
            'form':form,
            'topic':topic,
        }
        return render(request, 'deepin/fast_topic_rp.html', ctx)
    if request.method == 'POST':
        form = FastTopicReplyForm(request.POST)
        if form.is_valid():
            post = Post()
            content = form.cleaned_data['Content']
            post.content = content
            post.author = request.user
            post.topic = topic
            post.save()
            topic.replied_time = post.created
            topic.reply_count += 1
            id_forum.post_count +=1
            id_forum.topic_count +=1
            id_forum.save()
            return HttpResponseRedirect(reverse('bb:topic_view', kwargs={'pk': topic.id}))
示例#3
0
文件: views.py 项目: cundi/MixBBS
def create_topic_reply(request, topic_id):
    if request.method == 'POST':
        topic = Topic.objects.get(id=topic_id)
        p = Post()
        # 回帖所属的那个帖子
        p.topic = topic
        p.content = request.POST['Content']
        p.author = request.user
        p.save()
        # 帖自被回复的时间就等于reply的创建时间
        topic.replied_time = p.created
        topic.post_count += 1
        topic.save()
        # 当前论坛的回帖总数
        forum.post_count += 1
        forum.save()
        return HttpResponseRedirect(
            reverse('bb:topic_view', kwargs={'pk': topic_id}))
    if request.method == 'GET':
        return render(request, 'deepin/topic_view.html')
示例#4
0
文件: views.py 项目: cundi/MixBBS
def create_topic_reply(request, topic_id):
    if request.method == 'POST':
        topic = Topic.objects.get(id=topic_id)
        p = Post()
        # 回帖所属的那个帖子
        p.topic = topic
        p.content = request.POST['Content']
        p.author = request.user
        p.save()
        # 帖自被回复的时间就等于reply的创建时间
        topic.replied_time = p.created
        topic.post_count += 1
        topic.save()
        # 当前论坛的回帖总数
        forum.post_count += 1
        forum.save()
        return HttpResponseRedirect(reverse('bb:topic_view', kwargs={'pk': topic_id}))
    if request.method == 'GET':
        return render(request, 'deepin/topic_view.html')