From b72283818c373d6884f1ca32c4364f09f8282d6d Mon Sep 17 00:00:00 2001 From: Joren de Graaf Date: Wed, 14 Oct 2026 18:02:27 +0200 Subject: [PATCH] latest changes --- main/food/static/food/food.css | 24 +++++++++++ main/food/templates/food/inventory_add.html | 5 ++- .../templates/food/inventory_overview.html | 11 +++-- .../partials/inventory_product_actions.html | 5 +++ main/frontend/package.json | 2 +- .../static/planner/checkin_sections.css | 17 ++++++++ .../static/planner/checkin_sections.js | 42 +++++++++++++++++++ .../static/planner/responsive_filters.js | 9 ++++ main/planner/templates/planner/health.html | 4 +- .../partials/bowel_health_checkin.html | 6 +-- .../partials/neck_headache_checkin.html | 8 ++-- main/recipes/static/recipes/match.css | 25 +++++++++++ main/recipes/static/recipes/recipes.css | 9 ++++ main/recipes/templates/recipes/library.html | 10 +++-- main/recipes/templates/recipes/match.html | 23 ++++++---- main/recipes/test_match.py | 14 +++++++ main/recipes/urls.py | 1 + main/recipes/views.py | 8 ++++ main/tasksnest/settings.py | 6 +-- 19 files changed, 201 insertions(+), 28 deletions(-) create mode 100644 main/food/templates/food/partials/inventory_product_actions.html create mode 100644 main/planner/static/planner/checkin_sections.css create mode 100644 main/planner/static/planner/checkin_sections.js create mode 100644 main/planner/static/planner/responsive_filters.js diff --git a/main/food/static/food/food.css b/main/food/static/food/food.css index dd9e728..4db6b09 100644 --- a/main/food/static/food/food.css +++ b/main/food/static/food/food.css @@ -64,3 +64,27 @@ body[data-theme="dark"] .food-tabs a[aria-current=page]{color:#102317} .inventory-product-card{display:grid;gap:.8rem}.inventory-product-heading{display:flex;align-items:center;gap:1rem;min-width:0}.inventory-product-heading img{width:68px;height:68px;object-fit:contain;background:white;border-radius:.6rem}.inventory-product-heading h2{margin:0}.inventory-product-heading p{margin:.25rem 0;overflow-wrap:anywhere}.inventory-packages summary,.inventory-use summary{cursor:pointer;min-height:44px;align-content:center;font-weight:650}.inventory-package-list{display:grid;gap:.65rem;margin:.6rem 0}.inventory-package{display:flex;align-items:center;gap:.8rem;padding:.65rem;border:1px solid var(--food-border);border-radius:.7rem;min-width:0}.inventory-package>div:last-child{min-width:0}.inventory-package p{margin:.2rem 0}.inventory-package small{color:var(--food-muted)}.inventory-package-fill{flex:none;position:relative;width:42px;height:64px;border:2px solid var(--food-muted);border-radius:.3rem;overflow:hidden;background:var(--food-progress-track)}.inventory-package-fill span{position:absolute;bottom:0;left:0;right:0;background:var(--food-green);transition:height .25s ease}.inventory-use-form{display:flex;flex-wrap:wrap;gap:.6rem;align-items:end}.inventory-use-form label{display:grid;gap:.25rem;flex:1;min-width:100px}.inventory-use-form input,.inventory-use-form select{max-width:100%;min-height:44px}.inventory-use-form button{min-height:44px}.inventory-preview{border:1px solid var(--food-border);border-radius:.7rem;padding:.8rem;margin-top:.7rem}.inventory-preview h3{margin:0}.inventory-preview form{display:flex;align-items:center;gap:.6rem;flex-wrap:wrap}.inventory-preview form button,.inventory-history button{min-height:44px}.inventory-preview [role=alert]{color:#e9aa72}.inventory-history ul{padding-left:1.2rem}.inventory-history li{margin:.4rem 0}.inventory-history li form{display:inline-block;margin-left:.5rem}@media(max-width:480px){.inventory-product-heading{align-items:flex-start}.inventory-use-form{display:grid;grid-template-columns:1fr 1fr}.inventory-use-form label:nth-child(3){grid-column:1/-1}.inventory-use-form button{grid-column:1/-1}}@media(prefers-reduced-motion:reduce){.inventory-package-fill span{transition:none}} .food-entry-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:.3rem;flex:none}.food-entry-actions a{display:inline-flex;align-items:center;min-height:44px;padding:.2rem .35rem}.food-entry-actions a:focus-visible{outline:2px solid var(--food-green);outline-offset:2px}@media(max-width:480px){.food-entry{flex-wrap:wrap}.food-entry-actions{width:100%;justify-content:flex-start}} + +/* Inventory search remains available when additional filters are collapsed. */ +.inventory-filters{display:block} +.inventory-filter-search label{display:block;min-width:0;margin-bottom:.3rem;font-size:.82rem;font-weight:700} +.inventory-filter-search>div{display:flex;gap:.6rem;min-width:0} +.inventory-filter-search input{flex:1;min-width:0;min-height:44px} +.inventory-filter-search button{min-height:44px} +.inventory-filter-details{min-width:0;margin-top:.65rem} +.inventory-filter-details summary{display:flex;align-items:center;min-height:44px;cursor:pointer;font-weight:700} +.inventory-filter-details summary:focus-visible{outline:2px solid var(--food-green);outline-offset:2px;border-radius:.3rem} +.inventory-filter-options{display:flex;flex-wrap:wrap;gap:.75rem;align-items:end;padding-top:.4rem} +.inventory-filter-options label{min-width:130px} +.inventory-filter-options .inventory-check{align-self:center} +@media(min-width:821px){.inventory-filter-details[open]>summary{display:none}} +@media(max-width:480px){.inventory-filters{padding:.9rem}.inventory-filter-options label{flex-basis:100%;min-width:0}} +.inventory-filter-search input{padding:.6rem .75rem;border:1px solid var(--food-border);border-radius:.65rem;color:var(--food-ink);background:var(--food-surface)} +.inventory-filter-search input:focus-visible{outline:2px solid var(--food-green);outline-offset:2px} +.inventory-filter-details summary::after{content:'⌄';margin-left:auto;font-size:1.2rem;line-height:1} +.inventory-filter-details[open] summary::after{transform:rotate(180deg)} +.inventory-filter-options select{width:100%;min-height:44px;padding:.55rem .65rem;border:1px solid var(--food-border);border-radius:.65rem;color:var(--food-ink);background:var(--food-surface)} +.inventory-filter-options select:focus-visible{outline:2px solid var(--food-green);outline-offset:2px} +.inventory-heading-actions{display:flex;align-items:center;justify-content:flex-end;gap:.5rem;flex-wrap:wrap} +.inventory-heading-actions .button{min-height:44px} +@media(max-width:600px){.inventory-page>.food-heading{align-items:flex-start;flex-wrap:wrap}.inventory-heading-actions{justify-content:flex-start;width:100%}} diff --git a/main/food/templates/food/inventory_add.html b/main/food/templates/food/inventory_add.html index 62ee93e..1fbe3f1 100644 --- a/main/food/templates/food/inventory_add.html +++ b/main/food/templates/food/inventory_add.html @@ -1,6 +1,6 @@ {% extends 'planner/base.html' %}{% load static %} {% block title %}Add to Kitchen Inventory · Tasknest{% endblock %} -{% block content %} +{% block content %}
← Kitchen Inventory

Add to inventory

{% if product %}
{% if product.image_url %}{% endif %}

{{ product.product_name }}

{% if product.brand %}

{{ product.brand }}

{% endif %}{% if product.package_quantity %}

{{ product.package_quantity }}

{% endif %}{% if off_categories %}

Open Food Facts: {{ off_categories }}

{% endif %}
@@ -11,8 +11,9 @@ Choose another product {% else %} + {% include 'food/partials/inventory_product_actions.html' %} - + {% include 'food/partials/inventory_product_actions.html' %}
{% csrf_token %}
{% endif %}
{% endblock %} diff --git a/main/food/templates/food/inventory_overview.html b/main/food/templates/food/inventory_overview.html index 257fd0c..1cf310e 100644 --- a/main/food/templates/food/inventory_overview.html +++ b/main/food/templates/food/inventory_overview.html @@ -1,12 +1,15 @@ {% extends 'planner/base.html' %}{% load static %} {% block title %}Kitchen Inventory · Tasknest{% endblock %} -{% block content %} -

Kitchen Inventory

What you have and where it lives.

+ Add item
-
+{% block content %} +

Kitchen Inventory

What you have and where it lives.

+ {% for card in cards %}
{% if card.product.image_url %}{% endif %}

{{ card.product.product_name }}

{% if card.product.brand %}

{{ card.product.brand }}

{% endif %}

{{ card.total|floatformat:-3 }} {% if card.unit == "packs" and card.total == 1 %}pack{% else %}{{ card.unit }}{% endif %} remaining · {{ card.packages|length }} package{{ card.packages|length|pluralize }}

View packages
{% for item in card.packages %}
Pack {{ forloop.counter }} · {{ item.package_status|title }}

{% if item.original_amount %}{{ item.remaining_amount|floatformat:-3 }} / {{ item.original_amount|floatformat:-3 }} {{ item.inventory_unit }} · {{ item.percentage_remaining }}% remaining{% else %}{{ item.quantity }} pack{{ item.quantity|pluralize }} · size unknown{% endif %}

{{ item.location.name }}{% if item.category %} · {{ item.category.name }}{% endif %}{% if item.best_before %} · Best before {{ item.best_before }}{% endif %}
{% endfor %}
Use amount
{% csrf_token %}
{% empty %}

No inventory items found.

Add your first item
{% endfor %} {% if recent_consumption %}

Recent use

    {% for entry in recent_consumption %}
  • {{ entry.created_at|date:'j M, H:i' }} · {{ entry.product.product_name }} · {{ entry.amount|floatformat:-3 }} {{ entry.unit }}
    Package changes
      {% for line in entry.lines.all %}
    • Pack {{ line.package.pk }}: {{ line.before_amount|floatformat:-3 }} → {{ line.after_amount|floatformat:-3 }} {{ line.unit }}
    • {% endfor %}
    {% if not entry.reversal %}
    {% csrf_token %}
    {% else %} · Undone{% endif %}
  • {% endfor %}
{% endif %} -
{% endblock %} +
{% endblock %} diff --git a/main/food/templates/food/partials/inventory_product_actions.html b/main/food/templates/food/partials/inventory_product_actions.html new file mode 100644 index 0000000..2072200 --- /dev/null +++ b/main/food/templates/food/partials/inventory_product_actions.html @@ -0,0 +1,5 @@ +
+ Scan barcode + Search Open Food Facts + Create manual product +
diff --git a/main/frontend/package.json b/main/frontend/package.json index 880c27e..2288178 100644 --- a/main/frontend/package.json +++ b/main/frontend/package.json @@ -8,7 +8,7 @@ "dev:django": "VITE_USE_DEV_SERVER=false ../../tasksnest/bin/python ../manage.py runserver 0.0.0.0:1234", "dev:hmr": "concurrently --kill-others-on-fail --names vite,django --prefix-colors cyan,green \"npm run dev:vite\" \"npm run dev:django:hmr\"", "dev:vite": "vite", - "dev:django:hmr": "../../tasksnest/bin/python ../manage.py runserver 0.0.0.0:1234", + "dev:django:hmr": "VITE_USE_DEV_SERVER=true ../../tasksnest/bin/python ../manage.py runserver 0.0.0.0:1234", "build": "vite build", "preview": "vite preview" }, diff --git a/main/planner/static/planner/checkin_sections.css b/main/planner/static/planner/checkin_sections.css new file mode 100644 index 0000000..4b14c44 --- /dev/null +++ b/main/planner/static/planner/checkin_sections.css @@ -0,0 +1,17 @@ +.checkin-score-details summary{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:2px 8px;min-height:48px;list-style:none;cursor:pointer} +.checkin-score-details summary::-webkit-details-marker{display:none} +.checkin-score-details summary::after{content:'⌄';grid-column:2;grid-row:1;color:#64746a;font-size:1.25rem;line-height:1} +.checkin-score-details[open] summary::after{transform:rotate(180deg)} +.checkin-score-details summary:focus-visible{outline:3px solid #377a53;outline-offset:3px;border-radius:6px} +.checkin-score-details__title{grid-column:1;grid-row:1;color:#235943;font-family:Fraunces,Georgia,serif;font-size:1rem;font-weight:700} +.checkin-score-details__summary{grid-column:1/-1;grid-row:2;color:#56645b;font-size:.78rem;line-height:1.35;overflow-wrap:anywhere} +.checkin-period__content,.bowel-period__content,.checkin-score-details__sleep-fields{margin-top:12px} +.checkin-score-details--sleep{grid-column:1/-1;min-width:0;padding:12px 15px;border:1px solid #dce3da;border-radius:12px;background:#f8faf7} +.checkin-form--sleep>.field:first-of-type{grid-column:1/-1;max-width:190px} +.checkin-score-details__sleep-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px} +.checkin-score-details__sleep-fields .checkin-form__note{grid-column:1/-1} +@media(max-width:500px){.checkin-score-details__sleep-fields{grid-template-columns:1fr}} +body[data-theme=dark] .checkin-score-details__title{color:#9bd5ae} +body[data-theme=dark] .checkin-score-details__summary,body[data-theme=dark] .checkin-score-details summary::after{color:#b5c5b9} +body[data-theme=dark] .checkin-score-details--sleep{border-color:#3b473f;background:#29342d} +body[data-theme=dark] .checkin-score-details summary:focus-visible{outline-color:#9bd5ae} diff --git a/main/planner/static/planner/checkin_sections.js b/main/planner/static/planner/checkin_sections.js new file mode 100644 index 0000000..01dfa2b --- /dev/null +++ b/main/planner/static/planner/checkin_sections.js @@ -0,0 +1,42 @@ +(() => { + const score = (panel, name, label, suffix) => { + const value = panel.querySelector(`[name="${name}"]`)?.value.trim(); + return value === undefined || value === '' ? null : `${label} ${value}${suffix}`; + }; + + const updateSummary = (panel) => { + const period = panel.dataset.checkinPeriod; + let scores; + if (panel.dataset.checkinKind === 'pain') { + scores = [ + score(panel, `${period}_neck_pain_severity`, 'Neck', '/10'), + score(panel, `${period}_headache_severity`, 'Headache', '/10'), + ]; + } else if (panel.dataset.checkinKind === 'gut') { + scores = [score(panel, `${period}_severity`, 'Gut', '/10')]; + } else { + scores = [ + score(panel, 'rested_score', 'Rested', '/10'), + score(panel, 'watch_sleep_score', 'Watch', '%'), + ]; + } + const summary = panel.querySelector('[data-checkin-summary]'); + const entered = scores.filter(Boolean); + summary.textContent = entered.length ? entered.join(' · ') : 'No scores recorded'; + }; + + const initialise = (root = document) => { + root.querySelectorAll('[data-checkin-summary-panel]').forEach(updateSummary); + }; + + document.addEventListener('DOMContentLoaded', () => initialise()); + document.addEventListener('htmx:afterSwap', (event) => initialise(event.detail.elt)); + document.addEventListener('input', (event) => { + const panel = event.target.closest?.('[data-checkin-summary-panel]'); + if (panel) updateSummary(panel); + }); + document.addEventListener('change', (event) => { + const panel = event.target.closest?.('[data-checkin-summary-panel]'); + if (panel) updateSummary(panel); + }); +})(); diff --git a/main/planner/static/planner/responsive_filters.js b/main/planner/static/planner/responsive_filters.js new file mode 100644 index 0000000..725d926 --- /dev/null +++ b/main/planner/static/planner/responsive_filters.js @@ -0,0 +1,9 @@ +(() => { + const viewport = window.matchMedia('(max-width: 820px)'); + const panels = document.querySelectorAll('[data-responsive-filters]'); + const update = () => { + panels.forEach((panel) => { panel.open = !viewport.matches; }); + }; + update(); + viewport.addEventListener('change', update); +})(); diff --git a/main/planner/templates/planner/health.html b/main/planner/templates/planner/health.html index d10a8cc..1a9db87 100644 --- a/main/planner/templates/planner/health.html +++ b/main/planner/templates/planner/health.html @@ -1,8 +1,9 @@ -{% extends 'planner/base.html' %} +{% extends 'planner/base.html' %}{% load static %} {% block title %}Health · Tasknest{% endblock %} {% block content %} +

Personal health tracking

@@ -20,4 +21,5 @@ {% include 'planner/partials/hydration_widget.html' %}
+ {% endblock %} diff --git a/main/planner/templates/planner/partials/bowel_health_checkin.html b/main/planner/templates/planner/partials/bowel_health_checkin.html index 9d75bab..59b549a 100644 --- a/main/planner/templates/planner/partials/bowel_health_checkin.html +++ b/main/planner/templates/planner/partials/bowel_health_checkin.html @@ -4,9 +4,9 @@ {% csrf_token %}{% if bowel_form.non_field_errors %}
{{ bowel_form.non_field_errors }}
{% endif %}
{{ bowel_form.check_in_date.label_tag }}{{ bowel_form.check_in_date }}{{ bowel_form.check_in_date.errors }}
-

Morning

{{ bowel_form.morning_severity.label_tag }}{{ bowel_form.morning_severity }}{{ bowel_form.morning_severity.errors }}
{{ bowel_form.morning_note.label_tag }}{{ bowel_form.morning_note }}{{ bowel_form.morning_note.errors }}
-

Afternoon

{{ bowel_form.afternoon_severity.label_tag }}{{ bowel_form.afternoon_severity }}{{ bowel_form.afternoon_severity.errors }}
{{ bowel_form.afternoon_note.label_tag }}{{ bowel_form.afternoon_note }}{{ bowel_form.afternoon_note.errors }}
-

Evening

{{ bowel_form.evening_severity.label_tag }}{{ bowel_form.evening_severity }}{{ bowel_form.evening_severity.errors }}
{{ bowel_form.evening_note.label_tag }}{{ bowel_form.evening_note }}{{ bowel_form.evening_note.errors }}
+
MorningNo score recorded
{{ bowel_form.morning_severity.label_tag }}{{ bowel_form.morning_severity }}{{ bowel_form.morning_severity.errors }}
{{ bowel_form.morning_note.label_tag }}{{ bowel_form.morning_note }}{{ bowel_form.morning_note.errors }}
+
AfternoonNo score recorded
{{ bowel_form.afternoon_severity.label_tag }}{{ bowel_form.afternoon_severity }}{{ bowel_form.afternoon_severity.errors }}
{{ bowel_form.afternoon_note.label_tag }}{{ bowel_form.afternoon_note }}{{ bowel_form.afternoon_note.errors }}
+
EveningNo score recorded
{{ bowel_form.evening_severity.label_tag }}{{ bowel_form.evening_severity }}{{ bowel_form.evening_severity.errors }}
{{ bowel_form.evening_note.label_tag }}{{ bowel_form.evening_note }}{{ bowel_form.evening_note.errors }}
diff --git a/main/planner/templates/planner/partials/neck_headache_checkin.html b/main/planner/templates/planner/partials/neck_headache_checkin.html index 5265925..d64aafa 100644 --- a/main/planner/templates/planner/partials/neck_headache_checkin.html +++ b/main/planner/templates/planner/partials/neck_headache_checkin.html @@ -30,9 +30,9 @@
-

Morning

{{ check_in_form.morning_neck_pain_severity.label_tag }}{{ check_in_form.morning_neck_pain_severity }}{{ check_in_form.morning_neck_pain_severity.help_text }}{% for error in check_in_form.morning_neck_pain_severity.errors %}

{{ error }}

{% endfor %}
{{ check_in_form.morning_headache_severity.label_tag }}{{ check_in_form.morning_headache_severity }}{{ check_in_form.morning_headache_severity.help_text }}{% for error in check_in_form.morning_headache_severity.errors %}

{{ error }}

{% endfor %}
{{ check_in_form.morning_note.label_tag }}{{ check_in_form.morning_note }}{% for error in check_in_form.morning_note.errors %}

{{ error }}

{% endfor %}
-

Afternoon

{{ check_in_form.afternoon_neck_pain_severity.label_tag }}{{ check_in_form.afternoon_neck_pain_severity }}{{ check_in_form.afternoon_neck_pain_severity.help_text }}{% for error in check_in_form.afternoon_neck_pain_severity.errors %}

{{ error }}

{% endfor %}
{{ check_in_form.afternoon_headache_severity.label_tag }}{{ check_in_form.afternoon_headache_severity }}{{ check_in_form.afternoon_headache_severity.help_text }}{% for error in check_in_form.afternoon_headache_severity.errors %}

{{ error }}

{% endfor %}
{{ check_in_form.afternoon_note.label_tag }}{{ check_in_form.afternoon_note }}{% for error in check_in_form.afternoon_note.errors %}

{{ error }}

{% endfor %}
-

Evening

{{ check_in_form.evening_neck_pain_severity.label_tag }}{{ check_in_form.evening_neck_pain_severity }}{{ check_in_form.evening_neck_pain_severity.help_text }}{% for error in check_in_form.evening_neck_pain_severity.errors %}

{{ error }}

{% endfor %}
{{ check_in_form.evening_headache_severity.label_tag }}{{ check_in_form.evening_headache_severity }}{{ check_in_form.evening_headache_severity.help_text }}{% for error in check_in_form.evening_headache_severity.errors %}

{{ error }}

{% endfor %}
{{ check_in_form.evening_note.label_tag }}{{ check_in_form.evening_note }}{% for error in check_in_form.evening_note.errors %}

{{ error }}

{% endfor %}
+
MorningNo scores recorded
{{ check_in_form.morning_neck_pain_severity.label_tag }}{{ check_in_form.morning_neck_pain_severity }}{{ check_in_form.morning_neck_pain_severity.help_text }}{% for error in check_in_form.morning_neck_pain_severity.errors %}

{{ error }}

{% endfor %}
{{ check_in_form.morning_headache_severity.label_tag }}{{ check_in_form.morning_headache_severity }}{{ check_in_form.morning_headache_severity.help_text }}{% for error in check_in_form.morning_headache_severity.errors %}

{{ error }}

{% endfor %}
{{ check_in_form.morning_note.label_tag }}{{ check_in_form.morning_note }}{% for error in check_in_form.morning_note.errors %}

{{ error }}

{% endfor %}
+
AfternoonNo scores recorded
{{ check_in_form.afternoon_neck_pain_severity.label_tag }}{{ check_in_form.afternoon_neck_pain_severity }}{{ check_in_form.afternoon_neck_pain_severity.help_text }}{% for error in check_in_form.afternoon_neck_pain_severity.errors %}

{{ error }}

{% endfor %}
{{ check_in_form.afternoon_headache_severity.label_tag }}{{ check_in_form.afternoon_headache_severity }}{{ check_in_form.afternoon_headache_severity.help_text }}{% for error in check_in_form.afternoon_headache_severity.errors %}

{{ error }}

{% endfor %}
{{ check_in_form.afternoon_note.label_tag }}{{ check_in_form.afternoon_note }}{% for error in check_in_form.afternoon_note.errors %}

{{ error }}

{% endfor %}
+
EveningNo scores recorded
{{ check_in_form.evening_neck_pain_severity.label_tag }}{{ check_in_form.evening_neck_pain_severity }}{{ check_in_form.evening_neck_pain_severity.help_text }}{% for error in check_in_form.evening_neck_pain_severity.errors %}

{{ error }}

{% endfor %}
{{ check_in_form.evening_headache_severity.label_tag }}{{ check_in_form.evening_headache_severity }}{{ check_in_form.evening_headache_severity.help_text }}{% for error in check_in_form.evening_headache_severity.errors %}

{{ error }}

{% endfor %}
{{ check_in_form.evening_note.label_tag }}{{ check_in_form.evening_note }}{% for error in check_in_form.evening_note.errors %}

{{ error }}

{% endfor %}
@@ -44,9 +44,11 @@

Sleep

{% if sleep_check_in_form.non_field_errors %}
{{ sleep_check_in_form.non_field_errors }}
{% endif %}
{{ sleep_check_in_form.wake_up_date.label_tag }}{{ sleep_check_in_form.wake_up_date }}{% for error in sleep_check_in_form.wake_up_date.errors %}

{{ error }}

{% endfor %}
+
Sleep scoresNo scores recorded
{{ sleep_check_in_form.rested_score.label_tag }}{{ sleep_check_in_form.rested_score }}{% for error in sleep_check_in_form.rested_score.errors %}

{{ error }}

{% endfor %}
{{ sleep_check_in_form.watch_sleep_score.label_tag }}{{ sleep_check_in_form.watch_sleep_score }}{% for error in sleep_check_in_form.watch_sleep_score.errors %}

{{ error }}

{% endfor %}
{{ sleep_check_in_form.note.label_tag }}{{ sleep_check_in_form.note }}{% for error in sleep_check_in_form.note.errors %}

{{ error }}

{% endfor %}
+
diff --git a/main/recipes/static/recipes/match.css b/main/recipes/static/recipes/match.css index 0626dc4..ce9b5f1 100644 --- a/main/recipes/static/recipes/match.css +++ b/main/recipes/static/recipes/match.css @@ -4,3 +4,28 @@ @media(prefers-reduced-motion:reduce){.recipe-match__card{transition:none}.recipe-match__confetti i{animation:none;display:none}} .recipe-match{--recipe-surface:#fff;--recipe-line:#e4e8e2;--recipe-ink:#25292e;--recipe-muted:#687178}body[data-theme=dark] .recipe-match{--recipe-surface:#202a23;--recipe-line:#435046;--recipe-ink:#eaf0ea;--recipe-muted:#afbbb2} .recipe-match__celebration{bottom:auto;height:320px}@media(max-width:600px){.recipe-match__celebration{height:min(76vw,320px)}} +.recipe-match__filter-panel{margin-bottom:24px;border:1px solid var(--recipe-line);border-radius:15px;background:var(--recipe-surface)}.recipe-match__filter-panel summary{display:flex;align-items:center;gap:10px;min-height:54px;padding:12px 16px;list-style:none;cursor:pointer;font-size:.88rem;font-weight:800}.recipe-match__filter-panel summary::-webkit-details-marker{display:none}.recipe-match__filter-panel summary small{margin-left:auto;color:var(--recipe-muted);font-size:.72rem;font-weight:600}.recipe-match__filter-panel summary::after{content:'⌄';margin-left:5px;color:var(--recipe-muted);font-size:1.25rem;line-height:1;transition:transform .15s ease}.recipe-match__filter-panel[open] summary::after{transform:rotate(180deg)}.recipe-match__filter-panel summary:focus-visible{outline:3px solid #a44cbe;outline-offset:3px;border-radius:12px}.recipe-match__filter-panel .recipe-match__filters{margin:0;padding:15px;border:0;border-radius:0;background:transparent}.recipe-match__image{height:280px}.recipe-match__celebration{height:280px}@media(min-width:601px){.recipe-match__filter-panel[open]>summary{display:none}}@media(max-width:600px){.recipe-match__filter-panel{margin-bottom:18px}.recipe-match__filter-panel[open] summary{border-bottom:1px solid var(--recipe-line)}.recipe-match__filter-panel .recipe-match__filters{padding:12px}.recipe-match__image,.recipe-match__celebration{height:min(70vw,280px)}} +.recipe-match__header{margin-bottom:16px}.recipe-match__eyebrow{margin-top:14px}.recipe-match__filter-panel{margin-bottom:18px}.recipe-match__counter{margin-bottom:8px}.recipe-match__actions{margin-top:16px}.recipe-match__image,.recipe-match__celebration{height:clamp(240px,26vh,280px)}@media(max-width:600px){.recipe-match__image,.recipe-match__celebration{height:min(70vw,280px)}} +body[data-theme=dark] .recipe-match__image-fallback{color:#253029}body[data-theme=dark] .recipe-match__kind{color:#a9dfb8} +@media(min-width:701px) and (max-width:820px){.site-header__inner{gap:10px;padding-inline:16px}.primary-nav{gap:10px;font-size:.82rem}} +@media(min-width:601px) and (max-width:820px){.recipe-match__filter-panel[open]>summary{display:flex;border-bottom:1px solid var(--recipe-line)}} + +/* Search stays visible while native details collapse the advanced fields. */ +.recipe-match__filter-panel{display:block;padding:12px 15px} +.recipe-match__search-row{display:flex;align-items:end;gap:9px} +.recipe-match__search-row label{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)} +.recipe-match__search-row input{flex:1;min-width:0;min-height:44px;padding:9px;border:1px solid var(--recipe-line);border-radius:9px;color:var(--recipe-ink);background:var(--recipe-surface)} +.recipe-match__search-row button{min-height:44px;padding:9px 15px;border:0;border-radius:9px;color:#fff;background:#235943;font-weight:700;cursor:pointer} +.recipe-match__more-filters summary{display:flex;align-items:center;gap:10px;min-height:44px;margin-top:7px;padding:0 2px;list-style:none;cursor:pointer;font-size:.82rem;font-weight:800} +.recipe-match__more-filters summary::-webkit-details-marker{display:none} +.recipe-match__more-filters summary small{margin-left:auto;color:var(--recipe-muted);font-size:.72rem;font-weight:600} +.recipe-match__more-filters summary::after{content:'⌄';margin-left:5px;color:var(--recipe-muted);font-size:1.25rem;line-height:1;transition:transform .15s ease} +.recipe-match__more-filters[open] summary::after{transform:rotate(180deg)} +.recipe-match__more-filters summary:focus-visible{outline:3px solid #a44cbe;outline-offset:2px;border-radius:6px} +.recipe-match__filter-panel .recipe-match__filters{margin:0;padding:7px 0 0;border:0;border-radius:0;background:transparent} +.recipe-match__filters label:first-child{flex:1 1 135px} +.recipe-match__reset{justify-self:end;margin:0 0 7px} +.recipe-match__reset button{min-height:44px;padding:8px 13px;border:1px solid var(--recipe-line);border-radius:9px;color:var(--recipe-ink);background:var(--recipe-surface);font-size:.82rem;font-weight:700;cursor:pointer} +.recipe-match__reset button:hover{border-color:#a44cbe} +@media(min-width:821px){.recipe-match__more-filters[open]>summary{display:none}} +@media(max-width:600px){.recipe-match__filter-panel{padding:12px}.recipe-match__filter-panel .recipe-match__filters{padding-top:7px}.recipe-match__search-row button{padding-inline:12px}} diff --git a/main/recipes/static/recipes/recipes.css b/main/recipes/static/recipes/recipes.css index 1c1caba..4853421 100644 --- a/main/recipes/static/recipes/recipes.css +++ b/main/recipes/static/recipes/recipes.css @@ -24,3 +24,12 @@ body[data-theme=dark] .recipes-markdown-editor .toastui-editor-defaultUI,body[da .recipes-cook-entry{margin:16px 0 0}.recipes-cook-entry .button{display:inline-flex;align-items:center;min-height:44px}.recipes-cooking,.recipes-cooking-finish{max-width:960px}.recipes-cooking-grid{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(260px,1fr);gap:16px}.recipes-cooking .recipes-panel h2,.recipes-cooking-finish .recipes-panel h2{margin:0 0 12px;font-family:Fraunces,Georgia,serif;font-size:1.35rem}.recipes-cooking-heading{display:flex;align-items:start;justify-content:space-between;gap:12px}.recipes-cooking-progress{margin:4px 0 18px;color:var(--recipe-accent);font-size:.85rem;font-weight:700}.recipes-cooking-step{display:flex;align-items:start;gap:18px;min-height:180px;font-size:1.15rem;line-height:1.65}.recipes-cooking-step[hidden]{display:none}.recipes-cooking-step .recipes-markdown-source{font-size:inherit}.recipes-cooking-number{display:grid;flex:none;place-items:center;width:40px;height:40px;border-radius:50%;color:#fff;background:#235943;font-weight:700}.recipes-cooking-navigation{display:flex;justify-content:space-between;gap:12px;margin-top:18px}.recipes-cooking-navigation button{min-height:44px}.recipes-cooking-navigation button:disabled{opacity:.5;cursor:not-allowed}.recipes-cooking-ingredients ul{padding:0;margin:0;list-style:none}.recipes-cooking-ingredients li{border-bottom:1px solid var(--recipe-line)}.recipes-cooking-ingredients li:last-child{border:0}.recipes-cooking-ingredients label{display:flex;align-items:center;gap:10px;min-height:52px;font-size:.87rem}.recipes-cooking-ingredients input{flex:none;width:20px;height:20px;accent-color:var(--recipe-accent)}.recipes-cooking-ingredients span{flex:1;min-width:0}.recipes-cooking-ingredients small{display:block;color:var(--recipe-muted)}.recipes-cooking-ingredients strong{white-space:nowrap}.recipes-cooking-ingredients input:checked+span{text-decoration:line-through;color:var(--recipe-muted)}.recipes-cooking-components{margin-top:25px;border-top:1px solid var(--recipe-line)}.recipes-cooking-components h3{margin:18px 0 8px}.recipes-cooking-components details{padding:10px 0;border-bottom:1px solid var(--recipe-line)}.recipes-cooking-components summary{cursor:pointer;font-weight:700}.recipes-cooking-components .recipes-markdown-source{margin-top:12px}.recipes-cooking-footer{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:14px;margin-top:16px;padding:16px;border:1px solid var(--recipe-line);border-radius:12px;background:var(--recipe-surface)}.recipes-cooking-footer p{margin:0;color:var(--recipe-muted);font-size:.84rem}.recipes-cooking-finish>.recipes-panel{margin-bottom:14px}.recipes-completion-form{display:grid;gap:15px}.recipes-completion-form>p{margin:0;color:var(--recipe-muted);font-size:.85rem}.recipes-completion-choice{display:flex;align-items:start;gap:12px;padding:13px;border:1px solid var(--recipe-line);border-radius:10px;cursor:pointer}.recipes-completion-choice input{width:20px;height:20px;accent-color:var(--recipe-accent)}.recipes-completion-choice span{display:grid;gap:3px}.recipes-completion-choice small{color:var(--recipe-muted)}.recipes-completion-fields{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.recipes-completion-fields label{display:grid;gap:5px;font-size:.82rem;font-weight:700}.recipes-completion-fields input,.recipes-completion-fields select{width:100%;min-height:44px;padding:8px;border:1px solid var(--recipe-line);border-radius:8px;color:var(--recipe-ink);background:var(--recipe-surface)}.recipes-completion-form>.button{justify-self:start;min-height:44px} @media(max-width:767px){.recipes-cooking-grid{grid-template-columns:1fr}.recipes-cooking-steps{min-height:300px}.recipes-cooking-step{min-height:190px}.recipes-cooking-footer .button{width:100%;text-align:center}.recipes-completion-fields{grid-template-columns:1fr}.recipes-cooking-navigation button{flex:1}} .recipes-cooking-meter{display:block;width:100%;height:9px;margin:-9px 0 21px;accent-color:var(--recipe-accent)} + +/* Keep search available while the additional library filters are collapsed. */ +.recipes-filter-details{min-width:0} +.recipes-filter-details summary{display:flex;align-items:center;min-height:44px;padding:0 2px;cursor:pointer;color:var(--recipe-ink);font-size:.82rem;font-weight:700} +.recipes-filter-details summary:focus-visible{outline:3px solid var(--recipe-accent);outline-offset:2px;border-radius:6px} +.recipes-filter-options{display:grid;gap:12px;padding-top:7px} +@media(min-width:821px){.recipes-filter-details[open]>summary{display:none}} +.recipes-filter-details summary::after{content:'⌄';margin-left:auto;font-size:1.2rem;line-height:1} +.recipes-filter-details[open] summary::after{transform:rotate(180deg)} diff --git a/main/recipes/templates/recipes/library.html b/main/recipes/templates/recipes/library.html index a412ad6..c8095fc 100644 --- a/main/recipes/templates/recipes/library.html +++ b/main/recipes/templates/recipes/library.html @@ -2,7 +2,7 @@ {% block title %}Recipes · Tasknest{% endblock %} {% block page_class %}recipes-page-content{% endblock %} {% block content %} - +
{% endif %}
+ {% endblock %} diff --git a/main/recipes/templates/recipes/match.html b/main/recipes/templates/recipes/match.html index 1271330..23dbfa6 100644 --- a/main/recipes/templates/recipes/match.html +++ b/main/recipes/templates/recipes/match.html @@ -3,19 +3,25 @@ {% block page_class %}recipes-page-content{% endblock %} {% block content %} - +
← Back to recipes

A little cooking demo

Recipe Match

Explore recipes one card at a time. Select a recipe to see if the demo account picked it too.

-
+
{% csrf_token %}

{% for recipe in recipes %} @@ -35,5 +41,6 @@
- + + {% endblock %} diff --git a/main/recipes/test_match.py b/main/recipes/test_match.py index 24e059c..6640268 100644 --- a/main/recipes/test_match.py +++ b/main/recipes/test_match.py @@ -53,6 +53,20 @@ class RecipeMatchTests(TestCase): with transaction.atomic(), self.assertRaises(IntegrityError): RecipeSelection.objects.create(user=self.user, recipe=self.recipe) + def test_reset_restores_own_cards_and_preserves_other_picks(self): + RecipeSelection.objects.create(user=self.demo, recipe=self.recipe) + RecipeSelection.objects.create(user=self.other, recipe=self.recipe) + RecipeSelection.objects.create(user=self.user, recipe=self.recipe) + url = reverse('recipes:match-reset') + self.assertEqual(self.client.get(url).status_code, 405) + self.assertNotContains(self.client.get(reverse('recipes:match')), 'Lemon salmon') + response = self.client.post(url) + self.assertRedirects(response, reverse('recipes:match')) + self.assertFalse(RecipeSelection.objects.filter(user=self.user).exists()) + self.assertTrue(RecipeSelection.objects.filter(user=self.demo, recipe=self.recipe).exists()) + self.assertTrue(RecipeSelection.objects.filter(user=self.other, recipe=self.recipe).exists()) + self.assertContains(self.client.get(reverse('recipes:match')), 'Lemon salmon') + def test_seed_and_reset_uses_existing_demo_recipes(self): self.recipe.status = Recipe.Status.DRAFT self.recipe.save(update_fields=('status',)) diff --git a/main/recipes/urls.py b/main/recipes/urls.py index 13775c5..2d2519c 100644 --- a/main/recipes/urls.py +++ b/main/recipes/urls.py @@ -7,6 +7,7 @@ app_name = 'recipes' urlpatterns = [ path('', views.library, name='list'), path('match/', views.match, name='match'), + path('match/reset/', views.match_reset, name='match-reset'), path('match//select/', views.match_select, name='match-select'), path('match//photo/', views.match_photo, name='match-photo'), path('new/', views.create, name='create'), diff --git a/main/recipes/views.py b/main/recipes/views.py index 3c5fe57..f1556ce 100644 --- a/main/recipes/views.py +++ b/main/recipes/views.py @@ -74,6 +74,14 @@ def match(request): }) +@login_required +@require_POST +def match_reset(request): + RecipeSelection.objects.filter(user=request.user).delete() + messages.success(request, 'Your Recipe Match picks have been reset.') + return redirect('recipes:match') + + @login_required @require_POST def match_select(request, identifier): diff --git a/main/tasksnest/settings.py b/main/tasksnest/settings.py index d2fcab6..7ac0560 100644 --- a/main/tasksnest/settings.py +++ b/main/tasksnest/settings.py @@ -161,10 +161,10 @@ USE_TZ = True STATIC_URL = 'static/' MEDIA_ROOT = BASE_DIR / 'private_media' -# Vite writes production assets and its manifest here. In development templates -# load modules from the Vite server configured by VITE_DEV_SERVER. +# Vite writes built assets and its manifest here. Use the Vite server only when +# explicitly requested by the HMR workflow. VITE_DEV_SERVER = os.environ.get('VITE_DEV_SERVER', 'http://localhost:5173') -VITE_USE_DEV_SERVER = os.environ.get('VITE_USE_DEV_SERVER', str(DEBUG)).lower() in {'1', 'true', 'yes'} +VITE_USE_DEV_SERVER = os.environ.get('VITE_USE_DEV_SERVER', 'false').lower() in {'1', 'true', 'yes'} VITE_MANIFEST_PATH = BASE_DIR / 'planner' / 'static' / 'planner' / 'dist' / '.vite' / 'manifest.json' # Open Food Facts is queried only by explicit food search or product lookup.