def add_comment(flight_id): flight = get_requested_record(Flight, flight_id) current_user = User.get(request.user_id) if not current_user: return jsonify(), 403 json = request.get_json() if json is None: return jsonify(error='invalid-request'), 400 try: data = FlightCommentSchema().load(json).data except ValidationError as e: return jsonify(error='validation-failed', fields=e.messages), 422 comment = FlightComment() comment.user = current_user comment.flight = flight comment.text = data['text'] create_flight_comment_notifications(comment) db.session.commit() return jsonify()
def add_comment(flight_id): flight = get_requested_record(Flight, flight_id) current_user = User.get(request.user_id) if not current_user: return jsonify(), 403 json = request.get_json() if json is None: return jsonify(error="invalid-request"), 400 try: data = FlightCommentSchema().load(json).data except ValidationError as e: return jsonify(error="validation-failed", fields=e.messages), 422 comment = FlightComment() comment.user = current_user comment.flight = flight comment.text = data["text"] create_flight_comment_notifications(comment) db.session.commit() return jsonify()
def add_comment(): if not g.current_user: flash(_('You have to be logged in to post comments!'), 'warning') return redirect(url_for('.index')) text = request.form['text'].strip() if not text: return redirect(url_for('.index')) comment = FlightComment() comment.user = g.current_user comment.flight = g.flight comment.text = text create_flight_comment_notifications(comment) db.session.commit() return redirect(url_for('.index'))
current_user = User.get(request.user_id) if not current_user: return jsonify(), 403 json = request.get_json() if json is None: return jsonify(error='invalid-request'), 400 try: data = FlightCommentSchema().load(json).data except ValidationError, e: return jsonify(error='validation-failed', fields=e.messages), 422 comment = FlightComment() comment.user = current_user comment.flight = flight comment.text = data['text'] create_flight_comment_notifications(comment) db.session.commit() return jsonify() def get_elevations_for_flight(flight): cached_elevations = cache.get('elevations_' + flight.__repr__()) if cached_elevations: return cached_elevations ''' WITH src AS
current_user = User.get(request.user_id) if not current_user: return jsonify(), 403 json = request.get_json() if json is None: return jsonify(error="invalid-request"), 400 try: data = FlightCommentSchema().load(json).data except ValidationError, e: return jsonify(error="validation-failed", fields=e.messages), 422 comment = FlightComment() comment.user = current_user comment.flight = flight comment.text = data["text"] create_flight_comment_notifications(comment) db.session.commit() return jsonify() def get_elevations_for_flight(flight): cached_elevations = cache.get("elevations_" + flight.__repr__()) if cached_elevations: return cached_elevations """