From f340d1d3a92bb0d80cec49e58c7220abbecf7868 Mon Sep 17 00:00:00 2001 From: Peter Stockings Date: Fri, 20 Oct 2023 19:40:43 +1100 Subject: [PATCH] Switch to using render_partial instead of include --- app.py | 3 +-- templates/partials/selected_workout_view.html | 4 +--- templates/users_and_workouts_wrapper.html | 8 ++------ templates/workouts_list.html | 15 ++++++++------- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/app.py b/app.py index 18b05a3..66757fd 100644 --- a/app.py +++ b/app.py @@ -1,4 +1,3 @@ -from sqlalchemy import desc from flask_basicauth import BasicAuth import matplotlib.dates as mdates import matplotlib.pyplot as plt @@ -44,7 +43,7 @@ class User(db.Model): bike_id = db.Column(db.Integer, db.ForeignKey( 'bikes.id', ondelete='CASCADE'), nullable=False) workouts = db.relationship( - 'Workout', backref='user', lazy=True, order_by='desc(Workout.created_at)') # 'Workout.created_at' + 'Workout', backref='user', lazy=True, order_by='desc(Workout.created_at)') bike = db.relationship('Bike', backref='user', lazy=True) diff --git a/templates/partials/selected_workout_view.html b/templates/partials/selected_workout_view.html index 1edb411..cf0ff21 100644 --- a/templates/partials/selected_workout_view.html +++ b/templates/partials/selected_workout_view.html @@ -93,9 +93,7 @@
- {% with workout=workout, graph_types=workout['selected_graph_types'] %} - {% include 'workout_view.html' %} - {% endwith %} + {{ render_partial('workout_view.html', workout=workout, graph_types=workout['selected_graph_types']) }}
- {% if u.workouts_count > 0 %} + {% if user.workouts_count > 0 %}