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


Python Comment.content方法代码示例

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


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

示例1: handle

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import content [as 别名]
    def handle(self, *args, **options):
        print 'start'
        Comment.objects.all().delete()
        Post.objects.all().delete()
        Topic.objects.all().delete()
        t = Topic()
        t.name = 'Angular'
        t.save()
        for i in range(0,10):
            p = Post()
            p.topic = t
            p.title = 'First post %s' % i
            p.content = 'Content of the first post'
            p.save()

        t = Topic()
        t.name = 'Python'
        t.save()
        for i in range(0,20):
            p = Post()
            p.topic = t
            p.title = 'Second post %s ' % i
            p.content = 'Content of the second post'
            p.save()
            for i in range(0,20):
                c = Comment()
                c.author = 'Jim Morrison'
                c.content = ' #%s Very nice article. Thank you very much!!!' % i
                c.post = p
                c.save()

        
        print 'done'
开发者ID:zdimon,项目名称:angular,代码行数:35,代码来源:blog_load_data.py

示例2: view_entry

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import content [as 别名]
def view_entry(request, e_id):
    """ View Entry """
    entry = Entry.objects.get(id=e_id)
    entry.parsed_content = mark_safe(entry.content) #bbcode.render_html(entry.content) 
    msg = ''
    if(request.method == 'POST'):
        user_data= {'author': request.POST['author'] , 'email': request.POST['email'], 'message': request.POST['message'],'captcha': request.POST['captcha'] }

        #check captcha
        code = request.session['captcha_code']

        if(request.user.is_authenticated()):
            #user auth witrh external account
            user_data['author'] = '%s %s '%(request.user.first_name, request.user.last_name ) 
            
            if(request.session['backend'] == 'twitter'):
                user_data['author'] += '(@%s)'%(request.user.username)
            else:
                user_data['author'] +='(%s)'%(request.session['backend'])

            if(request.user.email == ''):
               user_data['email'] = '[email protected]'#request.user.email
            else:
               user_data['email'] = request.user.email
            logout(request)

        cf = CommentForm(user_data)
            
        if(cf.is_valid()):
            #Check Captcha
            if(''.join(code) == str.strip(str(request.POST['captcha'].upper()))):
                #save comment
                com = Comment()
                com.author = cf.cleaned_data['author']
                com.content = cf.cleaned_data['message']
                com.email = cf.cleaned_data['email']
                com.entry = entry
                try: 
                    com.save()
                    msg = 'Comment posted succesfully. Thanks.!'
                except:
                    msg = 'Error saving your comment. Please try again.' 
            else:
                msg = 'Wrong Captcha code. Please Try Again'
            
        else:
            msg = 'Error processing your comment. Please Try Again.'

        request.session['comment_posted_msg'] = msg
        return redirect('/blog/article/%s'%(e_id))#TODO put marker here to go to specific part of the html

    if('comment_posted_msg' in request.session):
        msg= request.session['comment_posted_msg']
        del request.session['comment_posted_msg']
    comments = entry.comment_set.filter(status=True)
    cf = CommentForm()

    t = get_template("entry.htm")
    c = RequestContext(request, {'entry': entry,'comments': comments, 'cform': cf, 'rn': random.randint(1,999999), 'msg': msg})
    return HttpResponse(t.render(c))
开发者ID:jeysonmc,项目名称:falsepixel,代码行数:62,代码来源:views.py

示例3: test_creating_a_new_comment_and_saving_it_to_the_database

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import content [as 别名]
 def test_creating_a_new_comment_and_saving_it_to_the_database(self):
     # start by create one Category and one post
     category = Category()
     category.name = "First"
     category.slug = "first"
     category.save()
     
     # create new post
     post = Post()
     post.category = category
     post.title = "First post"
     post.content = "Content"
     post.visable = True
     post.save()
     
     # create one comment
     comment = Comment()
     comment.name = "John"
     comment.content = "This is cool"
     comment.post = post
     
     # check save
     comment.save()
     
     # now check we can find it in the database
     all_comment_in_database = Comment.objects.all()
     self.assertEquals(len(all_comment_in_database), 1)
     only_comment_in_database = all_comment_in_database[0]
     self.assertEquals(only_comment_in_database, comment)
     
     # and check that it's saved its two attributes: name and content
     self.assertEquals(only_comment_in_database.name, comment.name)
     self.assertEquals(only_comment_in_database.content, comment.content)
开发者ID:pabllo87,项目名称:Ultra-simple-blog,代码行数:35,代码来源:models.py

示例4: leave_comment

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import content [as 别名]
def leave_comment(request,eid=None):
	if request.method == 'POST' and eid:
		uname=request.POST.get('uname',None)
		content=request.POST.get('comment',None)
		email=request.POST.get('email',None)
		#不为空   
		if uname and content and email:
			comment=Comment()
			comment.uname=uname
			comment.content=content
			comment.pub_date=datetime.datetime.now()
			comment.save()
		return index(request)
	return index(request)
开发者ID:rxlisbest,项目名称:roy,代码行数:16,代码来源:views.py

示例5: _upsert_comment

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import content [as 别名]
def _upsert_comment(comment):
    """
        操作类型:
            create:创建评论
            approve:通过评论
            spam:标记垃圾评论
            delete:删除评论
            delete-forever:彻底删除评论
    """
    action = comment.get('action', '')
    meta = comment.get('meta', None)
    if meta and isinstance(meta, dict):
        from blog.models import Article, Comment
        a_id = meta.get('thread_key')
        try:
            if action == 'create':
                try:
                    article = Article.objects.get(id=int(a_id))
                except (Article.DoesNotExist, TypeError, ValueError) as e:
                    print 'Article does not exist, ID: %s, error: %s' % (a_id, e)
                    return
                c = Comment()
                c.article = article
                parent_id = meta.get('parent_id', '0')
                parent_c = Comment.objects.filter(duoshuo_id=parent_id)
                c.parent = None if parent_id == '0' or parent_c.count() == 0 else parent_c[0]

                c.duoshuo_id = meta.get('post_id', '')
                c.duoshuo_user_id = comment.get('user_id', '')
                c.author = meta.get('author_name', '')
                c.author_email = meta.get('author_email', '')
                c.author_website = meta.get('author_url', '')
                c.author_ip = meta.get('ip', '')
                c.comment_date = timestamp2datetime(comment.get('date', None), convert_to_local=True) or datetime.datetime.now()
                c.content = _clean_content(meta.get('message', ''))
                c.author_agent = ''
                status = meta.get('status', '')
                c.status = COMMENT_STATUS.APPROVED if status == 'approved' else (COMMENT_STATUS.NOT_REVIEWED if status == 'pending' else COMMENT_STATUS.REJECTED)
                c.sync_status = 0
                c.save()
                print 'Create comment, article ID: %s, comment ID: %s' % (a_id, c.id)
            elif action == 'approve':
                Comment.objects.filter(duoshuo_id__in=meta).update(status=COMMENT_STATUS.APPROVED)
            elif action == 'spam':
                Comment.objects.filter(duoshuo_id__in=meta).update(status=COMMENT_STATUS.REJECTED)
            elif action in ('delete', 'delete-forever'):
                Comment.objects.filter(duoshuo_id__in=meta).update(hided=True, status=COMMENT_STATUS.REJECTED)
        except Exception, e:
            print 'update article comment failed, exception: %s, comment: %s' % (e, comment)
开发者ID:qiuzhangcheng,项目名称:GeekBlog,代码行数:51,代码来源:sync_views_and_comment_count.py

示例6: show

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import content [as 别名]
def show(request,uid=-1,aid=-1,*arg,**kwarg):
	uid=int(uid)
	userInfos=common.Users(request,uid)

	guestBlog=userInfos["guestblog"]
	try:
		myModules=guestBlog.modules.split(",")
	except:
		myModules = ''.split(',')
	moduleParams={}
	for myModule in myModules:
		moduleParams.setdefault(myModule,{"uid":uid})

	moduleList=modules.GetModuleList(moduleParams)
	

	articleInfo=Article.objects.get(id=aid)

	

	template = 'default'
	if request.POST.has_key('ok'):
		username = utility.GetPostData(request,'username')
		content = utility.GetPostData(request,'content')

		comment=Comment()
		comment.article=articleInfo
		comment.content=content
		comment.user_id=userInfos["currentuser"].id
		comment.username=username
		comment.createtime=datetime.datetime.now()
		comment.save()

		articleInfo.comments+=1

		if guestBlog:
			guestBlog=userInfos["guestblog"]
			guestBlog.comments+=1
			guestBlog.save()
			template = guestBlog.template

	commentList=Comment.objects.filter(article_id=aid)

	#更新文章浏览量
	articleInfo.views+=1
	articleInfo.save()

	return utility.my_render_to_response(request,"Skins/"+template+"/show.html",locals())
开发者ID:xf22001,项目名称:myblog,代码行数:50,代码来源:viewsarticle.py

示例7: leave_comment

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import content [as 别名]
def leave_comment(request,eid=None):
    if request.method == 'POST' and eid:
        uname=request.POST.get('uname',None)
        content=request.POST.get('comment',None)
        email=request.POST.get('email',None)
        essay=Essay.objects.get(id=eid)
        if uname and content and email and essay:
            comment=Comment()
            comment.uname=uname
            comment.content=content
            comment.email=email
            comment.essay=essay
            comment.pub_date=datetime.datetime.now()
            comment.save()
            return essay_details(request,eid)
        return index(request)
    
    return index(request)
开发者ID:abel-von,项目名称:django-blog,代码行数:20,代码来源:views.py

示例8: post_detail

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import content [as 别名]
def post_detail(request, post_id):
  context = RequestContext(request)
  if request.method == 'GET':
    try:
      post = Post.objects.get(pk=post_id)
    except Poll.DoesNotExist:
      raise Http404
    post_comment = Comment.objects.filter(post_id=post_id)
    return render_to_response('blog/post_detail.html', { 'post': post, 'post_comment': post_comment, 'post_id': post_id}, context)
  else:
    try:
      post = Post.objects.get(pk=post_id)
    except Poll.DoesNotExist:
      raise Http404
    comment = Comment()
    comment.content = request.POST['content']
    comment.user = request.user
    comment.post = post
    comment.save()
    return HttpResponseRedirect(reverse('post_detail', args=(post_id,)))
开发者ID:xwjiang,项目名称:myBlogSite,代码行数:22,代码来源:views.py

示例9: blog_show_comment

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import content [as 别名]
def blog_show_comment(request, blog_id):
    blog = Article.objects.get(pk=blog_id)
    if request.method == 'POST':
        name = request.POST['name']
        content = request.POST['content']
        print name, content
        try:
            new_comment = Comment()
            new_comment.article = blog
            new_comment.name = name
            new_comment.content = content
            new_comment.save()
            import datetime
            date = unicode(datetime.datetime.now())[0:-13]                     #TODO datatype优化
            date = u' ' + date
            content = unicode(escape(content))
            data_returned = {"name": name, "content": content, "date": date}
        except Exception, ex:
            print ex
            return HttpResponse("false")

        return JsonResponse(data_returned)
开发者ID:bricksfx,项目名称:django_self_blog,代码行数:24,代码来源:views.py

示例10: addcomment

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import content [as 别名]
def addcomment(request):
    postid = request.GET.get('id')
    id=request.POST['id']
    username=request.POST['username']
    email=request.POST['email']
    content=request.POST['content']
    psw=request.POST['psw']	
    t = loader.get_template("addcommentresult.html")
    if (psw=="123456" and username!="" and email!="" and content!=""):
		comment=Comment()
		comment.user=username
		comment.content=content
		comment.email=email
		post=Post.objects.get(id=postid)
		comment.ofpost=post
		comment.save()
		post.comment_times+=1
		post.save()
		result="评论添加成功"
			
    else:
        result="评论添加不成功 请联系站长"	
    c = Context({"username":username,"result":result,"postid":postid,"id":id})
    return HttpResponse(t.render(c))
开发者ID:wherego,项目名称:mydjangoblog,代码行数:26,代码来源:views.py

示例11: entry

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import content [as 别名]
def entry(request, blog_slug):
    """

    Defines the page of a single blog entry.
    Finds the entry based on its slugified title, passed in by blog_slug.
    """

    the_entry = get_object_or_404(Entry, slug=blog_slug)
    tags = Tag.objects_by_entry_count.all()
    comment_form = CommentForm()

    if request.method == "POST":
        new_comment = Comment()
        new_comment.content = request.POST["content"]
        new_comment.author = request.user
        new_comment.published = datetime.now()
        new_comment.associated_with = the_entry
        new_comment.save()

    return render(request, "individual_blog.html", {
        "entry": the_entry,
        "comment_form": comment_form,
        "tags": tags
    })
开发者ID:Ernir,项目名称:ernir.net,代码行数:26,代码来源:views.py


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