Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Blueprint, session, jsonify, g
- from .models import Comment
- from ..auth.models import User
- from ..db import db
- comments_bp = Blueprint('comments', __name__)
- @comments_bp.route('/comments/<int:comment_id>/', methods=['DELETE'])
- def delete_comment(comment_id):
- #comment_query = db.session.query(Comment)
- comment_filtered = db.session.query(Comment).filter(Comment.id == comment_id)
- print '<><><><>', g.user
- has_permission = g.user.is_superuser or g.user.id == Comment.id
- if has_permission:
- comment_filtered.delete()
- db.session.commit()
- return jsonify({'status': 0})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement