latest changes

This commit is contained in:
Joren de Graaf
2026-10-22 10:32:41 +02:00
parent 5799b542c8
commit 5b986134be
63 changed files with 2412 additions and 77 deletions
@@ -0,0 +1,8 @@
{% extends 'planner/base.html' %}{% load static %}
{% block title %}Groceries · Tasknest{% endblock %}
{% block content %}
<link rel="stylesheet" href="{% static 'groceries/groceries.css' %}?v=2">
<div class="grocery-page"><header><p class="grocery-kicker">Food</p><h1>Grocery list</h1><p>Plan what to buy. Marking an item purchased does not add it to Kitchen Inventory.</p></header>
<section class="grocery-panel" aria-labelledby="quick-add"><h2 id="quick-add">Quick add</h2><form class="grocery-add" method="post" action="{% url 'groceries:add' %}">{% csrf_token %}<label>Name<input name="name" maxlength="180" required autocomplete="off"></label><label>Quantity<input name="quantity" type="number" min="0.001" step="0.001" value="1" required></label><label>Unit<select name="unit"><option value="pieces">pieces</option><option value="g">g</option><option value="kg">kg</option><option value="ml">ml</option><option value="L">L</option><option value="packs">packs</option><option value="portions">portions</option><option value="tsp">tsp</option><option value="tbsp">tbsp</option></select></label><label>Category<input name="category" maxlength="80"></label><button type="submit">Add item</button></form></section>
<section class="grocery-panel" aria-labelledby="grocery-items"><div class="grocery-panel-head"><h2 id="grocery-items">Items</h2><form method="post" action="{% url 'groceries:clear-purchased' %}">{% csrf_token %}<button type="submit" class="grocery-text-button">Clear purchased</button></form></div><form method="get" class="grocery-filter" hx-get="{% url 'groceries:index' %}" hx-target="#grocery-list" hx-push-url="true"><label>Search<input type="search" name="q" value="{{ query }}"></label><label>Status<select name="status"><option value="needed"{% if selected_status == 'needed' %} selected{% endif %}>Needed</option><option value="purchased"{% if selected_status == 'purchased' %} selected{% endif %}>Purchased</option><option value="all"{% if selected_status == 'all' %} selected{% endif %}>All</option></select></label><button type="submit">Filter</button></form><div id="grocery-list" aria-live="polite">{% include 'groceries/partials/list.html' %}</div></section></div>
{% endblock %}
@@ -0,0 +1,3 @@
{% extends 'planner/base.html' %}{% load static %}
{% block title %}Add to Kitchen Inventory · Tasknest{% endblock %}
{% block content %}<link rel="stylesheet" href="{% static 'groceries/groceries.css' %}?v=2"><div class="grocery-page"><a href="{% url 'groceries:index' %}">← Grocery list</a><h1>Add purchased item to inventory</h1><section class="grocery-panel"><p><strong>{{ item.name }}</strong> · {{ item.quantity|floatformat:-3 }} {{ item.unit }}</p>{% if item.inventory_transferred_at %}<p>This item was already added to Kitchen Inventory.</p>{% else %}<p>Confirm the product and location. This creates stock only when you submit this form.</p><form method="post" class="grocery-add">{% csrf_token %}<label>Food product<select name="product_id" required><option value="">Choose a product</option>{% for product in products %}<option value="{{ product.api_id }}"{% if product.pk == item.product_id %} selected{% endif %}>{{ product.product_name }}{% if product.brand %} · {{ product.brand }}{% endif %}</option>{% endfor %}</select></label><label>Kitchen location<input name="location" value="Pantry" maxlength="100" required></label><button type="submit">Confirm and add stock</button></form>{% endif %}</section></div>{% endblock %}
@@ -0,0 +1,2 @@
{% regroup items by category as categories %}
{% for group in categories %}<section class="grocery-group"><h3>{{ group.grouper|default:'Other' }}</h3><ul>{% for item in group.list %}<li class="grocery-item"><form method="post" action="{% url 'groceries:update' item.pk %}" class="grocery-item-main">{% csrf_token %}<input type="hidden" name="status" value="{% if item.status == 'needed' %}purchased{% else %}needed{% endif %}"><button type="submit" class="grocery-check" aria-label="Mark {{ item.name }} {% if item.status == 'needed' %}purchased{% else %}needed{% endif %}" aria-pressed="{% if item.status == 'purchased' %}true{% else %}false{% endif %}">{% if item.status == 'purchased' %}✓{% else %}○{% endif %}</button></form><div class="grocery-item-body"><strong>{{ item.name }}</strong><span>{{ item.quantity|floatformat:-3 }} {{ item.unit }}</span>{% if item.notes %}<small>{{ item.notes }}</small>{% endif %}{% for source in item.sources.all %}<small>From {{ source.recipe.title }}</small>{% endfor %}{% if item.status == "purchased" %}<a href="{% url 'groceries:inventory-transfer' item.pk %}">{% if item.inventory_transferred_at %}Added to inventory{% else %}Add to inventory{% endif %}</a>{% endif %}<details><summary>Edit</summary><form method="post" action="{% url 'groceries:update' item.pk %}" class="grocery-edit">{% csrf_token %}<label>Name<input name="name" value="{{ item.name }}" required></label><label>Quantity<input name="quantity" type="number" min="0.001" step="0.001" value="{{ item.quantity }}" required></label><label>Unit<select name="unit"><option value="{{ item.unit }}" selected>{{ item.unit }}</option><option value="pieces">pieces</option><option value="g">g</option><option value="kg">kg</option><option value="ml">ml</option><option value="L">L</option><option value="packs">packs</option><option value="portions">portions</option><option value="tsp">tsp</option><option value="tbsp">tbsp</option></select></label><label>Category<input name="category" value="{{ item.category }}"></label><label>Notes<textarea name="notes">{{ item.notes }}</textarea></label><button type="submit">Save</button></form></details></div><form method="post" action="{% url 'groceries:delete' item.pk %}">{% csrf_token %}<button type="submit" class="grocery-text-button" aria-label="Delete {{ item.name }}">Delete</button></form></li>{% endfor %}</ul></section>{% empty %}<p class="grocery-empty">No grocery items here yet.</p>{% endfor %}
@@ -0,0 +1,3 @@
{% extends 'planner/base.html' %}{% load static %}
{% block title %}Review groceries · {{ recipe.title }}{% endblock %}
{% block content %}<link rel="stylesheet" href="{% static 'groceries/groceries.css' %}?v=2"><div class="grocery-page"><a href="{% url 'recipes:detail' recipe.api_id %}">← Back to recipe</a><h1>Review groceries for {{ recipe.title }}</h1><p>Only known, compatible stock is subtracted. Items already on your grocery list are counted.</p>{% if error %}<p role="alert">{{ error }}</p>{% endif %}{% if plan %}<form method="get" class="grocery-panel grocery-filter"><label>Servings<input type="number" name="servings" min="0.01" max="99999.99" step="0.01" value="{{ plan.servings }}"></label><label><input type="checkbox" name="optional" value="1"{% if plan.include_optional %} checked{% endif %}> Include optional ingredients</label>{% for line in plan.lines %}{% if line.ingredient.substitutions.exists %}<label>{{ line.name }} alternative<select name="sub_{{ line.ingredient.pk }}"><option value="">Original</option>{% for substitute in line.ingredient.substitutions.all %}<option value="{{ substitute.pk }}"{% if line.selected_substitution == substitute.pk|stringformat:"s" %} selected{% endif %}>{{ substitute.name }}</option>{% endfor %}</select></label>{% endif %}{% endfor %}<button>Update preview</button></form><section class="grocery-panel"><h2>Missing ingredients</h2><ul class="grocery-preview-list">{% for line in plan.lines %}<li><strong>{{ line.name }}</strong> · {{ line.quantity|floatformat:-3 }} {{ line.unit }} needed · {{ line.stock_used|floatformat:-3 }} in stock · {{ line.list_used|floatformat:-3 }} listed · <b>{{ line.missing|floatformat:-3 }} to add</b>{% if line.uncertain %}<span class="grocery-uncertain">Review: {{ line.reason }}</span>{% endif %}{% if line.source %}<small>From {{ line.source }}</small>{% endif %}</li>{% empty %}<li>No ingredients to add.</li>{% endfor %}</ul><form method="post" action="{% url 'groceries:recipe-add' recipe.api_id %}">{% csrf_token %}<input type="hidden" name="servings" value="{{ plan.servings }}">{% if plan.include_optional %}<input type="hidden" name="optional" value="1">{% endif %}{% for key,value in plan.substitutions.items %}<input type="hidden" name="sub_{{ key }}" value="{{ value }}">{% endfor %}{% if plan.requires_review %}<label class="grocery-confirm"><input type="checkbox" name="confirm_uncertain" value="1" required> I reviewed the uncertain stock or ingredient matches.</label>{% endif %}<button type="submit">Add missing ingredients</button></form></section>{% endif %}</div>{% endblock %}