Fix Interactive Route Map: Create MapRoute records from GPX files
- Create MapRoute database records for all GPX files for map visualization - Populate route statistics (distance, elevation, coordinates) from GPX parsing - Update GPX file statistics to mirror MapRoute data for post detail pages - Enable /community/api/routes endpoint to return proper route data for map iframe - Fix post detail page GPX statistics display This resolves the issue where the community map showed '2 routes discovered' but routes weren't actually rendering on the Leaflet.js map visualization. Changes: - Dockerfile: Updated init script paths and added migrate-db call - app/__init__.py: Added admin user auto-creation with error handling - app/routes/community.py: Added debug logging and API route for map data - docker-compose.yml: Simplified to use .env for environment variables - run.py: Added comprehensive database schema migration command
This commit is contained in:
@@ -15,6 +15,32 @@ import gpxpy
|
||||
|
||||
community = Blueprint('community', __name__)
|
||||
|
||||
@community.route('/debug')
|
||||
def debug():
|
||||
"""Debug endpoint to check posts"""
|
||||
posts = Post.query.filter_by(published=True).order_by(Post.created_at.desc()).paginate(
|
||||
page=1, per_page=12, error_out=False
|
||||
)
|
||||
|
||||
debug_info = {
|
||||
'total_posts': posts.total,
|
||||
'items_count': len(posts.items),
|
||||
'pages': posts.pages,
|
||||
'posts': []
|
||||
}
|
||||
|
||||
for post in posts.items:
|
||||
debug_info['posts'].append({
|
||||
'id': post.id,
|
||||
'title': post.title,
|
||||
'published': post.published,
|
||||
'author': post.author.nickname if post.author else None,
|
||||
'images_count': post.images.count(),
|
||||
'media_folder': post.media_folder
|
||||
})
|
||||
|
||||
return jsonify(debug_info)
|
||||
|
||||
@community.route('/')
|
||||
def index():
|
||||
"""Community main page with map and posts"""
|
||||
@@ -26,6 +52,11 @@ def index():
|
||||
# Get posts with GPX files for map display
|
||||
posts_with_routes = Post.query.filter_by(published=True).join(GPXFile).all()
|
||||
|
||||
# Debug logging
|
||||
current_app.logger.info(f"Community index: Found {posts.total} total posts, {len(posts.items)} on page {page}")
|
||||
for post in posts.items:
|
||||
current_app.logger.info(f" - Post {post.id}: {post.title}, images: {post.images.count()}")
|
||||
|
||||
return render_template('community/index.html', posts=posts, posts_with_routes=posts_with_routes)
|
||||
|
||||
@community.route('/test-map')
|
||||
|
||||
Reference in New Issue
Block a user