Fixes for GPX tracks display
This commit is contained in:
parent
c586d907d6
commit
214aef1723
20
sar_calls.py
20
sar_calls.py
@ -92,12 +92,21 @@ def edit_sar(id):
|
|||||||
@app.route('/sar_details/<int:id>')
|
@app.route('/sar_details/<int:id>')
|
||||||
def sar_details(id):
|
def sar_details(id):
|
||||||
sar = SARCall.query.get_or_404(id) # Fetch the SARCall record or return 404
|
sar = SARCall.query.get_or_404(id) # Fetch the SARCall record or return 404
|
||||||
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
|
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
|
||||||
|
comments_with_gpx = []
|
||||||
|
|
||||||
# Assuming each comment has a relationship to GPXFile
|
for comment in sar.comments:
|
||||||
print (gpx_files)
|
gpx_tracks = GPSTrack.query.filter_by(comment_id=comment.id).all()
|
||||||
|
for track in gpx_tracks:
|
||||||
|
comments_with_gpx.append({
|
||||||
|
"id": track.id,
|
||||||
|
"comment_id": comment.id,
|
||||||
|
"name": track.file_name,
|
||||||
|
"comment": track.gpx_name
|
||||||
|
})
|
||||||
|
|
||||||
return render_template('sar_details.html', sar=sar, gpx_ids=gpx_files)
|
return render_template('sar_details.html', sar=sar, gpx_ids=gpx_files, comments_with_gpx=comments_with_gpx)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/delete_sar/<int:id>')
|
@app.route('/delete_sar/<int:id>')
|
||||||
@ -169,9 +178,8 @@ def upload_gpx():
|
|||||||
return jsonify({'message': 'GPX file uploaded successfully'})
|
return jsonify({'message': 'GPX file uploaded successfully'})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/get_gpx/<int:gpx_id>')
|
@app.route('/get_gpx/<int:gpx_id>')
|
||||||
@login_required
|
@login_required
|
||||||
def get_gpx(gpx_id):
|
def get_gpx(gpx_id):
|
||||||
gpx_file = GPSTrack.query.get_or_404(gpx_id)
|
gpx_file = GPSTrack.query.get_or_404(gpx_id)
|
||||||
return Response(gpx_file.gpx_data, mimetype='application/gpx+xml')
|
return Response(gpx_file.gpx_data, mimetype='application/gpx+xml')
|
||||||
|
@ -60,6 +60,15 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="comment-text"><p id="comment-text-{{ comment.id }}">{{ comment.text }}</p></div>
|
<div class="comment-text"><p id="comment-text-{{ comment.id }}">{{ comment.text }}</p></div>
|
||||||
|
|
||||||
|
{% for gpx_track in comments_with_gpx %}
|
||||||
|
{% if gpx_track.comment_id == comment.id %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ url_for('get_gpx', gpx_id=gpx_track.id) }}">{{ gpx_track.name }}</a>: {{gpx_track.comment}}
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
{% if current_user.id == comment.user_id or current_user.id == 1 or current_user.id == sar.user_id %}
|
{% if current_user.id == comment.user_id or current_user.id == 1 or current_user.id == sar.user_id %}
|
||||||
<button class="edit-comment-btn" data-comment-id="{{ comment.id }}"
|
<button class="edit-comment-btn" data-comment-id="{{ comment.id }}"
|
||||||
data-comment-text="{{ comment.text }}">Edit
|
data-comment-text="{{ comment.text }}">Edit
|
||||||
|
Loading…
Reference in New Issue
Block a user