本文整理汇总了Python中forum.models.Post.creator方法的典型用法代码示例。如果您正苦于以下问题:Python Post.creator方法的具体用法?Python Post.creator怎么用?Python Post.creator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forum.models.Post
的用法示例。
在下文中一共展示了Post.creator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_reply
# 需要导入模块: from forum.models import Post [as 别名]
# 或者: from forum.models.Post import creator [as 别名]
def post_reply(request, topic_id):
form = PostForm()
topic = Topic.objects.get(pk=topic_id)
user = request.user
if topic.closed:
return render(request, 'personal/basic.html', {'content':['This topic is closed.']})
if topic.forum.closed and not user.has_perm('forum.can_post_lock_forum'):
return render(request, 'personal/basic.html', {'content':['This forum is locked.']})
if request.method == 'POST':
form = PostForm(request.POST)
if form.is_valid():
post = Post()
post.topic = topic
post.title = 'RE: '+topic.title
post.body = bleach_clean(form.cleaned_data['body'])
post.creator = request.user
post.user_ip = get_client_ip(request)
post.save()
return HttpResponseRedirect(reverse('topic-detail', args=(topic.id, topic.slug, )))
return render_to_response('forum/reply.html', {
'form': form,
'topic': topic,
'forum': topic.forum,
'editing': False,
}, context_instance=RequestContext(request))
示例2: post_reply
# 需要导入模块: from forum.models import Post [as 别名]
# 或者: from forum.models.Post import creator [as 别名]
def post_reply(request, topic_id):
form = PostForm()
topic = Topic.objects.get(pk=topic_id)
if request.method == 'POST':
form = PostForm(request.POST)
if form.is_valid():
post = Post()
post.topic = topic
post.title = form.cleaned_data['title']
post.body = form.cleaned_data['body']
post.creator = request.user
userToUpdate = UserProfile.objects.get(user=request.user)
nCredits = userToUpdate.credits
userToUpdate.credits = int(float(nCredits + 100))
# TODO: Change status (if points+100>threshold -> status changes) Alert???
# Alert? Maybe return to page with status update info for user.
# Make Gold/Platinum distinction
if nCredits + 100 >= GOLD_THRESHOLD:
newStatus = "Gold"
userToUpdate.status = newStatus
userToUpdate.save()
post.user_ip = request.META['REMOTE_ADDR']
post.save()
return render_to_response("forum/status_change.html", {'status': newStatus}, context_instance=RequestContext(request))
elif nCredits + 100 >= PLATINUM_THRESHOLD:
newStatus = "Platinum"
userToUpdate.status = newStatus
userToUpdate.save()
post.user_ip = request.META['REMOTE_ADDR']
post.save()
return render_to_response("forum/status_change.html", {'status': newStatus}, context_instance=RequestContext(request))
else:
userToUpdate.save()
post.user_ip = request.META['REMOTE_ADDR']
post.save()
return HttpResponseRedirect(reverse('topic-detail', args=(topic.id, )))
return render_to_response('forum/reply.html', {
'form': form,
'topic': topic,
}, context_instance=RequestContext(request))
示例3: post_reply
# 需要导入模块: from forum.models import Post [as 别名]
# 或者: from forum.models.Post import creator [as 别名]
def post_reply(request, topic_id):
form = PostForm()
topic = Topic.objects.get(pk=topic_id)
if request.method == 'POST':
form = PostForm(request.POST)
if form.is_valid():
post = Post()
post.topic = topic
post.title = form.cleaned_data['title']
post.body = form.cleaned_data['body']
post.creator = request.user
post.user_ip = request.META['REMOTE_ADDR']
post.save()
return HttpResponseRedirect(reverse('topic-detail', args=(topic.id, )))
return render_to_response('django_simple_forum/reply.html', {
'form': form,
'topic': topic,
}, context_instance=RequestContext(request))
示例4: new_topic
# 需要导入模块: from forum.models import Post [as 别名]
# 或者: from forum.models.Post import creator [as 别名]
def new_topic(request, forum_id):
form = TopicForm()
forum = get_object_or_404(Forum, pk=forum_id)
user = request.user
if forum.closed and not user.has_perm('forum.can_post_lock_forum'):
return render(request, 'personal/basic.html', {'content':['This forum is locked.']})
if request.method == 'POST':
form = TopicForm(request.POST)
if form.is_valid():
topic = Topic()
topic.title = form.cleaned_data['title']
topic.description = bleach_clean(form.cleaned_data['description'])
topic.forum = forum
topic.creator = user
topic.save()
tpkPost = Post()
tpkPost.topic = topic
tpkPost.title = topic.title
tpkPost.body = bleach_clean(form.cleaned_data['description'])
tpkPost.creator = user
tpkPost.user_ip = get_client_ip(request)
tpkPost.save()
return HttpResponseRedirect(reverse('topic-detail', args=(topic.id, topic.slug, )))
return render_to_response('forum/new-topic.html', {
'form': form,
'forum': forum,
}, context_instance=RequestContext(request))