当前位置: 首页>>代码示例>>Python>>正文


Python Post.user_ip方法代码示例

本文整理汇总了Python中forum.models.Post.user_ip方法的典型用法代码示例。如果您正苦于以下问题:Python Post.user_ip方法的具体用法?Python Post.user_ip怎么用?Python Post.user_ip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在forum.models.Post的用法示例。


在下文中一共展示了Post.user_ip方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post_reply

# 需要导入模块: from forum.models import Post [as 别名]
# 或者: from forum.models.Post import user_ip [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))
开发者ID:atirados,项目名称:CS425-Final-Project,代码行数:51,代码来源:views.py

示例2: post_reply

# 需要导入模块: from forum.models import Post [as 别名]
# 或者: from forum.models.Post import user_ip [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))
开发者ID:LunaSquee,项目名称:lunasqu.ee-django,代码行数:35,代码来源:views.py

示例3: post_reply

# 需要导入模块: from forum.models import Post [as 别名]
# 或者: from forum.models.Post import user_ip [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))
开发者ID:boyombo,项目名称:pharmrep,代码行数:26,代码来源:views.py

示例4: new_topic

# 需要导入模块: from forum.models import Post [as 别名]
# 或者: from forum.models.Post import user_ip [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))
开发者ID:LunaSquee,项目名称:lunasqu.ee-django,代码行数:38,代码来源:views.py


注:本文中的forum.models.Post.user_ip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。