本文整理汇总了Python中app.models.Comment.text方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.text方法的具体用法?Python Comment.text怎么用?Python Comment.text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.models.Comment
的用法示例。
在下文中一共展示了Comment.text方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: comment_add
# 需要导入模块: from app.models import Comment [as 别名]
# 或者: from app.models.Comment import text [as 别名]
def comment_add(order_id):
text = request.form['text']
c = Comment()
o = Order.get(order_id)
if not o:
abort(404)
c.text = text
c.order_id = order_id
c.user_login = current_user.login
c.save()
if current_user.is_admin:
return redirect(url_for('admin_order', order_id=order_id))
return redirect(url_for('order', order_id=order_id))
示例2: add_quote
# 需要导入模块: from app.models import Comment [as 别名]
# 或者: from app.models.Comment import text [as 别名]
def add_quote(request):
if request.method == 'POST':
print request.POST
post_quote = ''
post_comment = ''
post_author = ''
quote_form = QuoteForm(request.POST.copy(), prefix='quote')
if quote_form.is_valid():
cd = quote_form.cleaned_data
post_quote = cd['quote']
post_comment = cd['comment']
post_author = cd['author']
quote = Quote()
if post_comment:
print 'post_comment',post_comment
comment = Comment()
comment.text = post_comment
comment.save()
quote.comment = comment
author, created = Author.objects.get_or_create(name__iexact=post_author)
if post_author:
author.name = post_author
else:
author.name = 'Anonymous'
author.save()
quote.author = author
quote.quote = post_quote
quote.save()
else:
print "Quote_form is not valid!"
data = {
'quote_text': post_quote,
'quote_comment': post_comment,
'quote_author': post_author,
}
return HttpResponse(simplejson.dumps(data))
raise Http404
示例3: manage_comment
# 需要导入模块: from app.models import Comment [as 别名]
# 或者: from app.models.Comment import text [as 别名]
def manage_comment(request):
if request.method == 'GET':
if request.GET['action'] == 'delete':
comment = Comment.objects.get(pk=request.GET['comment_id'])
comment.delete()
elif request.GET['action'] == 'edit':
comment = Comment.objects.get(pk=request.GET['comment_id'])
comment.text = request.GET['edited_text']
comment.save()
elif request.GET['action'] == 'add':
comment = Comment()
comment.text = request.GET['text']
comment.user = request.user
comment.post = Post.objects.get(pk=request.GET['post_id'])
comment.save()
resp = serialize('json', [comment, ])
resp_obj = json.loads(resp)
resp_obj[0]['fields']['first_name'] = request.user.first_name
resp_obj[0]['fields']['last_name'] = request.user.last_name
resp_obj[0]['fields']['username'] = request.user.username
return HttpResponse(json.dumps(resp_obj))
return HttpResponse()