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


Python Comment.user方法代码示例

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


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

示例1: submit_comment_view

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import user [as 别名]
def submit_comment_view(request):
    try:
        if request.method == 'GET':
            paper_id = int(request.GET['id'])
        elif request.method == 'POST':
            paper_id = int(request.POST['id'])
        paper = Paper.objects.filter(id=paper_id).get()
        comment = Comment()
        comment.paper = paper
        comment.user = request.user
        if request.method == 'POST':
            form = forms.SubmitCommentForm(request.POST, instance=comment)
            if form.is_valid():
                form.save(paper)
                return HttpResponseRedirect("paper?id=%d" % paper_id)
        else:
            form = forms.SubmitCommentForm()
    except (ValueError, KeyError, Paper.DoesNotExist):
        paper = None
        form = None

    return render_to_response("submit_comment.html", RequestContext(request, {
        'form' : form,
        'paper' : paper,
    }))
开发者ID:labdalla,项目名称:jeeves,代码行数:27,代码来源:views.py

示例2: submit_comment_view

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import user [as 别名]
def submit_comment_view(request):
    import forms
    user = UserProfile.objects.get(username=request.user.username)

    try:
        if request.method == 'GET':
            paper_id = int(request.GET['id'])
        elif request.method == 'POST':
            paper_id = int(request.POST['id'])
        paper = Paper.objects.filter(id=paper_id).get()
        comment = Comment()
        comment.paper = paper
        comment.user = user
        if request.method == 'POST':
            form = forms.SubmitCommentForm(request.POST, instance=comment)
            if form.is_valid():
                form.save(paper)
                return HttpResponseRedirect("paper?id=%s" % paper_id)
        else:
            form = forms.SubmitCommentForm()
    except (ValueError, KeyError, Paper.DoesNotExist):
        paper = None
        form = None

    return render(request, "submit_comment.html", {
        'form' : form,
        'paper' : paper,
        'which_page' : "submit_comment"
    })
开发者ID:jeanqasaur,项目名称:jeeves,代码行数:31,代码来源:views.py

示例3: new_comment

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import user [as 别名]
def new_comment(request,idnum):
	try:
		post = request.POST
		sentiment = post["sentiment"]	
		title = post["comment_title"]
		text = post["comment_text"]
		all = post["images"]
		images = map(int,post["images"].split("_")) if all else []
		venue = Venue.objects.get(id=idnum)
		if sentiment and title and text:
			comment = Comment()
			comment.set_sentiment_by_index(int(sentiment))
			comment.title = title
			comment.text = text
			comment.venue = venue
			comment.user = request.user
			comment.save()
			for id in images:
				image = VenueImage.objects.get(id=id)
				image.comment = comment
				image.save()
		else:
			raise Exception("invalid post content")
	except Exception, e:
		pass
开发者ID:michaelgiba,项目名称:JustOpenedDjango,代码行数:27,代码来源:views.py

示例4: detail

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import user [as 别名]
def detail(request, post_id):
    """

    :param request:
    :param post_id:
    :return:
    """
    post = get_object_or_404(Post, pk=post_id)
    parents = post.item.all()
    content = ContentType.objects.get_for_model(Comment)
    subs = Comment.objects.filter(content_type=content).filter(is_active=1).filter(parent=post_id)
    if request.method == "POST":
        form = CommentForm(request.POST)
        if form.is_valid():
            text = form.cleaned_data["text"]
            email = form.cleaned_data["email"]
            c_type = request.POST.get("c_type")
            obj_id = request.POST.get("replyfor")

            if c_type == "Comment":
                c_model = Comment

            if c_type == "Post":
                c_model = Post

            con_type = ContentType.objects.get_for_model(c_model)
            new_comment = Comment(email=email,
                                  text=text,
                                  content_type=con_type,
                                  parent=post_id,
                                  object_id=obj_id,
                                  pubdate=datetime.now(),
                                  is_active=0)
            new_comment.save()

            if request.user.is_authenticated():
                new_comment.is_active = 1
                new_comment.user = request.user
                new_comment.save()
            else:

                if email_check(email):
                    return redirect('/')
                else:
                    act_code = produce_val()
                    send_act_code.delay(act_code,
                                        new_comment.email)
                    new_activation = Activation(conf_code=act_code,
                                                comment=new_comment,
                                                exp_date=datetime.now(), )
                    new_activation.save()
        form = CommentForm()
    else:
        form = CommentForm()

    return render(request, 'blog/deneme.html', {'parents': parents,
                                                'subs': subs, 'post': post,
                                                'r_user': request.user,
                                                'form': form, })
开发者ID:gokhanciplak,项目名称:deneme,代码行数:61,代码来源:views.py

示例5: comment

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import user [as 别名]
def comment(todo_id):
    comment_user = current_user()
    form = request.form
    one_comment = Comment(form)
    one_comment.user = comment_user
    one_comment.todolist = TodoList.query.filter_by(id=todo_id).first()
    #有外键记得把每个外键连上
    one_comment.save()
    return redirect(url_for('comment_view', todo_id = todo_id))
开发者ID:Subwin,项目名称:todolist,代码行数:11,代码来源:app.py

示例6: comment_add

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import user [as 别名]
def comment_add():
    user = current_user()
    if user is None:
        return redirect(url_for('login_view'))
    else:
        c = Comment(request.form)
        c.user = user
        c.save()
        # log('comment-post by form:', c.post)
        return redirect(url_for('post_view', post_id=c.post_id))
开发者ID:eason-lee,项目名称:Forum-Gua,代码行数:12,代码来源:app.py

示例7: view_post

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import user [as 别名]
def view_post(id):
    form = request.forms
    if form.update_comment :
        post = Post.get(id=id)
        comment = Comment()
        comment.post = post # current post
        comment.user = User.get(username=form.username)
        comment.content = form.content
        comment.pub_date = datetime.now()
        comment.save()
        redirect('/view/post/%d' %(id,))
    else :
        post = Post.get(id=id)
        comments = Comment.filter(post__id = id)
        return template('templates/post.html.tpl',post=post,comments=comments)
开发者ID:josuebrunel,项目名称:bottleblog,代码行数:17,代码来源:blog.py

示例8: comment_add

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import user [as 别名]
def comment_add():
    j = request.get_json()
    c = Comment(j)
    log('comment request.get_json():', j)
    c.user = current_user()
    c.save()
    comment = c.comment_row()
    log('新增Comment:', c)
    log('comment add, dict: ', comment)
    t = comment.get('time', '')
    ft = from_now(t)
    response_data = {
        'id': comment.get('id', ''),
        'user_link': comment.get('user_link', ''),
        'time': ft,
        'content': comment.get('content', ''),
    }
    return json.dumps(response_data, indent=2)
开发者ID:RachelQ1103,项目名称:Forum-Gua,代码行数:20,代码来源:app.py


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