From 448e524ea093e8b44f5c40c4f03921cd5241b6f3 Mon Sep 17 00:00:00 2001 From: vadik likholetov Date: Wed, 15 Nov 2023 16:24:56 +0200 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- sar_calls.py | 18 +++++++++++++++--- templates/sar_details.html | 25 +++++++++++++++++-------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/sar_calls.py b/sar_calls.py index 9f8f3bf..e7108f4 100644 --- a/sar_calls.py +++ b/sar_calls.py @@ -1,5 +1,5 @@ from dateutil import parser -from flask import request, redirect, flash, render_template, url_for, jsonify +from flask import request, redirect, flash, render_template, url_for, jsonify, Response from flask_login import login_required, current_user from app import app, db @@ -92,8 +92,12 @@ def edit_sar(id): @app.route('/sar_details/') def sar_details(id): sar = SARCall.query.get_or_404(id) # Fetch the SARCall record or return 404 - gpx_files = GPSTrack.query.filter_by(sar_call_id=id).all() - return render_template('sar_details.html', sar=sar, gpx_files=gpx_files) + gpx_files = [id[0] for id in GPSTrack.query.with_entities(GPSTrack.id).filter_by(sar_call_id=id).all()] # Fetch all GPX files for this SARCall + + # Assuming each comment has a relationship to GPXFile + print (gpx_files) + + return render_template('sar_details.html', sar=sar, gpx_ids=gpx_files) @app.route('/delete_sar/') @@ -163,3 +167,11 @@ def upload_gpx(): db.session.commit() return jsonify({'message': 'GPX file uploaded successfully'}) + + + +@app.route('/get_gpx/') +@login_required +def get_gpx(gpx_id): + gpx_file = GPSTrack.query.get_or_404(gpx_id) + return Response(gpx_file.gpx_data, mimetype='application/gpx+xml') \ No newline at end of file diff --git a/templates/sar_details.html b/templates/sar_details.html index 3c2a1ca..64ab545 100644 --- a/templates/sar_details.html +++ b/templates/sar_details.html @@ -60,9 +60,6 @@

{{ comment.text }}

- {% if comment.gpx_data %} - - {% endif %} {% if current_user.id == comment.user_id or current_user.id == 1 or current_user.id == sar.user_id %}