예제 #1
0
파일: flight.py 프로젝트: bbonamin/Skylines
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'))
예제 #2
0
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'))
예제 #3
0
    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
예제 #4
0
    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,