feat: Refactor notes functionality into blueprint

- Moved notes-related routes (viewing/editing workout notes) from `app.py` into a new blueprint at `routes/notes.py`.
- Integrated notes-specific database logic (fetching and updating notes) directly into `routes/notes.py` helper functions, removing the corresponding methods from `db.py` for better encapsulation.
- Registered the new `notes_bp` blueprint in `app.py`.
- Removed the original notes route definitions from `app.py`.
- Updated `url_for` calls in `templates/partials/workout_note.html` to reference the new blueprint endpoints (e.g., `notes.get_person_notes`).
- Updated `templates/changelog/changelog.html` to document this refactoring in its own entry.
This commit is contained in:
Peter Stockings
2025-03-31 22:08:47 +11:00
parent 6095e76f10
commit 78436b230b
6 changed files with 132 additions and 87 deletions

View File

@@ -3,13 +3,13 @@
{% if note|length > 0 %}
<span class="text-base font-normal text-gray-500 whitespace-normal">{{ note | replace('\n', '<br>') | safe }}</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_note_edit_form', person_id=person_id, workout_id=workout_id) }}"
hx-get="{{ url_for('notes.get_workout_note_edit_form', person_id=person_id, workout_id=workout_id) }}"
hx-target="#workout-note-{{workout_id}}">
Edit
</a>
{% else %}
<a class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2 cursor-pointer float-none sm:float-right"
hx-get="{{ url_for('get_workout_note_edit_form', person_id=person_id, workout_id=workout_id) }}"
hx-get="{{ url_for('notes.get_workout_note_edit_form', person_id=person_id, workout_id=workout_id) }}"
hx-target="#workout-note-{{workout_id}}">
Add note
</a>
@@ -24,7 +24,7 @@
<div class="flex flex-col">
<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_workout_note', person_id=person_id, workout_id=workout_id) }}"
hx-get="{{ url_for('notes.get_workout_note', person_id=person_id, workout_id=workout_id) }}"
hx-target="#workout-note-{{workout_id}}">
<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">
@@ -34,7 +34,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-put="{{ url_for('update_workout_note', person_id=person_id, workout_id=workout_id) }}"
hx-put="{{ url_for('notes.update_workout_note', person_id=person_id, workout_id=workout_id) }}"
hx-include="[name='note']">
<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">