Fix calendar year view
This commit is contained in:
10
app.py
10
app.py
@@ -1,11 +1,11 @@
|
||||
from datetime import datetime, date, timedelta
|
||||
import calendar
|
||||
from dateutil.relativedelta import relativedelta
|
||||
import os
|
||||
from flask import Flask, render_template, redirect, request, url_for
|
||||
import jinja_partials
|
||||
from decorators import validate_person, validate_topset, validate_workout
|
||||
from db import DataBase
|
||||
from utils import get_people_and_exercise_rep_maxes, convert_str_to_date, get_earliest_and_latest_workout_date, filter_workout_topsets, get_exercise_ids_from_workouts
|
||||
from utils import get_people_and_exercise_rep_maxes, convert_str_to_date, get_earliest_and_latest_workout_date, filter_workout_topsets, get_exercise_ids_from_workouts, first_and_last_visible_days_in_month
|
||||
from flask_htmx import HTMX
|
||||
|
||||
app = Flask(__name__)
|
||||
@@ -92,6 +92,10 @@ def get_calendar(person_id):
|
||||
end_date = last_date_of_view + \
|
||||
timedelta(days=end[last_date_of_view.weekday()])
|
||||
|
||||
if selected_view == 'year':
|
||||
start_date = first_date_of_view
|
||||
end_date = last_date_of_view
|
||||
|
||||
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)
|
||||
@@ -299,7 +303,7 @@ def my_utility_processor():
|
||||
def strftime(date, format="%b %d %Y"):
|
||||
return date.strftime(format)
|
||||
|
||||
return dict(get_list_of_people_and_workout_count=get_list_of_people_and_workout_count, is_selected_page=is_selected_page, get_first_element_from_list_with_matching_attribute=get_first_element_from_list_with_matching_attribute, is_checked=is_checked, strftime=strftime, datetime=datetime, timedelta=timedelta)
|
||||
return dict(get_list_of_people_and_workout_count=get_list_of_people_and_workout_count, is_selected_page=is_selected_page, get_first_element_from_list_with_matching_attribute=get_first_element_from_list_with_matching_attribute, is_checked=is_checked, strftime=strftime, datetime=datetime, timedelta=timedelta, relativedelta=relativedelta, first_and_last_visible_days_in_month=first_and_last_visible_days_in_month)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user