fixed comment delete routine
This commit is contained in:
parent
2da7eeb71d
commit
49bf426f91
@ -9,7 +9,12 @@
|
|||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Python 3.9 (SARBase)" jdkType="Python SDK" />
|
<orderEntry type="jdk" jdkName="Python 3.9 (SARBase)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="leaflet.draw" level="application" />
|
||||||
<orderEntry type="library" name="leaflet-control-geocoder" level="application" />
|
<orderEntry type="library" name="leaflet-control-geocoder" level="application" />
|
||||||
|
<orderEntry type="library" name="leaflet" level="application" />
|
||||||
|
<orderEntry type="library" name="jquery-3.5.1.slim" level="application" />
|
||||||
|
<orderEntry type="library" name="@turf/turf" level="application" />
|
||||||
|
<orderEntry type="library" name="leaflet-gpx" level="application" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PackageRequirementsSettings">
|
<component name="PackageRequirementsSettings">
|
||||||
<option name="removeUnused" value="true" />
|
<option name="removeUnused" value="true" />
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="JavaScriptLibraryMappings">
|
<component name="JavaScriptLibraryMappings">
|
||||||
<file url="file://$PROJECT_DIR$" libraries="{leaflet-control-geocoder}" />
|
<file url="file://$PROJECT_DIR$" libraries="{@turf/turf, jquery-3.5.1.slim, leaflet, leaflet-gpx, leaflet.draw}" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -208,6 +208,12 @@ def delete_comment(id):
|
|||||||
comment = Comment.query.get_or_404(id)
|
comment = Comment.query.get_or_404(id)
|
||||||
# if current_user.id != comment.user_id and current_user.id != 1 and current_user.id != comment.sar_call.user_id:
|
# if current_user.id != comment.user_id and current_user.id != 1 and current_user.id != comment.sar_call.user_id:
|
||||||
# abort(403)
|
# abort(403)
|
||||||
|
|
||||||
|
# delete associated GPX files
|
||||||
|
gpx_tracks= GPSTrack.query.filter_by(comment_id=comment.id).all()
|
||||||
|
for track in gpx_tracks:
|
||||||
|
db.session.delete(track)
|
||||||
|
|
||||||
db.session.delete(comment)
|
db.session.delete(comment)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash('Comment deleted successfully!', 'success')
|
flash('Comment deleted successfully!', 'success')
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
<!-- Include leaflet-gpx plugin -->
|
<!-- Include leaflet-gpx plugin -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-gpx/1.7.0/gpx.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-gpx/1.7.0/gpx.min.js"></script>
|
||||||
|
|
||||||
|
<script src='https://unpkg.com/@turf/turf@6/turf.min.js'></script>
|
||||||
<script src="/static/togpx.js"></script>
|
<script src="/static/togpx.js"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@ -424,6 +425,11 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#uploadGPXModal').on('hie', function (e) {
|
||||||
|
// Refresh the parent page (assuming you want to refresh the entire page)
|
||||||
|
location.reload(); // This will refresh the current page
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -444,7 +450,32 @@
|
|||||||
|
|
||||||
// Function to convert GeoJSON to GPX
|
// Function to convert GeoJSON to GPX
|
||||||
function geoJSONToGPX(geoJSONData) {
|
function geoJSONToGPX(geoJSONData) {
|
||||||
var gpx = togpx(geoJSONData);
|
|
||||||
|
// Convert each point to a circle polygon
|
||||||
|
let convertedFeatures = geoJSONData.features.map(feature => {
|
||||||
|
console.log(feature);
|
||||||
|
if (feature.geometry.type === 'Point' && feature.properties.radius) {
|
||||||
|
// Convert radius from meters to kilometers for turf.circle
|
||||||
|
let radiusInKm = feature.properties.radius / 1000;
|
||||||
|
|
||||||
|
// Create a circular polygon
|
||||||
|
let circle = turf.circle(feature.geometry.coordinates, radiusInKm);
|
||||||
|
|
||||||
|
// Optional: transfer other properties to the new feature
|
||||||
|
circle.properties = {...feature.properties};
|
||||||
|
|
||||||
|
return circle;
|
||||||
|
}
|
||||||
|
return feature;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a new GeoJSON FeatureCollection
|
||||||
|
let convertedGeoJSON = {
|
||||||
|
"type": "FeatureCollection",
|
||||||
|
"features": convertedFeatures
|
||||||
|
};
|
||||||
|
console.log(convertedGeoJSON);
|
||||||
|
var gpx = togpx(convertedGeoJSON);
|
||||||
return gpx;
|
return gpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,7 +486,7 @@
|
|||||||
var trackComment = document.getElementById('track-comment').value;
|
var trackComment = document.getElementById('track-comment').value;
|
||||||
var sarID = document.getElementById('sarIdForGPX').value;
|
var sarID = document.getElementById('sarIdForGPX').value;
|
||||||
|
|
||||||
// Get the track data (replace 'getTrackData()' with your method to obtain the track data)
|
// Get the track data
|
||||||
var trackData = getTrackData();
|
var trackData = getTrackData();
|
||||||
|
|
||||||
// Send trackName, trackComment, and trackData to the server
|
// Send trackName, trackComment, and trackData to the server
|
||||||
@ -481,6 +512,12 @@
|
|||||||
// Close the modal
|
// Close the modal
|
||||||
$('#saveTrackModal').modal('hide');
|
$('#saveTrackModal').modal('hide');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#saveTrackModal').on('hidden.bs.modal', function (e) {
|
||||||
|
// Refresh the parent page (assuming you want to refresh the entire page)
|
||||||
|
location.reload(); // This will refresh the current page
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user