mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-23 18:31:08 -05:00
feat: Refactor rides app with unique constraints, mixins, and enhanced documentation
- Added migration to convert unique_together constraints to UniqueConstraint for RideModel. - Introduced RideFormMixin for handling entity suggestions in ride forms. - Created comprehensive code standards documentation outlining formatting, docstring requirements, complexity guidelines, and testing requirements. - Established error handling guidelines with a structured exception hierarchy and best practices for API and view error handling. - Documented view pattern guidelines, emphasizing the use of CBVs, FBVs, and ViewSets with examples. - Implemented a benchmarking script for query performance analysis and optimization. - Developed security documentation detailing measures, configurations, and a security checklist. - Compiled a database optimization guide covering indexing strategies, query optimization patterns, and computed fields.
This commit is contained in:
@@ -316,6 +316,11 @@
|
||||
<!-- Leaflet JS -->
|
||||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
||||
|
||||
{# Security: Safely embed JSON data using Django's json_script tag to prevent XSS #}
|
||||
{% if nearby_locations %}
|
||||
{{ nearby_locations|json_script:"nearby-locations-data" }}
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
// Nearby locations map class
|
||||
class NearbyMap {
|
||||
@@ -436,11 +441,14 @@ class NearbyMap {
|
||||
|
||||
addLocationMarkers() {
|
||||
{% if nearby_locations %}
|
||||
const locations = {{ nearby_locations|safe }};
|
||||
|
||||
locations.forEach(location => {
|
||||
this.addLocationMarker(location);
|
||||
});
|
||||
{# Security: Use json_script to safely embed JSON data without XSS risk #}
|
||||
const locationsData = document.getElementById('nearby-locations-data');
|
||||
if (locationsData) {
|
||||
const locations = JSON.parse(locationsData.textContent);
|
||||
locations.forEach(location => {
|
||||
this.addLocationMarker(location);
|
||||
});
|
||||
}
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user