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'))
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 (SELECT ST_DumpPoints(flights.locations) AS location, flights.timestamps AS timestamps, flights.locations AS locations
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 (SELECT ST_DumpPoints(flights.locations) AS location, flights.timestamps AS timestamps,