當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。