Advertisement
OlexBy

уууу

May 19th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. from flask import Blueprint, session, jsonify, g
  2.  
  3. from .models import Comment
  4. from ..auth.models import User
  5. from ..db import db
  6.  
  7. comments_bp = Blueprint('comments', __name__)
  8.  
  9.  
  10. @comments_bp.route('/comments/<int:comment_id>/', methods=['DELETE'])
  11. def delete_comment(comment_id):
  12. #comment_query = db.session.query(Comment)
  13. comment_filtered = db.session.query(Comment).filter(Comment.id == comment_id)
  14. print '<><><><>', g.user
  15. has_permission = g.user.is_superuser or g.user.id == Comment.id
  16. if has_permission:
  17. comment_filtered.delete()
  18. db.session.commit()
  19. return jsonify({'status': 0})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement