added stool tracking + toothbrushing tracking

This commit is contained in:
Joren de Graaf
2026-10-02 11:32:59 +02:00
parent d1fbb52937
commit 943dc2280f
16 changed files with 641 additions and 87 deletions
@@ -0,0 +1,17 @@
<section class="checkin-panel bowel-panel" id="bowel-health-checkin" aria-labelledby="bowel-heading">
<header class="checkin-panel__header"><div><p class="eyebrow">Daily wellbeing</p><h2 id="bowel-heading">Bowel health</h2><p>Record how your bowels felt during each part of the day. Choose a date below to edit an entry.</p></div></header>
<form class="checkin-form checkin-form--bowel" method="post" action="{% url 'planner:bowel-health-save' %}" hx-post="{% url 'planner:bowel-health-save' %}" hx-target="#bowel-health-checkin" hx-swap="outerHTML" novalidate>
{% csrf_token %}{% if bowel_form.non_field_errors %}<div class="form-errors">{{ bowel_form.non_field_errors }}</div>{% endif %}
<div class="field">{{ bowel_form.check_in_date.label_tag }}{{ bowel_form.check_in_date }}{{ bowel_form.check_in_date.errors }}</div>
<div class="bowel-periods">
<div class="bowel-period"><h3>Morning</h3><div class="field">{{ bowel_form.morning_severity.label_tag }}{{ bowel_form.morning_severity }}{{ bowel_form.morning_severity.errors }}</div><div class="field">{{ bowel_form.morning_note.label_tag }}{{ bowel_form.morning_note }}{{ bowel_form.morning_note.errors }}</div></div>
<div class="bowel-period"><h3>Afternoon</h3><div class="field">{{ bowel_form.afternoon_severity.label_tag }}{{ bowel_form.afternoon_severity }}{{ bowel_form.afternoon_severity.errors }}</div><div class="field">{{ bowel_form.afternoon_note.label_tag }}{{ bowel_form.afternoon_note }}{{ bowel_form.afternoon_note.errors }}</div></div>
<div class="bowel-period"><h3>Evening</h3><div class="field">{{ bowel_form.evening_severity.label_tag }}{{ bowel_form.evening_severity }}{{ bowel_form.evening_severity.errors }}</div><div class="field">{{ bowel_form.evening_note.label_tag }}{{ bowel_form.evening_note }}{{ bowel_form.evening_note.errors }}</div></div>
</div><div class="form-actions"><button class="button button--compact" type="submit">Save bowel check-in</button></div>
</form>
<section class="checkin-calendar" aria-labelledby="bowel-calendar-heading"><header class="checkin-calendar__header">
<a class="text-link" href="{% url 'planner:task-list' %}?bowel_date={{ bowel_previous_month|date:'Y-m-d' }}#bowel-health-checkin" hx-get="{% url 'planner:bowel-health-panel' %}?date={{ bowel_previous_month|date:'Y-m-d' }}" hx-target="#bowel-health-checkin" hx-swap="outerHTML" aria-label="Previous month">←</a><h3 id="bowel-calendar-heading">{{ bowel_selected_date|date:'F Y' }}</h3><a class="text-link" href="{% url 'planner:task-list' %}?bowel_date={{ bowel_next_month|date:'Y-m-d' }}#bowel-health-checkin" hx-get="{% url 'planner:bowel-health-panel' %}?date={{ bowel_next_month|date:'Y-m-d' }}" hx-target="#bowel-health-checkin" hx-swap="outerHTML" aria-label="Next month">→</a>
</header><div class="checkin-calendar__weekdays" aria-hidden="true"><span>Mon</span><span>Tue</span><span>Wed</span><span>Thu</span><span>Fri</span><span>Sat</span><span>Sun</span></div>
<div class="checkin-calendar__grid">{% for week in bowel_calendar_weeks %}{% for day in week %}<a class="checkin-day{% if day.is_today %} checkin-day--today{% endif %}{% if day.is_selected %} checkin-day--selected{% endif %}{% if day.is_outside_month %} checkin-day--outside{% endif %}" href="{% url 'planner:task-list' %}?bowel_date={{ day.date|date:'Y-m-d' }}#bowel-health-checkin" hx-get="{% url 'planner:bowel-health-panel' %}?date={{ day.date|date:'Y-m-d' }}" hx-target="#bowel-health-checkin" hx-swap="outerHTML" aria-label="{{ day.label }}"><span class="checkin-day__number">{{ day.date|date:'j' }}</span><span class="checkin-day__periods" aria-hidden="true">{% for period in day.periods %}<span class="checkin-day__period checkin-day__period--{{ period.level }}"><span>{{ period.short_label }}</span><strong>{% if period.score is not None %}{{ period.score }}{% else %}—{% endif %}</strong></span>{% endfor %}</span></a>{% endfor %}{% endfor %}</div>
<p class="checkin-calendar__legend">M = morning · A = afternoon · E = evening · 0 = no symptoms · 10 = worst symptoms</p></section>
</section>
@@ -7,7 +7,7 @@
</div>
{% if check_in_active_tab == 'pain' %}
<dl class="checkin-streaks" aria-label="Pain check-in summary">
<div><dt>Current <span class="checkin-tooltip" tabindex="0" aria-label="A confirmed day has both pain scores at {{ check_in_streak_threshold }} or below">ⓘ<span class="checkin-tooltip__content" role="tooltip">A confirmed day has both scores at {{ check_in_streak_threshold }} or below.</span></span></dt><dd>{{ check_in_streaks.current }} day{{ check_in_streaks.current|pluralize }}</dd></div>
<div><dt>Current <span class="checkin-tooltip" tabindex="0" aria-label="A confirmed day has both scores in morning, afternoon, and evening at {{ check_in_streak_threshold }} or below">ⓘ<span class="checkin-tooltip__content" role="tooltip">A confirmed day has both scores in every time period at {{ check_in_streak_threshold }} or below.</span></span></dt><dd>{{ check_in_streaks.current }} day{{ check_in_streaks.current|pluralize }}</dd></div>
<div><dt>Longest</dt><dd>{{ check_in_streaks.longest }} day{{ check_in_streaks.longest|pluralize }}</dd></div>
<div><dt>Physio sessions this year</dt><dd>{{ physio_sessions_this_year }}/{{ annual_physio_session_allowance }}</dd></div>
</dl>
@@ -21,15 +21,19 @@
{% if check_in_active_tab == 'pain' %}
<div id="pain-checkin-panel" role="tabpanel" aria-labelledby="pain-checkin-tab" tabindex="0">
<form class="checkin-form" method="post" action="{% url 'planner:neck-headache-checkin-save' %}" hx-post="{% url 'planner:neck-headache-checkin-save' %}" hx-target="#neck-headache-checkin" hx-swap="outerHTML" novalidate>
<form class="checkin-form checkin-form--pain" method="post" action='{% url "planner:neck-headache-checkin-save" %}' hx-post='{% url "planner:neck-headache-checkin-save" %}' hx-target="#neck-headache-checkin" hx-swap="outerHTML" novalidate>
{% csrf_token %}
<h3 class="checkin-form__heading">Neck &amp; headache</h3>
{% if check_in_form.non_field_errors %}<div class="form-errors">{{ check_in_form.non_field_errors }}</div>{% endif %}
<div class="field{% if check_in_form.check_in_date.errors %} field--error{% endif %}">{{ check_in_form.check_in_date.label_tag }}{{ check_in_form.check_in_date }}{% for error in check_in_form.check_in_date.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div>
<div class="field{% if check_in_form.neck_pain_severity.errors %} field--error{% endif %}">{{ check_in_form.neck_pain_severity.label_tag }}{{ check_in_form.neck_pain_severity }}<small>{{ check_in_form.neck_pain_severity.help_text }}</small>{% for error in check_in_form.neck_pain_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div>
<div class="field{% if check_in_form.headache_severity.errors %} field--error{% endif %}">{{ check_in_form.headache_severity.label_tag }}{{ check_in_form.headache_severity }}<small>{{ check_in_form.headache_severity.help_text }}</small>{% for error in check_in_form.headache_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div>
<div class="field checkin-form__note{% if check_in_form.note.errors %} field--error{% endif %}">{{ check_in_form.note.label_tag }}{{ check_in_form.note }}{% for error in check_in_form.note.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div>
<div class="field checkin-form__physio"><label class="checkbox-field">{{ check_in_form.had_physiotherapy }} <span>{{ check_in_form.had_physiotherapy.label }}</span></label></div>
<div class="checkin-form__topline">
<div class="field{% if check_in_form.check_in_date.errors %} field--error{% endif %}">{{ check_in_form.check_in_date.label_tag }}{{ check_in_form.check_in_date }}{% for error in check_in_form.check_in_date.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div>
<div class="field checkin-form__physio"><label class="checkbox-field">{{ check_in_form.had_physiotherapy }} <span>{{ check_in_form.had_physiotherapy.label }}</span></label></div>
</div>
<div class="checkin-periods">
<section class="checkin-period" aria-labelledby="morning-checkin-heading"><h4 id="morning-checkin-heading">Morning</h4><div class="checkin-period__scores"><div class="field{% if check_in_form.morning_neck_pain_severity.errors %} field--error{% endif %}">{{ check_in_form.morning_neck_pain_severity.label_tag }}{{ check_in_form.morning_neck_pain_severity }}<small>{{ check_in_form.morning_neck_pain_severity.help_text }}</small>{% for error in check_in_form.morning_neck_pain_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div><div class="field{% if check_in_form.morning_headache_severity.errors %} field--error{% endif %}">{{ check_in_form.morning_headache_severity.label_tag }}{{ check_in_form.morning_headache_severity }}<small>{{ check_in_form.morning_headache_severity.help_text }}</small>{% for error in check_in_form.morning_headache_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div></div><div class="field{% if check_in_form.morning_note.errors %} field--error{% endif %}">{{ check_in_form.morning_note.label_tag }}{{ check_in_form.morning_note }}{% for error in check_in_form.morning_note.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div></section>
<section class="checkin-period" aria-labelledby="afternoon-checkin-heading"><h4 id="afternoon-checkin-heading">Afternoon</h4><div class="checkin-period__scores"><div class="field{% if check_in_form.afternoon_neck_pain_severity.errors %} field--error{% endif %}">{{ check_in_form.afternoon_neck_pain_severity.label_tag }}{{ check_in_form.afternoon_neck_pain_severity }}<small>{{ check_in_form.afternoon_neck_pain_severity.help_text }}</small>{% for error in check_in_form.afternoon_neck_pain_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div><div class="field{% if check_in_form.afternoon_headache_severity.errors %} field--error{% endif %}">{{ check_in_form.afternoon_headache_severity.label_tag }}{{ check_in_form.afternoon_headache_severity }}<small>{{ check_in_form.afternoon_headache_severity.help_text }}</small>{% for error in check_in_form.afternoon_headache_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div></div><div class="field{% if check_in_form.afternoon_note.errors %} field--error{% endif %}">{{ check_in_form.afternoon_note.label_tag }}{{ check_in_form.afternoon_note }}{% for error in check_in_form.afternoon_note.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div></section>
<section class="checkin-period" aria-labelledby="evening-checkin-heading"><h4 id="evening-checkin-heading">Evening</h4><div class="checkin-period__scores"><div class="field{% if check_in_form.evening_neck_pain_severity.errors %} field--error{% endif %}">{{ check_in_form.evening_neck_pain_severity.label_tag }}{{ check_in_form.evening_neck_pain_severity }}<small>{{ check_in_form.evening_neck_pain_severity.help_text }}</small>{% for error in check_in_form.evening_neck_pain_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div><div class="field{% if check_in_form.evening_headache_severity.errors %} field--error{% endif %}">{{ check_in_form.evening_headache_severity.label_tag }}{{ check_in_form.evening_headache_severity }}<small>{{ check_in_form.evening_headache_severity.help_text }}</small>{% for error in check_in_form.evening_headache_severity.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div></div><div class="field{% if check_in_form.evening_note.errors %} field--error{% endif %}">{{ check_in_form.evening_note.label_tag }}{{ check_in_form.evening_note }}{% for error in check_in_form.evening_note.errors %}<p class="field-error">{{ error }}</p>{% endfor %}</div></section>
</div>
<div class="form-actions"><button class="button button--compact" type="submit">Save pain check-in</button></div>
</form>
</div>
@@ -53,8 +57,8 @@
<a class="text-link" href="{% url 'planner:task-list' %}?check_in_date={{ check_in_previous_month|date:'Y-m-d' }}&wellbeing_tab={{ check_in_active_tab }}" hx-get="{% url 'planner:neck-headache-checkin-panel' %}?date={{ check_in_previous_month|date:'Y-m-d' }}&tab={{ check_in_active_tab }}" hx-target="#neck-headache-checkin" hx-swap="outerHTML" aria-label="Previous month">←</a><h3 id="checkin-calendar-heading">{{ check_in_selected_date|date:"F Y" }}</h3><a class="text-link" href="{% url 'planner:task-list' %}?check_in_date={{ check_in_next_month|date:'Y-m-d' }}&wellbeing_tab={{ check_in_active_tab }}" hx-get="{% url 'planner:neck-headache-checkin-panel' %}?date={{ check_in_next_month|date:'Y-m-d' }}&tab={{ check_in_active_tab }}" hx-target="#neck-headache-checkin" hx-swap="outerHTML" aria-label="Next month">→</a>
</header>
<div class="checkin-calendar__weekdays" aria-hidden="true"><span>Mon</span><span>Tue</span><span>Wed</span><span>Thu</span><span>Fri</span><span>Sat</span><span>Sun</span></div>
<div class="checkin-calendar__grid">{% for week in check_in_calendar_weeks %}{% for day in week %}<a class="checkin-day checkin-day--{{ day.level }}{% if day.is_today %} checkin-day--today{% endif %}{% if day.is_selected %} checkin-day--selected{% endif %}{% if day.is_outside_month %} checkin-day--outside{% endif %}" href="{% url 'planner:task-list' %}?check_in_date={{ day.date|date:'Y-m-d' }}&wellbeing_tab={{ check_in_active_tab }}" hx-get="{% url 'planner:neck-headache-checkin-panel' %}?date={{ day.date|date:'Y-m-d' }}&tab={{ check_in_active_tab }}" hx-target="#neck-headache-checkin" hx-swap="outerHTML" aria-label="{{ day.label }}"><span class="checkin-day__number">{{ day.date|date:"j" }}</span>{% if day.check_in %}<strong class="checkin-day__score">{{ day.highest_score }}</strong>{% if day.check_in.had_physiotherapy %}<span class="checkin-day__physio" aria-hidden="true">✚</span>{% endif %}{% else %}<span class="checkin-day__empty" aria-hidden="true">—</span>{% endif %}{% if day.sleep_check_in %}<span class="checkin-day__sleep" aria-hidden="true">☾</span>{% endif %}</a>{% endfor %}{% endfor %}</div>
<p class="checkin-calendar__legend"><span><i class="checkin-legend checkin-legend--unrecorded"></i> Pain unrecorded</span><span><i class="checkin-legend checkin-legend--zero"></i> Pain recorded: 0</span><span>Number = highest pain score</span><span><i class="checkin-legend checkin-legend--sleep">☾</i> Sleep check-in</span></p>
<div class="checkin-calendar__grid">{% for week in check_in_calendar_weeks %}{% for day in week %}<a class="checkin-day{% if day.is_today %} checkin-day--today{% endif %}{% if day.is_selected %} checkin-day--selected{% endif %}{% if day.is_outside_month %} checkin-day--outside{% endif %}" href='{% url "planner:task-list" %}?check_in_date={{ day.date|date:"Y-m-d" }}&wellbeing_tab={{ check_in_active_tab }}' hx-get='{% url "planner:neck-headache-checkin-panel" %}?date={{ day.date|date:"Y-m-d" }}&tab={{ check_in_active_tab }}' hx-target="#neck-headache-checkin" hx-swap="outerHTML" aria-label="{{ day.label }}"><span class="checkin-day__number">{{ day.date|date:"j" }}</span><span class="checkin-day__periods" aria-hidden="true">{% for period in day.periods %}<span class="checkin-day__period checkin-day__period--{{ period.level }}"><span>{{ period.short_label }}</span><strong>{% if period.score is not None %}{{ period.score }}{% else %}—{% endif %}</strong></span>{% endfor %}</span>{% if day.check_in and day.check_in.had_physiotherapy %}<span class="checkin-day__physio" aria-hidden="true">✚</span>{% endif %}{% if day.sleep_check_in %}<span class="checkin-day__sleep" aria-hidden="true">☾</span>{% endif %}</a>{% endfor %}{% endfor %}</div>
<p class="checkin-calendar__legend"><span><i class="checkin-legend checkin-legend--unrecorded"></i> Unrecorded period</span><span><i class="checkin-legend checkin-legend--zero"></i> Recorded: 0</span><span>Three bands: morning, afternoon, evening</span><span><i class="checkin-legend checkin-legend--sleep">☾</i> Sleep check-in</span></p>
</section>
{% if check_in_active_tab == 'sleep' %}<section class="sleep-trend" aria-labelledby="sleep-trend-heading"><header><h3 id="sleep-trend-heading">Sleep scores over time</h3><p>Rested and watch scores are shown together for comparison only; neither is presented as causing a change in the other.</p></header>{% if sleep_check_in_trend %}<div class="sleep-trend__table-wrap"><table><thead><tr><th scope="col">Wake-up date</th><th scope="col">Rested</th><th scope="col">Watch</th></tr></thead><tbody>{% for sleep in sleep_check_in_trend %}<tr><th scope="row"><time datetime="{{ sleep.wake_up_date|date:'Y-m-d' }}">{{ sleep.wake_up_date|date:"j M" }}</time></th><td>{{ sleep.rested_score }}/10</td><td>{% if sleep.watch_sleep_score is not None %}{{ sleep.watch_sleep_score }}%{% else %}—{% endif %}</td></tr>{% endfor %}</tbody></table></div>{% else %}<p class="sleep-trend__empty">Save a sleep check-in to start the comparison.</p>{% endif %}</section>{% endif %}
@@ -0,0 +1,4 @@
<form class="brushing-control" method="post" action="{% url 'planner:tooth-brushing-toggle' %}" hx-post="{% url 'planner:tooth-brushing-toggle' %}" hx-target="this" hx-swap="outerHTML">
{% csrf_token %}<input type="hidden" name="date" value="{{ brushing_day|date:'Y-m-d' }}"><input type="hidden" name="period" value="{{ brushing_period }}">
<button type="submit" aria-pressed="{% if brushing_done %}true{% else %}false{% endif %}" aria-label="{{ brushing_day|date:'l j F' }} {{ brushing_period }} brushing{% if brushing_done %}, done{% else %}, not done{% endif %}"><span class="brushing-control__mark" aria-hidden="true">{% if brushing_done %}●{% else %}○{% endif %}</span> {{ brushing_period|capfirst }}</button>
</form>
@@ -0,0 +1,9 @@
<article class="brushing-widget" aria-labelledby="brushing-heading">
<p class="eyebrow">Daily routine</p><h2 id="brushing-heading">Teeth</h2>
<div class="brushing-days">{% for day in brushing_days %}
<div class="brushing-day"><time datetime="{{ day.date|date:'Y-m-d' }}">{{ day.date|date:'l' }}</time><div class="brushing-day__controls">
{% include 'planner/partials/tooth_brushing_control.html' with brushing_day=day.date brushing_period='morning' brushing_done=day.record.morning %}
{% include 'planner/partials/tooth_brushing_control.html' with brushing_day=day.date brushing_period='evening' brushing_done=day.record.evening %}
</div></div>
{% endfor %}</div>
</article>
@@ -40,10 +40,12 @@
{% include 'planner/partials/workout_section.html' %}
{% include 'planner/partials/neck_headache_checkin.html' %}
{% include 'planner/partials/bowel_health_checkin.html' %}
</div>
{% if user.is_authenticated %}
<aside class="homepage-sidebar" aria-label="Personal routines">
{% include 'planner/partials/weather_widget.html' %}
{% include 'planner/partials/tooth_brushing_widget.html' %}
{% include 'planner/partials/fasting_widget.html' %}
</aside>
{% endif %}