feat: Refactor workout functionality into blueprint
- Moved workout-related routes (create/delete/edit workouts, topsets, tags, start dates, show workout) from `app.py` into a new blueprint at `routes/workout.py`. - Integrated workout view model logic from `features/workout.py` directly into `routes/workout.py` helper function `_get_workout_view_model`. - Removed `features/workout.py` and the corresponding class instantiation in `db.py`. - Registered the new `workout_bp` blueprint in `app.py`. - Removed the original workout route definitions from `app.py`. - Updated `url_for` calls in relevant templates (`workout.html`, `person_overview.html`, `partials/workout_tags.html`, `partials/topset.html`, `partials/start_date.html`, `partials/new_set_form.html`, `notes.html`, `calendar.html`) to reference the new blueprint endpoints (e.g., `workout.create_workout`). - Updated `templates/changelog/changelog.html` to document this refactoring.
This commit is contained in:
@@ -95,7 +95,7 @@
|
||||
</div>
|
||||
{% for workout in day.workouts %}
|
||||
<div class="bottom flex-grow py-1 w-full"
|
||||
hx-get="{{ url_for('show_workout', person_id=person_id, workout_id=workout.workout_id) }}"
|
||||
hx-get="{{ url_for('workout.show_workout', person_id=person_id, workout_id=workout.workout_id) }}"
|
||||
hx-push-url="true" hx-target="#container">
|
||||
{% for set in workout.sets %}
|
||||
<button
|
||||
@@ -141,7 +141,7 @@
|
||||
{% for day in month.days %}
|
||||
<div class="{% if day.is_today and day.is_in_current_month %}rounded-md border-4 border-green-50 border{% endif %} py-3 px-4 hover:bg-blue hover:text-white text-center cursor-pointer rounded-md {% if day.has_workouts and day.is_in_current_month %}bg-green-100{% endif %}"
|
||||
{% if day.has_workouts %}
|
||||
hx-get="{{ url_for('show_workout', person_id=person_id, workout_id=day.first_workout_id) }}"
|
||||
hx-get="{{ url_for('workout.show_workout', person_id=person_id, workout_id=day.first_workout_id) }}"
|
||||
hx-push-url="true" hx-target="#container" {% endif %}>
|
||||
{% if day.is_in_current_month %}
|
||||
{{ day.day }}
|
||||
@@ -170,7 +170,7 @@
|
||||
{% block add_workout_button %}
|
||||
<button
|
||||
class="fixed z-90 bottom-10 right-8 bg-blue-600 w-20 h-20 rounded-full drop-shadow-lg flex justify-center items-center text-white text-4xl hover:bg-blue-700 hover:drop-shadow-2xl hover:animate-bounce duration-300"
|
||||
hx-post="{{ url_for('create_workout', person_id=person_id) }}" hx-push-url="true" hx-target="#container">
|
||||
hx-post="{{ url_for('workout.create_workout', person_id=person_id) }}" hx-push-url="true" hx-target="#container">
|
||||
<svg viewBox="0 0 20 20" enable-background="new 0 0 20 20" class="w-6 h-6 inline-block">
|
||||
<path fill="#FFFFFF" d="M16,10c0,0.553-0.048,1-0.601,1H11v4.399C11,15.951,10.553,16,10,16c-0.553,0-1-0.049-1-0.601V11H4.601
|
||||
C4.049,11,4,10.553,4,10c0-0.553,0.049-1,0.601-1H9V4.601C9,4.048,9.447,4,10,4c0.553,0,1,0.048,1,0.601V9h4.399
|
||||
|
||||
@@ -10,6 +10,17 @@
|
||||
<div class="prose max-w-none">
|
||||
<p>Updates and changes to the site will be documented here, with the most recent changes listed first.</p>
|
||||
|
||||
<!-- New Entry for Workout Refactoring -->
|
||||
<hr class="my-6">
|
||||
<h2 class="text-xl font-semibold mb-2">March 31, 2025</h2>
|
||||
<ul class="list-disc pl-5 space-y-1">
|
||||
<li>Refactored workout functionality (create/delete/edit workouts, topsets, tags) into its own blueprint
|
||||
(`routes/workout.py`).</li>
|
||||
<li>Moved workout view model logic from `features/workout.py` into the `routes/workout.py` blueprint.
|
||||
</li>
|
||||
<li>Updated relevant `url_for` calls in templates to use the new `workout.` prefix.</li>
|
||||
</ul>
|
||||
|
||||
<!-- New Entry for Calendar Year View Fix -->
|
||||
<hr class="my-6">
|
||||
<h2 class="text-xl font-semibold mb-2">March 31, 2025</h2>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
{% for workout_note in workout_notes %}
|
||||
<tr class="border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted">
|
||||
<td class="p-4 align-middle [&:has([role=checkbox])]:pr-0 cursor-pointer"
|
||||
hx-get="{{ url_for('show_workout', person_id=person_id, workout_id=workout_note.workout_id) }}"
|
||||
hx-get="{{ url_for('workout.show_workout', person_id=person_id, workout_id=workout_note.workout_id) }}"
|
||||
hx-push-url="true" hx-target="#container">
|
||||
<div class="flex flex-row items-center justify-center">
|
||||
<button
|
||||
@@ -96,7 +96,7 @@
|
||||
{% block add_workout_button %}
|
||||
<button
|
||||
class="fixed z-90 bottom-10 right-8 bg-blue-600 w-20 h-20 rounded-full drop-shadow-lg flex justify-center items-center text-white text-4xl hover:bg-blue-700 hover:drop-shadow-2xl hover:animate-bounce duration-300"
|
||||
hx-post="{{ url_for('create_workout', person_id=person_id) }}" hx-push-url="true" hx-target="#container">
|
||||
hx-post="{{ url_for('workout.create_workout', person_id=person_id) }}" hx-push-url="true" hx-target="#container">
|
||||
<svg viewBox="0 0 20 20" enable-background="new 0 0 20 20" class="w-6 h-6 inline-block">
|
||||
<path fill="#FFFFFF" d="M16,10c0,0.553-0.048,1-0.601,1H11v4.399C11,15.951,10.553,16,10,16c-0.553,0-1-0.049-1-0.601V11H4.601
|
||||
C4.049,11,4,10.553,4,10c0-0.553,0.049-1,0.601-1H9V4.601C9,4.048,9.447,4,10,4c0.553,0,1,0.048,1,0.601V9h4.399
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<form class="w-full" id="new-set-workout-{{ workout_id }}"
|
||||
hx-post="{{ url_for('create_topset', person_id=person_id, workout_id=workout_id) }}" hx-swap="beforeend"
|
||||
hx-post="{{ url_for('workout.create_topset', person_id=person_id, workout_id=workout_id) }}" hx-swap="beforeend"
|
||||
hx-target="#new-workout" _="on htmx:afterOnLoad if #no-workouts add .hidden to #no-workouts end
|
||||
on topsetAdded
|
||||
render #notification-template with (message: 'Topset added') then append it to #notifications-container
|
||||
@@ -52,7 +52,7 @@
|
||||
</form>
|
||||
|
||||
<div hx-trigger="exerciseSelected from:body"
|
||||
hx-get="{{ url_for('get_most_recent_topset_for_exercise', person_id=person_id, workout_id=workout_id) }}"
|
||||
hx-get="{{ url_for('workout.get_most_recent_topset_for_exercise', person_id=person_id, workout_id=workout_id) }}"
|
||||
hx-target="#new-set-workout-{{ workout_id }}" hx-include="[name='exercise_id']">
|
||||
</div>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% if is_edit|default(false, true) == false %}
|
||||
<span class="text-base font-normal text-gray-500">{{ strftime(start_date, "%b %d %Y") }}</span>
|
||||
<a class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2 cursor-pointer"
|
||||
hx-get="{{ url_for('get_workout_start_date_edit_form', person_id=person_id, workout_id=workout_id) }}"
|
||||
hx-get="{{ url_for('workout.get_workout_start_date_edit_form', person_id=person_id, workout_id=workout_id) }}"
|
||||
hx-target="#edit-start-date">
|
||||
Edit
|
||||
</a>
|
||||
@@ -20,10 +20,10 @@
|
||||
<input type="date"
|
||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5 w-full"
|
||||
name="start-date" value="{{ start_date }}"
|
||||
hx-put="{{ url_for('update_workout_start_date', person_id=person_id, workout_id=workout_id) }}">
|
||||
hx-put="{{ url_for('workout.update_workout_start_date', person_id=person_id, workout_id=workout_id) }}">
|
||||
</div>
|
||||
|
||||
<a hx-get="{{ url_for('get_workout_start_date', person_id=person_id, workout_id=workout_id) }}"
|
||||
<a hx-get="{{ url_for('workout.get_workout_start_date', person_id=person_id, workout_id=workout_id) }}"
|
||||
hx-target="#edit-start-date"
|
||||
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2 cursor-pointer">
|
||||
Cancel
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
{% if is_edit|default(false, true) == false %}
|
||||
<button
|
||||
class="inline-flex justify-center p-2 text-blue-600 rounded-full cursor-pointer hover:bg-blue-100 dark:text-blue-500 dark:hover:bg-gray-600"
|
||||
hx-get="{{ url_for('get_topset_edit_form', person_id=person_id, workout_id=workout_id, topset_id=topset_id) }}">
|
||||
hx-get="{{ url_for('workout.get_topset_edit_form', person_id=person_id, workout_id=workout_id, topset_id=topset_id) }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" class="w-5 h-5">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
@@ -55,7 +55,7 @@
|
||||
</button>
|
||||
<button
|
||||
class="inline-flex justify-center p-2 text-blue-600 rounded-full cursor-pointer hover:bg-blue-100 dark:text-blue-500 dark:hover:bg-gray-600"
|
||||
hx-delete="{{ url_for('delete_topset', person_id=person_id, workout_id=workout_id, topset_id=topset_id) }}"
|
||||
hx-delete="{{ url_for('workout.delete_topset', person_id=person_id, workout_id=workout_id, topset_id=topset_id) }}"
|
||||
hx-confirm="Are you sure you wish to delete this topset?">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" class="w-5 h-5">
|
||||
@@ -68,7 +68,7 @@
|
||||
{% else %}
|
||||
<button
|
||||
class="inline-flex justify-center p-2 text-blue-600 rounded-full cursor-pointer hover:bg-blue-100 dark:text-blue-500 dark:hover:bg-gray-600"
|
||||
hx-put="{{ url_for('update_topset', person_id=person_id, workout_id=workout_id, topset_id=topset_id) }}"
|
||||
hx-put="{{ url_for('workout.update_topset', person_id=person_id, workout_id=workout_id, topset_id=topset_id) }}"
|
||||
hx-include="#topset-{{ topset_id }} * [name='exercise_id'],#topset-{{ topset_id }} * [name='repetitions'],#topset-{{ topset_id }} * [name='weight']">
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
@@ -80,7 +80,7 @@
|
||||
|
||||
<button
|
||||
class="inline-flex justify-center p-2 text-blue-600 rounded-full cursor-pointer hover:bg-blue-100 dark:text-blue-500 dark:hover:bg-gray-600"
|
||||
hx-get="{{ url_for('get_topset', person_id=person_id, workout_id=workout_id, topset_id=topset_id) }}">
|
||||
hx-get="{{ url_for('workout.get_topset', person_id=person_id, workout_id=workout_id, topset_id=topset_id) }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" class="w-5 h-5">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<div class="relative">
|
||||
<div class="w-full">
|
||||
<select multiple name="tag_id"
|
||||
hx-post="{{ url_for('add_tag_to_workout', person_id=person_id, workout_id=workout_id) }}"
|
||||
hx-post="{{ url_for('workout.add_tag_to_workout', person_id=person_id, workout_id=workout_id) }}"
|
||||
hx-target="#tag-wrapper-w-{{ workout_id }}"
|
||||
class="block appearance-none w-full bg-gray-200 border border-gray-200 text-gray-700 py-3 px-4 pr-8 rounded leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
|
||||
_="init js(me)
|
||||
@@ -66,7 +66,7 @@
|
||||
type="text" name="tag_name">
|
||||
|
||||
<button type="submit"
|
||||
hx-post="{{ url_for('create_new_tag_for_workout', person_id=person_id, workout_id=workout_id) }}"
|
||||
hx-post="{{ url_for('workout.create_new_tag_for_workout', person_id=person_id, workout_id=workout_id) }}"
|
||||
hx-include="[name='tag_name']" hx-target="#tag-wrapper-w-{{ workout_id }}"
|
||||
class="p-2.5 ml-2 text-sm font-medium text-white bg-blue-700 rounded-lg border border-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
<tbody class="bg-white">
|
||||
|
||||
{% for workout in workouts %}
|
||||
<tr hx-get="{{ url_for('show_workout', person_id=person_id, workout_id=workout.id) }}"
|
||||
<tr hx-get="{{ url_for('workout.show_workout', person_id=person_id, workout_id=workout.id) }}"
|
||||
hx-push-url="true" hx-target="#container" class="cursor-pointer">
|
||||
<td class="p-4 whitespace-nowrap text-sm font-normal text-gray-500">
|
||||
{{ workout.start_date | strftime("%b %d %Y") }}
|
||||
@@ -175,7 +175,7 @@
|
||||
{% block add_workout_button %}
|
||||
<button
|
||||
class="fixed z-90 bottom-10 right-8 bg-blue-600 w-20 h-20 rounded-full drop-shadow-lg flex justify-center items-center text-white text-4xl hover:bg-blue-700 hover:drop-shadow-2xl hover:animate-bounce duration-300"
|
||||
hx-post="{{ url_for('create_workout', person_id=person_id) }}" hx-push-url="true" hx-target="#container">
|
||||
hx-post="{{ url_for('workout.create_workout', person_id=person_id) }}" hx-push-url="true" hx-target="#container">
|
||||
<svg viewBox="0 0 20 20" enable-background="new 0 0 20 20" class="w-6 h-6 inline-block">
|
||||
<path fill="#FFFFFF" d="M16,10c0,0.553-0.048,1-0.601,1H11v4.399C11,15.951,10.553,16,10,16c-0.553,0-1-0.049-1-0.601V11H4.601
|
||||
C4.049,11,4,10.553,4,10c0-0.553,0.049-1,0.601-1H9V4.601C9,4.048,9.447,4,10,4c0.553,0,1,0.048,1,0.601V9h4.399
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
|
||||
<button type="button"
|
||||
class="absolute right-0 text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 ml-auto inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white mr-2"
|
||||
hx-get="{{ url_for('delete_workout', person_id=person_id, workout_id=workout_id) }}"
|
||||
hx-get="{{ url_for('workout.delete_workout', person_id=person_id, workout_id=workout_id) }}"
|
||||
hx-confirm="Are you sure you wish to delete this workout?" hx-push-url="true"
|
||||
hx-target="#container">
|
||||
<svg aria-hidden="true" class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20"
|
||||
|
||||
Reference in New Issue
Block a user