def comment_delete(request): # 删除评论 # 判断当前用户是否有权限 comment_id = int(request.query['id']) # 只有评论用户和评论所属的微博的用户都能删除评论 Comment.delete(comment_id) return redirect('/weibo/index')
def comment_delete(): comment_id = int(request.args['id']) Comment.delete(comment_id) d = dict( message="成功删除 comment" ) return jsonify(d)
def destroy(self, id): comment = Comment().find(id) if comment.user().id == Auth.user().id: comment.delete() return RedirectResponse((comment.article().url()))
def delete_weibo_comment(self): # 删除微博的同时,删除微博下的所有评论 cs = self.comments() for c in cs: Comment.delete(c.id) # 前面几行也可以这么写:[Comment.delete(c.id) for c in self.comments()] Weibo.delete(self.id)
def delete(request): weibo_id = int(request.query['id']) Weibo.delete(weibo_id) cs = Comment.all(weibo_id=weibo_id) for c in cs: Comment.delete(c.id) return redirect('/weibo/index')
def comment_delete(request): comment_id = int(request.query['id']) Comment.delete(comment_id) d = dict( message="成功删除评论" ) return json_response(d)
def delete(): weibo_id = int(request.args['id']) Weibo.delete(weibo_id) comments = Comment.find_all(weibo_id=weibo_id) for c in comments: Comment.delete(c.id) d = dict(message="成功删除 weibo") return jsonify(d)
def delete(cls, weibo_id): w = Weibo.find_by(id=weibo_id) cs = Comment.find_all(weibo_id=w.id) log('weibo_delete', cs) for c in cs: Comment.delete(c.id) super().delete(weibo_id)
def delete(request): comment_id = int(request.query['id']) Comment.delete(id=comment_id) # 注意删除所有微博对应评论 # cs = Comment.all(weibo_id=weibo_id) # for c in cs: # c.delete(c.id) return redirect('/weibo/index')
def post(self, comment_id): user = users.get_current_user() comment = Comment.get_by_id(int(comment_id)) if users.is_current_user_admin() or user.email() == comment.user_email: Comment.delete(comment) return self.redirect_to("main-page")
def post(self, comment_id): comment = Comment.get_by_id(int(comment_id)) user = users.get_current_user() if comment.author_email == user.email() or users.is_current_user_admin(): Comment.delete(comment) self.redirect_to("topic-details", topic_id=comment.topic_id)
def delete(request): weibo_id = int(request.query['id']) Weibo.delete(weibo_id) comments = Comment.find_all(weibo_id=weibo_id) for i in range(len(comments)): Comment.delete(comments[i].id) d = dict(message="成功删除 weibo") return json_response(d)
def delete(request): weibo_id = int(request.query['id']) Weibo.delete(weibo_id) comments = Comment.find_all(weibo_id=weibo_id) for comment in comments: Comment.delete(comment.id) d = dict(status=210, message="成功删除 weibo") return json_response(d)
def comment_delete(request): comment_id = int(request.query['weibo_id']) Comment.delete(comment_id) d = dict( status=210, message="成功删除 weiboComment", ) return json_response(d)
def post(self, comment_id): comment = Comment.get_by_id(int(comment_id)) user = users.get_current_user() if comment.author_email == user.email() or users.is_current_user_admin( ): Comment.delete(comment) return self.write("Comment deleted successfully.")
def post(self, post_id, post): action = self.request.get("action") error_message = "" if action: if self.user_logged_in(): if self.user_owns_post(post): if action == 'like' or action == 'dislike': error_message = 'You cannot like your own post' else: if (action == 'like'): if Post.likedPost(post, self.user.key()): post.liked_user.append(self.user.key()) post.put() else: error_message = 'You can like only once' elif (action == 'dislike'): if Post.dislikedPost(post, self.user.key()): post.disliked_user.append(self.user.key()) post.put() else: error_message = 'You cand dislike only once' # Adding Comment if (action == 'Add Comment'): content = self.request.get("comment_content") comment = Comment(parent=blog_key(), content=content, author=self.user, post=post) comment.put() # Deleting Comments elif (action == 'Delete Comment'): comment_id = self.request.get("comment_id") key = db.Key.from_path('Comment', int(comment_id), parent=blog_key()) comment = db.get(key) if comment: if self.user_owns_comment(comment): comment.delete() else: error_message = "You can only delete your own comments" elif (action == "Edit Comment"): comment_id = self.request.get("comment_id") comment_content = self.request.get("comment_edit_content") key = db.Key.from_path('Comment', int(comment_id), parent=blog_key()) comment = db.get(key) if comment: if self.user_owns_comment(comment): comment.content = comment_content comment.put() else: error_message = "You can only edit your own comments" self.renderPage(post_id, post, error_message)
def delete(): weibo_id = int(request.args['id']) Weibo.delete(weibo_id) comments = Comment.all(id=weibo_id) # log('AAAA', comments) for comment in comments: # log('BBB', comment['id']) Comment.delete(comment.id) d = dict(message="成功删除 weibo") return jsonify(d)
def post(self, comment_id): """ soft delete for comments only by author or admin """ comment = Comment.get_by_id(int(comment_id)) user = User.logged_in_user() if User.is_admin(user) or User.is_author(user, comment): Comment.delete(comment) return self.redirect_to("topic-details", topic_id=comment.topic_id) else: return self.render_template("error.html", params={"message": COMMENT_AUTHOR})
def comment_delete(request): u = current_user(request) # 删除微博 comment_id = int(request.query.get('id', None)) c = Comment.find(comment_id) log('comment_delete 1', c.user_id) w = Weibo.find(c.weibo_id) log('comment_delete 2', w.user_id) if c.user_id == u.id or w.user_id == u.id: Comment.delete(comment_id) return redirect('/weibo/index')
def delete(request): weibo_id = int(request.query['id']) Weibo.delete(weibo_id) comment_id_list = Comment.find_all(weibo_id=weibo_id) for c in comment_id_list: Comment.delete(c.id) d = dict(message="成功删除 weibo和所属评论") return json_response(d)
def comment_delete(): u = current_user() comment_id = request.args.get('id', None) c = Comment.find(comment_id) b_user_id = request.args.get('b_id', None) a = (u.id == c.user_id) b = (u.id == b_user_id) blog = Blog.find_by(user_id=b_user_id) if a or b: Comment.delete(comment_id) return redirect(url_for('routes_blog.detail', blog_id=blog.id))
def delete(request): weibo_id = int(request.query['id']) Weibo.delete(weibo_id) comment = Comment.find_all(weibo_id=weibo_id) # 循环删除 for i in comment: Comment.delete(int(i.id)) d = dict(message="成功删除 weibo") return json_response(d)
def delete(): weibo_id = int(request.args.get('id')) item = Weibo.find(weibo_id) if same_user_required(item): t = Weibo.delete(weibo_id) comments = Comment.find_all(weibo_id=str(weibo_id)) for c in comments: Comment.delete(c.id) return jsonify(t.json()) else: pass
def delete(request): weibo_id = int(request.query['id']) Weibo.delete(weibo_id) comments = Comment.find_all(weibo_id=weibo_id) for c in comments: c_id = c.id Comment.delete(c_id) d = dict( message="成功删除 weibo" ) return json_response(d)
def weibo_delete(request): ''' 删除浏览器发送数据对应的 weibo 返回删除成功的信息 ''' weibo_id = int(request.query['id']) # 循环遍历该 weibo 所有评论,并删除 comments = Comment.all(weibo_id=weibo_id) for comment in comments: Comment.delete(comment.id) Weibo.delete(weibo_id) d = dict(message="成功删除 weibo") return json_response(d)
def comment_delete(request): # 获取comment id form = request.form() if 'cid' in request.query: c_id = request.query['cid'] elif 'cid' in form: c_id = form['cid'] else: return redirect('/weibo/index') # 根据comment id删除评论 Comment.delete(int(c_id)) return redirect('/weibo/index')
def comment_delete(request): u = current_user(request) nuser_id = int(u.id) # log('gaicuoti:', user_id) comment_id = int(request.query['id']) comments = Comment.one(id=comment_id) weibo_id = comments.weibo_id user_id = comments.user_id log('gaicuoti:', weibo_id, user_id) if nuser_id == user_id or nuser_id == weibo_id: Comment.delete(comment_id) return redirect('/weibo/index')
def delete_one_comment(comment_id): try: # deletes the comment Comment.delete().where(Comment.id == comment_id).execute() return jsonify( data={}, status={'code': 200, 'message': 'successfully deleted comment.'} ) # if the queried comment doesnt exist except DoesNotExist: return jsonify( data={}, status={'code': 404, 'message': 'Resource does not exist.'} )
def delete(): comment_id = int(request.args.get('id')) item = Comment.find(comment_id) if same_user_required(item): t = Comment.delete(comment_id) return jsonify(t.json()) else: pass
def post(self, topic_id, comment_id): is_admin = users.is_current_user_admin() logged_user = users.get_current_user() comment = Comment.get_by_id(int(comment_id)) is_author = comment.author_email == logged_user.email() if is_admin or is_author: Comment.delete(comment_id) else: return self.write('You cannot delete other users comments.') flash = { 'flash_message': 'Comment deleted successfully', 'flash_class': 'alert-warning', } return self.redirect_to('topic-details', topic_id=topic_id, **flash)