本文整理汇总了Python中models.comment.Comment.put方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.put方法的具体用法?Python Comment.put怎么用?Python Comment.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.comment.Comment
的用法示例。
在下文中一共展示了Comment.put方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import put [as 别名]
def post(self):
print 'Content-Type: text/plain'
print ''
video = Video.get_by_key_name('vid' + self.request.get('playerID'))
if not video:
video = Video.get_by_key_name(self.request.get('playerID'))
author = users.get_current_user()
if video:
text = unicode(self.request.get('message')).strip()
stime = float(self.request.get('playTime'))
mode = int(self.request.get('mode'))
fontsize = int(self.request.get('fontsize'))
color = int(self.request.get('color'))
cmt = Comment(author=author,
text=text,
stime=stime,
mode=mode,
fontsize=fontsize,
color=color,
cid=video)
if cmt:
cmt.put()
print 'OK'
else:
print 'Failed'
else:
print 'Failed'
示例2: post
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import put [as 别名]
def post(self):
"""Recieves comment message from user and stores in database"""
if self.authenticated():
post_id = self.request.get('post_id')
post = Post.get_by_id(int(post_id))
comment_txt = self.request.get('comments')
comment = Comment(comment = comment_txt, commenter = self.user, post = post)
comment.put()
self.redirect('/blog/%s' % (post_id))
else:
self.login_redirect()
示例3: post
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import put [as 别名]
def post(self, ticketId):
user = users.get_current_user()
if not user:
self.redirect('/')
comment = Comment()
ticket = TicketService.getById(ticketId)
comment.author = user
comment.ticket = ticket
comment.message = self.request.get('message')
comment.put()
self.redirect('/ticket/' + ticketId)
示例4: post
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import put [as 别名]
def post(self, submission_id, **kwargs):
'''
creates a new comment instance and inserts it into the db.
content is required to make a new comment
'''
content = self.request.get('content')
if content:
comment = Comment(user=self.user, content=content, **kwargs)
comment.put()
time.sleep(0.1)
self.redirect('/%s' % submission_id)
else:
error = 'You must enter content'
self.render('comments/new_comment.html', error=error, **kwargs)
示例5: post
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import put [as 别名]
def post(self, post_id):
if self.user:
content = self.request.get('content')
postid = int(post_id)
blog = Post.by_id(postid)
title = blog.subject
if content:
comment = Comment(title=title, content=content,
created_by=self.user.name, post_id=postid)
comment.put()
self.redirect('/comment')
else:
error = "We need some content for the comment"
self.render_front(title, content, error)
else:
self.redirect('/login')
示例6: post
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import put [as 别名]
def post(self, task_id):
# create new task (with parent)
task_key = ndb.Key(urlsafe=task_id)
# check if user is authed to reassign task
if not authed_for_task(task_key.get(), self.user_entity):
return self.abort(401)
# get user key
user_key = self.user_entity.key
# create new comment object
comment = Comment(parent=task_key)
# populate form with POST data
form = CommentForm(self.request.POST)
if form.validate():
# populate comment object with validated form data
form.populate_obj(comment)
# set reference properties on comment object
comment.task = task_key
comment.user = user_key
# store comment
comment.put()
# record history item
history_text = 'Comment added'
add_to_history(task_key.get(), self.user_entity, history_text)
# add a flash message to session
self.session.add_flash(history_text)
else:
# if form doesn't validate then add a flash message before redirecting
flash_msg = form.errors
self.session.add_flash(flash_msg)
# redirect to task view page
redirect_url = self.uri_for('task-view', task_id=task_key.urlsafe())
return self.redirect(redirect_url)
示例7: post
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import put [as 别名]
def post(self, id):
comment = Comment.get_by_id(int(id))
if(comment):
text = self.request.get("text")
if(text is not ""):
idea_key = Comment.idea.get_value_for_datastore(comment)
idea = Idea.get(idea_key)
reply = Comment(
idea = idea_key,
author = self.current_user.key(),
reply_to = comment.key(),
text = text,
)
reply.put()
idea.comments += 1
idea.put()
event = CommentReplyEvent(self.current_user, reply, comment)
values = {
"response" : "Reply sent",
"next":{
"content": "Back",
"url": "/idea/"+str(idea.key().id())
}
}
path = "feedback.html"
self.render(path, values)
else:
raise GetpitchdError("Comment text is empty")
else:
raise GetpitchdError("Comment does not exist.")
示例8: post
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import put [as 别名]
def post(self, id):
idea = Idea.get_by_id(int(id))
if(idea):
content = self.request.get("feedback")
if(content=="positive" or content=="negative"):
key_name = str(self.current_user.key().id()) + "_" + str(idea.key().id())
existing_feedback = Feedback.get_by_key_name(key_name)
if not existing_feedback:
feedback = Feedback(
key_name = key_name,
author = self.current_user.key(),
idea = idea.key(),
content = content,
)
feedback.put()
if(content == "positive"):
idea.positive += 1
else:
idea.negative += 1
text = self.request.get("text")
if text:
comment = Comment(
idea = idea.key(),
author = self.current_user.key(),
text = text,
)
comment.put()
idea.comments += 1
idea.put()
if text:
event = IdeaFeedbackEvent(self.current_user, feedback, idea, text)
else:
event = IdeaFeedbackEvent(self.current_user, feedback, idea)
if(content == "positive"):
author_key = Idea.author.get_value_for_datastore(idea)
author = User.get(author_key)
text = "I'm enthusiastic about a new startup idea pitched by @" + author.username + " on @gopitchme: " + idea.title
url = config.SITE_URL + "/idea/" + str(idea.key().id())
tweet = generate_tweet(text, url)
response = "Feedback sent"
call_to_action = "Why not tweeting this idea to your friends?"
values = {
"response": response,
"call_to_action": call_to_action,
"tweet": tweet,
"skip_url": "/idea/" + str(idea.key().id()),
}
path = "idea/tweet.html"
else:
values = {
"response": "Thanks for your feedback",
"next": {
"content": "Back",
"url": "/idea/"+str(idea.key().id()),
}
}
path = "feedback.html"
self.render(path, values)
else:
raise GetpitchdError("Feedback already sent")
else:
raise GetpitchdError("Forbidden feedback")
else:
raise GetpitchdError("Idea does not exist")