本文整理汇总了Python中models.comment.Comment类的典型用法代码示例。如果您正苦于以下问题:Python Comment类的具体用法?Python Comment怎么用?Python Comment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Comment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: post_comment
def post_comment():
if request.method == "POST":
user_id = session.get("user_id")
comment = request.form.get("comment")
Comment.add_comment(g.db,user_id=user_id,user_comment=comment)
return redirect("/comment")
return redirect("/")
开发者ID:wangyu190810,项目名称:nedujob,代码行数:7,代码来源:comment.py
示例2: post
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'
开发者ID:ComMouse,项目名称:mukioplayer,代码行数:29,代码来源:main.py
示例3: PostModel
class PostModel(Model):
def __init__(self, db, collection, obj):
super(PostModel, self).__init__(db, collection, obj)
self.user = obj['user']
self.title = obj['title']
self.body = obj['body']
self.tags = obj['tags']
self.upvotes = obj['upvotes']
self.comments = Comment()
# Increases the upvotes on a post
def vote_up(self):
self.upvotes += 1
self.collection.objects.update({'_id': self.get_id()},
{'$inc': {'upvotes': 1}})
# Adds a comment on this post
def add_comment(self, **kwargs):
return self.comments.insert(post_id=self.get_id(), **kwargs)
# Gets comments on this post
def get_comments(self):
return self.comments.find(post_id=self.get_id())
# Use for removing comments by the user who created them, or by the poster
def remove_comments(self, **kwargs):
self.comments.remove(**kwargs)
# Removes self and the comments
def remove(self):
self.remove_comments(post_id=self.get_id())
super(PostModel, self).remove()
开发者ID:christi1001dx,项目名称:proj1-7,代码行数:33,代码来源:post.py
示例4: comment_request_impl
def comment_request_impl(args):
try:
author = user_from_token(args['token'])
post = post_from_id(author, args['post_id'])
comment = Comment(args['content'])
post.comments.append(comment)
author.comments.append(comment)
post.add_hot(5, None)
if args.has_key("picture") and args['picture'] is not None:
output = s3_upload(args['picture'])
url = 'https://{}.s3.amazonaws.com/{}'.format(os.environ['S3_BUCKET_NAME'], output)
comment.pic = url
db.session.commit()
#send notification to author
send_notification_for_user_commenting_on_post(device_token=post.user.device_token,
user_id=author.id,
user_pic=author.pic,
comment_id=comment.id,
nickname=author.nickname,
post_id=post.id,
platform=post.user.platform)
return Response(True, "Comment Succeded", CommentSchema().dumps(comment).data).output()
except Exception as exception:
return Response(False, str(exception), None).output()
开发者ID:rafagonc,项目名称:share,代码行数:26,代码来源:comment.py
示例5: comment
def comment(recipe_id=None):
if recipe_id != None and 'comment_text' in request.form and len(request.form['comment_text'].strip()) > 0:
Comment.create_comment(g.current_user, recipe_id, request.form['comment_text'].strip())
comment = Comment.load_last_comment(recipe_id)
return render_template('comment.html', comment=comment)
else:
return ''
开发者ID:teffland,项目名称:recipes,代码行数:7,代码来源:views.py
示例6: post
def post(self, content_id):
user = users.get_current_user()
comment = {
'nickname': user.nickname(),
'content_id': content_id,
'comment': self.request.get('comment')
}
Comment.create(comment)
self.redirect('/content/' + content_id + "?action=comment.post")
开发者ID:rcoronel-datalicious,项目名称:ph,代码行数:9,代码来源:content.py
示例7: test_add_and_get
def test_add_and_get(self):
uid0 = User.add("test1", "password", "[email protected]")
bid0 = Board.add("board1", "A")
lid0 = List.add("To Do", bid0)
caid0 = Card.add("card1", lid0, uid0)
coid0 = Comment.add(caid0, uid0, "comment1")
comment0 = Comment.get(coid0)
assert caid0 == comment0.card_id
assert uid0 == comment0.user_id
assert "comment1" == comment0.content
开发者ID:GuangzheGao,项目名称:sorbitol,代码行数:10,代码来源:test_comment.py
示例8: post
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()
开发者ID:harikrish00,项目名称:blogit,代码行数:11,代码来源:comment_post.py
示例9: post
def post(self):
uname = self.get_current_user()
user = User.get_user_by_name(uname)
if len(user)>0:
aid = self.get_argument("aid",None)
uid = user[0].uid
touname = self.get_argument("touname",None)
touid = User.get_user_by_name(touname)[0].uid
comment = self.get_argument("comment")
date = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
Comment.add_one_comment(aid,uid,touid,comment,date)
Article.add_one_ncomment(aid)
self.redirect("/article?aid="+str(aid)+"#comment-id")
else:
self.redirect("/login")
开发者ID:oujiaqi,项目名称:suiyue,代码行数:15,代码来源:article.py
示例10: __init__
def __init__(self, db, collection, obj):
super(UserModel, self).__init__(db, collection, obj)
self.username = obj['username']
self.password = obj['password']
self.voted = obj['voted']
self.posts = Post()
self.comments = Comment()
开发者ID:christi1001dx,项目名称:proj1-7,代码行数:7,代码来源:user.py
示例11: create
def create(parameters):
comment = Comment(Comment.cxn, "comments", parameters)
try:
comment.save()
attributes_to_render = comment.attributes
attributes_to_render.update({"id": comment.id})
template = open('./templates/comments/show.html').read()
attributes_to_render.update({"html": TemplateEngine(template, attributes_to_render).render_partial()})
return json.dumps(attributes_to_render)
except ValidationError as ve:
response = {"status": 422, "errors": ve.messages}
return json.dumps(response)
except Exception as e:
print(str(e))
response = {"status": 500, "errors": [str(e)]}
return json.dumps(response)
开发者ID:zackmdavis,项目名称:Wires,代码行数:16,代码来源:comments_controller.py
示例12: post
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)
开发者ID:tiffanyhan,项目名称:poetry-blog,代码行数:16,代码来源:comments.py
示例13: post
def post(self):
comment_id = self.request.get('comment_id')
comment_txt = self.request.get('comment')
comment = Comment.get_by_id(int(comment_id))
comment.comment = comment_txt
comment.put()
self.redirect('/blog/%s' % comment.post.key().id())
开发者ID:harikrish00,项目名称:blogit,代码行数:7,代码来源:edit_comment.py
示例14: saveComment
def saveComment(self):
results = {'result': False}
text = self.request.get('commentText')
pointRootUrlsafe = self.request.get('p')
parentCommentUrlsafe = self.request.get('parentKey')
user = self.current_user
if user:
try:
comment = Comment.create(
text, user, pointRootUrlsafe,
parentCommentUrlsafe)
if comment:
pst_date = PST.convert(comment.date)
results = {
'result': True,
'userName': user.name,
'userURL': user.url,
'avatar_url': user.avatar_url if hasattr(user, 'avatar_url') else '/static/img/icon_triceratops_black_47px.png',
'text': text,
'date': pst_date.strftime('%b. %d, %Y, %I:%M %p'),
'parentUrlsafe': parentCommentUrlsafe,
'myUrlSafe':comment.key.urlsafe(),
'level': comment.level
}
except WhysaurusException as e:
results['error'] = str(e)
resultJSON = json.dumps(results)
self.response.headers.add_header('content-type', 'application/json', charset='utf-8')
self.response.out.write(resultJSON)
开发者ID:aaronlifshin,项目名称:howtosavedemocaracy,代码行数:30,代码来源:comments.py
示例15: post
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')
开发者ID:pribala,项目名称:udacity_projects,代码行数:16,代码来源:main.py
示例16: get_comment
def get_comment(page=None):
if request.method == "GET":
comments = Comment.get_all_comment(g.db,status=1)
page_nums = get_page_nums(comments)
return render_template("comment.html",
comments= SqlalchemyOrmPage(comments,page=page,items_per_page=20),
page_nums = page_nums)
开发者ID:wangyu190810,项目名称:nedujob,代码行数:7,代码来源:comment.py
示例17: post
def post(self, comment_id):
comment = Comment.get_by_id(int(comment_id))
comment.content = self.request.get("content")
comment.updated = datetime.datetime.now()
comment.updated_by = users.get_current_user().nickname()
comment.put()
self.redirect("/topic/" + str(comment.the_topic_id))
开发者ID:KlemenGlobocnik,项目名称:forum,代码行数:8,代码来源:CommentHandlers.py
示例18: __init__
def __init__(self, db, collection, obj):
super(PostModel, self).__init__(db, collection, obj)
self.user = obj['user']
self.title = obj['title']
self.body = obj['body']
self.tags = obj['tags']
self.upvotes = obj['upvotes']
self.comments = Comment()
开发者ID:christi1001dx,项目名称:proj1-7,代码行数:8,代码来源:post.py
示例19: post
def post(self, slug=None):
try:
linkcheck = self.request.get_all('checks')
for key in linkcheck:
comment = Comment.get(key)
comment.delit()
finally:
self.redirect('/admin/comments')
开发者ID:oldhu,项目名称:micolog-oldhu,代码行数:8,代码来源:admin_comments.py
示例20: delete_post_comment
def delete_post_comment(comment_id):
comment = Comment.get_by_id(comment_id)
origin_post = comment.post.get()
origin_post.num_comments -= 1
origin_post.put()
#will now display [deleted] to keep comment chain intact
comment.partial_delete()
return origin_post.key.id()
开发者ID:Roasbeef,项目名称:FlaskrNews,代码行数:9,代码来源:api.py
注:本文中的models.comment.Comment类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论