Switch to using render_partial instead of include
This commit is contained in:
3
app.py
3
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)
|
||||
|
||||
|
||||
|
||||
@@ -93,9 +93,7 @@
|
||||
</div>
|
||||
<div class="p-3 text-xs italic font-normal text-gray-500" id="workout_view_wrapper-156">
|
||||
<div id="workout_view-{{ workout.id }}">
|
||||
{% 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']) }}
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<button
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
{% for u in users %}
|
||||
{% with user=u, workouts=u.workouts, bikes=bikes %}
|
||||
{% include 'workouts_list.html' %}
|
||||
{% endwith %}
|
||||
{{ render_partial('workouts_list.html', user=u, workouts=u.workouts, bikes=bikes) }}
|
||||
{% endfor %}
|
||||
|
||||
<script>
|
||||
@@ -12,6 +10,4 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
{% with users=users, bikes=bikes %}
|
||||
{% include 'users.html' %}
|
||||
{% endwith %}
|
||||
{{ render_partial('users.html', users=users, bikes=bikes) }}
|
||||
@@ -1,8 +1,8 @@
|
||||
<div class="block p-6 bg-white border border-b-0 border-gray-200 rounded-lg rounded-b-none shadow">
|
||||
<div class="flex flex-row justify-between">
|
||||
<h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">{{ u.name }}</h5>
|
||||
<h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">{{ user.name }}</h5>
|
||||
<div hx-delete="{{ url_for('delete_user', user_id=user.id) }}"
|
||||
hx-confirm="Are you sure you wish to delete your account {{ u.name }}?" hx-target="#users-container"
|
||||
hx-confirm="Are you sure you wish to delete your account {{ user.name }}?" hx-target="#users-container"
|
||||
class="cursor-pointer pr-2">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" class="w-6 h-6" data-darkreader-inline-stroke=""
|
||||
@@ -37,13 +37,14 @@
|
||||
</div>
|
||||
<button
|
||||
class="shadow mt-6 bg-purple-500 hover:bg-purple-400 focus:shadow-outline focus:outline-none text-white font-bold py-2 px-4 rounded w-full ml-0 md:ml-4"
|
||||
type="submit" onclick="location.href = '{{ url_for('new_workout', user_id=u.id) }}';">New Workout</button>
|
||||
type="submit" onclick="location.href = '{{ url_for('new_workout', user_id=user.id) }}';">New
|
||||
Workout</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="border border-t-0 border-neutral-200 border-b-lg bg-white dark:border-neutral-600 dark:bg-neutral-800 mb-8">
|
||||
{% if u.workouts_count > 0 %}
|
||||
{% if user.workouts_count > 0 %}
|
||||
|
||||
<h2 class="mb-0">
|
||||
<button
|
||||
@@ -63,11 +64,11 @@
|
||||
</button>
|
||||
</h2>
|
||||
<div class="!visible collapse p-4 hidden">
|
||||
{{ render_partial('partials/calendar.html', calendar_month=u.calendar_month, user_id = u.id) }}
|
||||
{{ render_partial('partials/calendar.html', calendar_month=user.calendar_month, user_id = user.id) }}
|
||||
|
||||
<div id="workouts-list-wrapper-for-user-{{ u.id }}" class="mt-5 pl-2">{{
|
||||
<div id="workouts-list-wrapper-for-user-{{ user.id }}" class="mt-5 pl-2">{{
|
||||
render_partial('partials/workouts_list_fragment.html',
|
||||
workouts=workouts[:7], user_id = u.id) }}</div>
|
||||
workouts=workouts[:7], user_id = user.id) }}</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user