Remove wrappers for calendar, dashboard, & person

This commit is contained in:
Peter Stockings
2023-07-16 09:54:26 +10:00
parent 38d250902b
commit dc88375d8c
7 changed files with 647 additions and 640 deletions

31
app.py
View File

@@ -61,8 +61,7 @@ def dashboard():
all_topsets, selected_person_ids, selected_exercise_ids, min_date, max_date)
if htmx:
return render_template('partials/page/dashboard.html',
model=people_and_exercise_rep_maxes, people=people, exercises=exercises, min_date=min_date, max_date=max_date, selected_person_ids=selected_person_ids, selected_exercise_ids=selected_exercise_ids, tags=tags), 200, {"HX-Trigger": "updatedPeople"}
return render_block(app.jinja_env, 'dashboard.html', 'content', model=people_and_exercise_rep_maxes, people=people, exercises=exercises, min_date=min_date, max_date=max_date, selected_person_ids=selected_person_ids, selected_exercise_ids=selected_exercise_ids, tags=tags)
return render_template('dashboard.html', model=people_and_exercise_rep_maxes, people=people, exercises=exercises, min_date=min_date, max_date=max_date, selected_person_ids=selected_person_ids, selected_exercise_ids=selected_exercise_ids, tags=tags)
@@ -134,8 +133,7 @@ def get_person(person_id):
person['ExerciseGraphs'] = exercise_graph_view_models
if htmx:
return render_template('partials/page/person.html',
person=person, selected_exercise_ids=active_exercise_ids, max_date=max_date, min_date=min_date, tags=tags, graph_axis=graph_axis), 200, {"HX-Trigger": "updatedPeople"}
return render_block(app.jinja_env, 'person.html', 'content', person=person, selected_exercise_ids=active_exercise_ids, max_date=max_date, min_date=min_date, tags=tags, graph_axis=graph_axis), 200, {"HX-Trigger": "updatedPeople"}
return render_template('person.html', person=person, selected_exercise_ids=active_exercise_ids, max_date=max_date, min_date=min_date, tags=tags, graph_axis=graph_axis), 200, {"HX-Trigger": "updatedPeople"}
@@ -161,9 +159,8 @@ def get_calendar(person_id):
end_date = date_info['end_date']
if htmx:
return render_template('partials/page/calendar.html',
person=person, selected_date=selected_date, selected_view=selected_view, next_date=next_date, previous_date=previous_date, start_date=start_date, end_date=end_date)
return render_template('calendar.html', person=person, selected_date=selected_date, selected_view=selected_view, next_date=next_date, previous_date=previous_date, start_date=start_date, end_date=end_date)
return render_block(app.jinja_env, 'calendar.html', 'content', person=person, selected_date=selected_date, selected_view=selected_view, next_date=next_date, previous_date=previous_date, start_date=start_date, end_date=end_date, datetime=datetime, timedelta=timedelta, relativedelta=relativedelta)
return render_template('calendar.html', person=person, selected_date=selected_date, selected_view=selected_view, next_date=next_date, previous_date=previous_date, start_date=start_date, end_date=end_date, datetime=datetime, timedelta=timedelta, relativedelta=relativedelta)
@ app.route("/person/<int:person_id>/workout/<int:workout_id>/modal", methods=['GET'])
@@ -387,6 +384,26 @@ def get_workout_note(person_id, workout_id):
return render_template('partials/workout_note.html', person_id=person_id, workout_id=workout_id, note=workout['Note'])
@app.template_filter('list_to_string')
def list_to_string(list):
return [str(i) for i in list]
@app.template_filter('strftime')
def strftime(date, format="%b %d %Y"):
return date.strftime(format)
@app.template_filter('get_first_element_from_list_with_matching_attribute')
def get_first_element_from_list_with_matching_attribute(list, attribute, value):
if not list:
return None
for element in list:
if element[attribute] == value:
return element
return None
@ app.context_processor
def my_utility_processor():