コード例 #1
0
ファイル: routes_weibo.py プロジェクト: COPPERHAMMER/MVC-web
def comment_delete(request):
    # 删除评论
    # 判断当前用户是否有权限
    comment_id = int(request.query['id'])
    # 只有评论用户和评论所属的微博的用户都能删除评论
    Comment.delete(comment_id)
    return redirect('/weibo/index')
コード例 #2
0
ファイル: api_weibo.py プロジェクト: minnzhang/Ajax-Weibo
def comment_delete():
    comment_id = int(request.args['id'])
    Comment.delete(comment_id)
    d = dict(
        message="成功删除 comment"
    )
    return jsonify(d)
コード例 #3
0
    def destroy(self, id):
        comment = Comment().find(id)

        if comment.user().id == Auth.user().id:
            comment.delete()

        return RedirectResponse((comment.article().url()))
コード例 #4
0
ファイル: weibo.py プロジェクト: BlackCatLongTail/ajax-weibo
 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)
コード例 #5
0
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')
コード例 #6
0
def comment_delete(request):
    comment_id = int(request.query['id'])
    Comment.delete(comment_id)
    d = dict(
        message="成功删除评论"
    )
    return json_response(d)
コード例 #7
0
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)
コード例 #8
0
    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)
コード例 #9
0
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')
コード例 #10
0
    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")
コード例 #11
0
ファイル: comments.py プロジェクト: BojPav/ninja_tech_forum
    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)
コード例 #12
0
ファイル: routes_weibo.py プロジェクト: sweetandpain/socket
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)
コード例 #13
0
ファイル: api_weibo.py プロジェクト: spacexzm/socketMVC
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)
コード例 #14
0
ファイル: api_weibo.py プロジェクト: spacexzm/socketMVC
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)
コード例 #15
0
    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.")
コード例 #16
0
ファイル: postpage.py プロジェクト: ThetHlaing/python-blog
    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)
コード例 #17
0
ファイル: api_weibo.py プロジェクト: sulinalinhang/ajax_weibo
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)
コード例 #18
0
ファイル: comments.py プロジェクト: jpirih/NinjaTechForum
    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})
コード例 #19
0
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')
コード例 #20
0
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)
コード例 #21
0
ファイル: routes_blog.py プロジェクト: Jeffreve/project_web
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))
コード例 #22
0
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)
コード例 #23
0
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
コード例 #24
0
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)
コード例 #25
0
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)
コード例 #26
0
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')
コード例 #27
0
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')
コード例 #28
0
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.'}
		)
コード例 #29
0
ファイル: api_comment.py プロジェクト: ilyydy/Ajax-todo
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
コード例 #30
0
    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)