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:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user