Start refactoring person overview (list) page, currently is accessible through tags and workout exercise select. Doesnt have any stats or graphs
This commit is contained in:
47
app.py
47
app.py
@@ -119,6 +119,40 @@ def get_person(person_id):
|
||||
|
||||
return render_template('person.html', person=person, selected_exercise_ids=selected_exercise_ids, max_date=max_date, min_date=min_date, tags=tags), 200, {"HX-Trigger": "updatedPeople"}
|
||||
|
||||
@ app.route("/person/<int:person_id>/workout/overview", methods=['GET'])
|
||||
def person_overview(person_id):
|
||||
min_date = request.args.get('min_date', type=convert_str_to_date)
|
||||
max_date = request.args.get('max_date', type=convert_str_to_date)
|
||||
selected_exercise_ids = request.args.getlist('exercise_id', type=int)
|
||||
|
||||
if not min_date or not max_date:
|
||||
db_min_date, db_max_date = db.person_overview.get_earliest_and_latest_workout_dates(person_id)
|
||||
min_date = min_date or db_min_date
|
||||
max_date = max_date or db_max_date
|
||||
|
||||
if not selected_exercise_ids and htmx.trigger_name != 'exercise_id':
|
||||
selected_exercise_ids = db.person_overview.list_of_performed_exercise_ids(person_id, min_date, max_date)
|
||||
|
||||
person = db.person_overview.get(person_id, min_date, max_date, selected_exercise_ids)
|
||||
exercises = db.person_overview.get_exercises_with_selection(person_id, min_date, max_date, selected_exercise_ids)
|
||||
tags = db.get_tags_for_person(person_id)
|
||||
|
||||
# Render the appropriate response for HTMX or full page
|
||||
render_args = {
|
||||
**person,
|
||||
"exercises": exercises,
|
||||
"tags": tags,
|
||||
"selected_exercise_ids": selected_exercise_ids,
|
||||
"max_date": max_date,
|
||||
"min_date": min_date
|
||||
}
|
||||
|
||||
if htmx:
|
||||
return render_block(app.jinja_env, 'person_overview.html', 'content', **render_args), 200, {"HX-Trigger": "updatedPeople"}
|
||||
|
||||
return render_template('person_overview.html', **render_args), 200, {"HX-Trigger": "updatedPeople"}
|
||||
|
||||
|
||||
|
||||
@ app.route("/person/<int:person_id>/calendar")
|
||||
@ validate_person
|
||||
@@ -146,17 +180,6 @@ def get_person_notes(person_id):
|
||||
return render_block(app.jinja_env, 'notes.html', 'content', person_id=person_id, person_name=person_name, workout_notes=workout_notes)
|
||||
return render_template('notes.html', person_id=person_id, person_name=person_name, workout_notes=workout_notes)
|
||||
|
||||
|
||||
@ app.route("/person/<int:person_id>/workout/<int:workout_id>/modal", methods=['GET'])
|
||||
@ validate_workout
|
||||
def get_workout_modal(person_id, workout_id):
|
||||
workout = db.get_workout(person_id, workout_id)
|
||||
(person_tags, workout_tags, selected_workout_tag_ids) = db.get_workout_tags(
|
||||
person_id, workout_id)
|
||||
exercises = db.get_all_exercises()
|
||||
return render_template('partials/workout_modal.html', **workout, person_tags=person_tags, workout_tags=workout_tags, selected_workout_tag_ids=selected_workout_tag_ids, exercises=exercises)
|
||||
|
||||
|
||||
@ app.route("/person/<int:person_id>/workout", methods=['POST'])
|
||||
def create_workout(person_id):
|
||||
new_workout_id = db.create_workout(person_id)
|
||||
@@ -324,7 +347,7 @@ def goto_tag():
|
||||
person_id = request.args.get("person_id")
|
||||
tag_filter = request.args.get('filter')
|
||||
if person_id:
|
||||
return redirect(url_for('get_person', person_id=int(person_id)) + tag_filter)
|
||||
return redirect(url_for('person_overview', person_id=int(person_id)) + tag_filter)
|
||||
return redirect(url_for('dashboard') + tag_filter)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user