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


Python Comment.email方法代码示例

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


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

示例1: lire_article

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import email [as 别名]
def lire_article(request, slug):
    """
    Affiche un article complet, sélectionné en fonction du slug
    fourni en paramètre
    """
    article = get_object_or_404(Article, slug=slug)
    comments = Comment.objects.filter(article=article)
    
    if request.method == 'POST':
        form = CommentForm(request.POST)
        
        if form.is_valid():
            
            # ajouter la relation avec l'article
            comment = Comment()
            comment.pseudo = form.cleaned_data['pseudo']
            comment.email = form.cleaned_data['email']
            comment.contenu = form.cleaned_data['contenu']
            comment.article = article
            
            comment.save()
            
            renvoi = True 
    else:
            form = CommentForm()

    return render(request, 'blog/lire_article.html', locals())
开发者ID:VincentMardon,项目名称:django_blog,代码行数:29,代码来源:views.py

示例2: comment

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import email [as 别名]
def comment(request, id):
    """
    Add a comment to blog
    """
    if request.method == 'POST':
        form = CommentForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            comment = Comment()
            comment.comment = data['comment']
            comment.blog_id = id
            comment.user_name = data['user_name']
            comment.email = data['email']
            comment.source_address = request.META['REMOTE_ADDR']# '192.168.2.8'
            comment.create_date = datetime.datetime.now()
            comment.save()
            blog = Blog.objects.get(id=id)
            if blog.comment_count is None:
                blog.comment_count = 0
            blog.comment_count += 1
            blog.save()
            if request.user.is_authenticated():
                return HttpResponseRedirect('/adminshow/%s/' % id)
            else:
                return HttpResponseRedirect('/show/%s/' % id)
        else:
            blog = Blog.objects.get(id=id)
            comments = Comment.objects.filter(blog_id=id)
            return render_to_response('artical.html', {'blog' : blog, 'comments' : comments, 'form' : form}, context_instance=RequestContext(request, processors=[new_blog, blog_group]))
    else:
        return HttpResponseRedirect('/show/%s/' % id)
开发者ID:kelvinfang,项目名称:juncheefamily,代码行数:33,代码来源:views.py

示例3: view_entry

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import email [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

示例4: form

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import email [as 别名]
def form(request):
	if request.method=="POST":
		c=Comment()
		c.name=request.POST["name"]
		c.phone=request.POST["phone"]
		c.email=request.POST["email"]
		c.message=request.POST["message"]
		c.save()
		ht = "<html><body style = 'background-color: #2c3e50 ;color:white;font-size:64px ;text-align:center' >Thank you !!!  <a href='/'>Home</a></body></html>" 
    	return HttpResponse(ht)
	return HttpResponse("Error")
开发者ID:sanu11,项目名称:MySite,代码行数:13,代码来源:views.py

示例5: leave_comment

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import email [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

示例6: addcomment

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import email [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


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