本文整理汇总了Python中blog.models.Comment.entry方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.entry方法的具体用法?Python Comment.entry怎么用?Python Comment.entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.models.Comment
的用法示例。
在下文中一共展示了Comment.entry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: blog_comment
# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import entry [as 别名]
def blog_comment(request, offset):
offset=int(offset)
e=Entries.objects.filter(id=offset)
if not request.POST['name']:
return HttpResponse(u'이름을 입력하세요')
cmt_name=request.POST['name']
cmt_content=request.POST['content']
if not request.POST['content']:
return HttpResponse(u'글 내용을 입력하세요')
cmt_password=request.POST['password']
if not request.POST['password']:
return HttpResponse(u'비밀번호를 입력하세요')
cmt_password = md5.md5(cmt_password).hexdigest()
cmt=Comment()
try:
cmt.name=cmt_name
cmt.password=cmt_password
cmt.text=cmt_content
ie=Entries.objects.get(id=request.POST['entry_id'])
cmt.entry=ie
ie.cnumber=ie.cnumber+1
ie.save()
cmt.save()
except:
return HttpResponse('오류가 나고 있습니다')
c=Comment.objects.filter(entry=Entries.objects.get(id=offset))
return render_to_response('blog.html',{'offset':offset,'e':e,'c':c})
示例2: entry_detail
# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import entry [as 别名]
def entry_detail(request, year, month, day, slug, draft=False):
date = datetime.date(*time.strptime(year+month+day, '%Y'+'%b'+'%d')[:3])
entry = get_object_or_404(Entry, slug=slug,
created_on__range=(
datetime.datetime.combine(date, datetime.time.min),
datetime.datetime.combine(date, datetime.time.max)
), is_draft=draft)
if request.method == 'POST' and entry.comments_allowed():
form = CommentForm(request.POST)
if form.is_valid():
comment = Comment(**form.cleaned_data)
comment.entry = entry
if request.META['REMOTE_ADDR'] != '':
comment.ip = request.META['REMOTE_ADDR']
else:
comment.ip = request.META['REMOTE_HOST']
comment.date = datetime.datetime.now()
comment.karma = 0
comment.spam = akismet(request, comment)
comment.save()
if (not comment.spam) and settings.BLOG_COMMENT_EMAIL:
comment_email = "%s\n--\n%s\n%s\n%s" % (comment.comment,
comment.name, comment.email, comment.website)
send_mail('[Blog] %s' % entry.title, comment_email,
comment.email, [entry.author.email], fail_silently=True)
return HttpResponseRedirect(entry.get_absolute_url())
else:
form = CommentForm()
return render_to_response('blog/entry_detail.html',
{'blog_title': settings.BLOG_TITLE, 'tags': Tag.objects.all(),
'object': entry, 'comment_form': form},
context_instance=RequestContext(request))
示例3: view_entry
# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import entry [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))