@bp.route('/<int:uid>/reply', methods=['POST', 'DELETE'])
@limit_request(5, redirect_url=(lambda uid: url_for('.view', uid=uid)))
@require_user
def reply(uid):
 if (request.method == 'DELETE'):
  reply_id = force_int(request.args.get('reply', 0), 0)
  if (not reply_id):
   return abort(404)
  reply = Reply.query.get_or_404(reply_id)
  if (not reply):
   return abort(404)
  if (reply.topic_id != uid):
   return abort(404)
  if (g.user.is_staff or (g.user.id == reply.account_id)):
   reply.delete()
   return jsonify(status='success')
  return abort(403)
 topic = Topic.query.get_or_404(uid)
 form = ReplyForm()
 if form.validate_on_submit():
  form.save(g.user, topic)
 else:
  flash(_('Missing content'), 'error')
 return redirect(url_for('.view', uid=uid))

@ bp . route ( '/<int:uid>/reply' , methods = [ 'POST' , 'DELETE' ] ) @ limit_request ( 5 , redirect_url = ( lambda uid : url_for ( '.view' , uid = uid ) ) ) @ require_user def reply ( uid ) : if ( request . method == 'DELETE' ) : reply_id = force_int ( request . args . get ( 'reply' , 0 ) , 0 ) if ( not reply_id ) : return abort ( 404 ) reply = Reply . query . get_or_404 ( reply_id ) if ( not reply ) : return abort ( 404 ) if ( reply . topic_id != uid ) : return abort ( 404 ) if ( g . user . is_staff or ( g . user . id == reply . account_id ) ) : reply . delete ( ) return jsonify ( status = 'success' ) return abort ( 403 ) topic = Topic . query . get_or_404 ( uid ) form = ReplyForm ( ) if form . validate_on_submit ( ) : form . save ( g . user , topic ) else : flash ( _ ( 'Missing content' ) , 'error' ) return redirect ( url_for ( '.view' , uid = uid ) )
reply to a thread .