From 467f50cc440e33c4322cc6a01e396e27933d643f Mon Sep 17 00:00:00 2001 From: Peter Stockings Date: Sat, 3 Dec 2022 11:53:17 +1100 Subject: [PATCH] Add month/year calendar (mainly static for now) --- app.py | 29 +- templates/calendar.html | 9 + templates/calendar_year.html | 448 ++++++++++++++++++++++++++ templates/partials/page/calendar.html | 431 +++++++++++++++++++++++++ 4 files changed, 916 insertions(+), 1 deletion(-) create mode 100644 templates/calendar.html create mode 100644 templates/calendar_year.html create mode 100644 templates/partials/page/calendar.html diff --git a/app.py b/app.py index 0b32219..fa523c1 100644 --- a/app.py +++ b/app.py @@ -1,4 +1,4 @@ -from datetime import datetime +from datetime import datetime, date, timedelta import os from flask import Flask, render_template, redirect, request, url_for import jinja_partials @@ -61,6 +61,33 @@ def get_person(person_id): return render_template('person.html', person=person, selected_exercise_ids=active_exercise_ids, max_date=max_date, min_date=min_date) +@ app.route("/person//calendar") +@ validate_person +def get_calendar(person_id): + person = db.get_person(person_id) + + selected_date = convert_str_to_date(request.args.get( + 'date'), '%Y-%m-%d') or date.today() + selected_view = request.args.get('view') or 'month' + + next_date = selected_date + (timedelta( + 365/12) if selected_view == 'month' else timedelta(365)) + previous_date = selected_date + (timedelta( + -365/12) if selected_view == 'month' else timedelta(-365)) + + 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) + return render_template('calendar.html', person=person, selected_date=selected_date, selected_view=selected_view, next_date=next_date, previous_date=previous_date) + + +@ app.route("/person//calendar_year") +@ validate_person +def get_calendar_year(person_id): + person = db.get_person(person_id) + return render_template('calendar_year.html', person=person) + + @ app.route("/person//workout", methods=['POST']) @ validate_person def create_workout(person_id): diff --git a/templates/calendar.html b/templates/calendar.html new file mode 100644 index 0000000..134c257 --- /dev/null +++ b/templates/calendar.html @@ -0,0 +1,9 @@ +{% extends 'base.html' %} + +{% block content %} + +{{ render_partial('partials/page/calendar.html', +person=person, selected_date=selected_date, selected_view=selected_view, next_date=next_date, +previous_date=previous_date) }} + +{% endblock %} \ No newline at end of file diff --git a/templates/calendar_year.html b/templates/calendar_year.html new file mode 100644 index 0000000..aad2842 --- /dev/null +++ b/templates/calendar_year.html @@ -0,0 +1,448 @@ +{% extends 'base.html' %} + +{% block content %} + +
+
+
+
+
+ + +
+

2022

+
+ +
+
+
+
+
+
December 2018 +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SMTWTFS
1
2345 + 6 + 78
9101112131415
16171819202122
23242526272829
3031
+
+
+
+
January 2019 +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SMTWTFS
12345
6789101112
13141516171819
20212223242526
2728293031
+
+
+
+
February 2019 +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SMTWTFS
12
3456789
10111213141516
17181920212223
2425262728
+
+
+
+
March 2019 +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SMTWTFS
12
3456789
10111213141516
17181920212223
24252627282930
31
+
+
+
+
April 2019 +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SMTWTFS
123456
78910111213
14151617181920
21222324252627
282930
+
+
+
+
May 2019 +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SMTWTFS
1234
567891011
12131415161718
19202122232425
262728293031
+
+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/templates/partials/page/calendar.html b/templates/partials/page/calendar.html new file mode 100644 index 0000000..eb20016 --- /dev/null +++ b/templates/partials/page/calendar.html @@ -0,0 +1,431 @@ +
+
+
+
+
+ + +
+

{{ strftime(selected_date, '%B, %Y') }}

+
+ +
+
+
+
+ +
+ + Sun +
+
+ + Mon +
+
+ + Tue +
+
+ + Wed +
+
+ + Thu +
+
+ + Fri +
+
+ + Sat +
+
+ +
+ +
+
+ 1 +
+
+ + +
+
+ + +
+
+ 2 +
+
+ + +
+
+ + +
+
+ 3 +
+
+
+ + +
+
+ 4 +
+
+
+ + +
+
+ 6 +
+
+
+ + +
+
+ 7 +
+
+ + +
+
+ + +
+
+ 8 +
+
+
+ + + + + +
+
+ 9 +
+
+
+ + +
+
+ 10 +
+
+
+ + +
+
+ 12 +
+
+ + +
+
+ + +
+
+ 13 +
+
+
+ + +
+
+ 14 +
+
+
+ + +
+
+ 15 +
+
+
+ + +
+
+ 16 +
+
+
+ + + + + + +
+
+ 16 +
+
+ + +
+
+ + +
+
+ 17 +
+
+
+ + +
+
+ 18 +
+
+
+ + +
+
+ 19 +
+
+
+ + +
+
+ 20 +
+
+
+ + +
+
+ 21 +
+
+
+ + +
+
+ 22 +
+
+
+ + + + + + +
+
+ 23 +
+
+
+ + +
+
+ 24 +
+
+
+ + +
+
+ 25 +
+
+
+ + +
+
+ 26 +
+
+
+ + +
+
+ 27 +
+
+
+ + +
+
+ 28 +
+
+
+ + +
+
+ 29 +
+
+
+ + + + + + +
+
+ 30 +
+
+
+ + +
+
+ 31 +
+
+
+ + +
+
+ 1 +
+
+
+ + +
+
+ 2 +
+
+
+ + +
+
+ 3 +
+
+
+ + +
+
+ 4 +
+
+
+ + +
+
+ 5 +
+
+
+ + + +
+ + +
+
\ No newline at end of file