示例#1
0
 def news_delete(id: int):
     if not auth.is_authorized():
         return redirect('/login')
     news = News.query.filter_by(id=id).first()
     if news.user_id != auth.get_user().id:
         abort(403)
     News.delete(news)
     return redirect('/news')
示例#2
0
 def delete(self, id):
     if not self._auth.is_authorized():
         abort(401)
     news = News.query.filter_by(id=id).first()
     if news.user_id != self._auth.get_user().id:
         abort(403)
     News.delete(news)
     return jsonify({"deleted": True})