latest changes

This commit is contained in:
Joren de Graaf
2026-10-07 14:33:21 +02:00
parent 86be3034c8
commit 98f76918dc
27 changed files with 1500 additions and 11 deletions
@@ -0,0 +1,18 @@
{% extends 'planner/base.html' %}{% load static %}
{% block title %}Add to Kitchen Inventory · Tasknest{% endblock %}
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}">
<div class="food-form-page inventory-page"><a href="{% url 'food:inventory' %}">← Kitchen Inventory</a><h1>Add to inventory</h1>
{% if product %}
<section class="food-card inventory-product">{% if product.image_url %}<img src="{{ product.image_url }}" alt="" loading="lazy">{% endif %}<div><h2>{{ product.product_name }}</h2>{% if product.brand %}<p>{{ product.brand }}</p>{% endif %}{% if product.package_quantity %}<p>{{ product.package_quantity }}</p>{% endif %}{% if off_categories %}<p><small>Open Food Facts: {{ off_categories }}</small></p>{% endif %}</div></section>
{% if existing %}<section class="food-card"><h2>Already in inventory</h2>{% for item in existing %}<div class="inventory-existing"><span>{{ item.location.name }} · Quantity {{ item.quantity }}{% if item.best_before %} · Best before {{ item.best_before }}{% endif %}</span><form method="post" action="{% url 'food:inventory-add-one' item.pk %}">{% csrf_token %}<button class="button button--secondary" type="submit">+1 existing item</button></form></div>{% endfor %}<p>Use the form below to add this product separately.</p></section>{% endif %}
<form class="food-card inventory-form" method="post">{% csrf_token %}<input type="hidden" name="product" value="{{ product.pk }}">{{ form.non_field_errors }}
{% for field in form %}<div class="form-field">{{ field.label_tag }}{% if field.name == 'quantity' %}<div class="inventory-quantity" data-inventory-quantity><button type="button" data-inventory-step="-1" aria-label="Decrease quantity">−</button>{{ field }}<button type="button" data-inventory-step="1" aria-label="Increase quantity">+</button></div>{% else %}{{ field }}{% endif %}{{ field.errors }}</div>{% endfor %}
<datalist id="inventory-locations">{% for location in locations %}<option value="{{ location.name }}">{% endfor %}</datalist><datalist id="inventory-categories">{% for category in categories %}<option value="{{ category.name }}">{% endfor %}</datalist>
<button class="button" type="submit">Add to inventory</button></form>
<a href="{% url 'food:inventory-add' %}">Choose another product</a>
{% else %}
<form method="get" class="food-search"><label for="inventory-query">Search saved products</label><input id="inventory-query" name="q" type="search" value="{{ query }}" autofocus><button class="button" type="submit">Search</button></form>
<ul class="food-product-list">{% for item in products %}<li><a href="{% url 'food:inventory-add' %}?product={{ item.pk }}">{% if item.image_url %}<img src="{{ item.image_url }}" alt="" loading="lazy">{% endif %}<span><strong>{{ item.product_name }}</strong>{% if item.brand %}<small>{{ item.brand }}</small>{% endif %}</span></a></li>{% empty %}<li>No saved products found.</li>{% endfor %}</ul>
<div class="food-actions"><a class="button" href="{% url 'food:scanner' %}?mode=inventory">Scan barcode</a><a class="button button--secondary" href="{% url 'food:inventory-external' %}?q={{ query|urlencode }}">Search Open Food Facts</a><a class="button button--secondary" href="{% url 'food:inventory-manual' %}">Create manual product</a></div>
<form method="post" action="{% url 'food:inventory-lookup' %}" class="food-barcode-form">{% csrf_token %}<label for="inventory-barcode">Enter barcode</label><input id="inventory-barcode" name="barcode" inputmode="numeric" pattern="[0-9]+" required><button class="button button--secondary" type="submit">Look up</button></form>
{% endif %}</div><script src="{% static 'food/inventory.js' %}" defer></script>{% endblock %}
@@ -0,0 +1,3 @@
{% extends 'planner/base.html' %}{% load static %}
{% block title %}Edit inventory item · Tasknest{% endblock %}
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}"><div class="food-form-page inventory-page"><a href="{% url 'food:inventory' %}">← Kitchen Inventory</a><h1>Edit {{ item.product.product_name }}</h1><form method="post" class="food-card inventory-form">{% csrf_token %}{{ form.non_field_errors }}{% for field in form %}<div class="form-field">{{ field.label_tag }}{% if field.name == 'quantity' %}<div class="inventory-quantity" data-inventory-quantity><button type="button" data-inventory-step="-1" aria-label="Decrease quantity">−</button>{{ field }}<button type="button" data-inventory-step="1" aria-label="Increase quantity">+</button></div>{% else %}{{ field }}{% endif %}{{ field.errors }}</div>{% endfor %}<datalist id="inventory-locations">{% for location in locations %}<option value="{{ location.name }}">{% endfor %}</datalist><datalist id="inventory-categories">{% for category in categories %}<option value="{{ category.name }}">{% endfor %}</datalist><button class="button" type="submit">Save changes</button></form></div><script src="{% static 'food/inventory.js' %}" defer></script>{% endblock %}
@@ -0,0 +1,3 @@
{% extends 'planner/base.html' %}{% load static %}
{% block title %}Search products · Tasknest{% endblock %}
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}"><div class="food-form-page"><a href="{% url 'food:inventory-add' %}">← Add item</a><h1>Search Open Food Facts</h1><form method="post" class="food-search">{% csrf_token %}<label for="inventory-external-query">Product name</label><input id="inventory-external-query" name="q" type="search" value="{{ query }}" required><button class="button" type="submit">Search</button></form>{% if notice %}<p role="status">{{ notice }}</p>{% endif %}<ul class="food-product-list">{% for item in results %}<li><form method="post" action="{% url 'food:inventory-lookup' %}">{% csrf_token %}<input type="hidden" name="barcode" value="{{ item.barcode }}"><button type="submit" class="food-result-button">{% if item.image_url %}<img src="{{ item.image_url }}" alt="" loading="lazy">{% endif %}<span><strong>{{ item.product_name }}</strong>{% if item.brand %}<small>{{ item.brand }}</small>{% endif %}</span></button></form></li>{% empty %}{% if request.method == 'POST' and not notice %}<li>No products found. <a href="{% url 'food:inventory-manual' %}">Create one manually</a>.</li>{% endif %}{% endfor %}</ul><p class="food-attribution">Product data from <a href="https://world.openfoodfacts.org/" rel="noopener noreferrer">Open Food Facts</a>.</p></div>{% endblock %}
@@ -0,0 +1,3 @@
{% extends 'planner/base.html' %}{% load static %}
{% block title %}Create inventory product · Tasknest{% endblock %}
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}"><div class="food-form-page"><a href="{% url 'food:inventory-add' %}">← Add item</a><h1>Create product</h1><p>Save a product to the shared food catalogue. Nutrition can be added later.</p><form method="post" class="food-card inventory-form">{% csrf_token %}{% for field in form %}<div class="form-field">{{ field.label_tag }}{{ field }}{{ field.errors }}</div>{% endfor %}<button class="button" type="submit">Continue to inventory</button></form></div>{% endblock %}
@@ -0,0 +1,6 @@
{% extends 'planner/base.html' %}{% load static %}
{% block title %}Kitchen Inventory · Tasknest{% endblock %}
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}">
<div class="food-page inventory-page"><header class="food-heading"><div><h1>Kitchen Inventory</h1><p>What you have and where it lives.</p></div><a class="button" href="{% url 'food:inventory-add' %}">+ Add item</a></header>
<form method="get" class="food-card inventory-filters"><label>Search<input type="search" name="q" value="{{ query }}"></label><label>Location<select name="location"><option value="">All locations</option>{% for location in locations %}<option value="{{ location.pk }}" {% if selected_location == location.pk|stringformat:'s' %}selected{% endif %}>{{ location.name }}</option>{% endfor %}</select></label><label>Category<select name="category"><option value="">All categories</option>{% for category in categories %}<option value="{{ category.pk }}" {% if selected_category == category.pk|stringformat:'s' %}selected{% endif %}>{{ category.name }}</option>{% endfor %}</select></label><label>Opened<select name="opened"><option value="">All</option><option value="yes" {% if opened == 'yes' %}selected{% endif %}>Opened</option><option value="no" {% if opened == 'no' %}selected{% endif %}>Unopened</option></select></label><label>Sort<select name="sort"><option value="location" {% if sort == 'location' %}selected{% endif %}>Location</option><option value="category" {% if sort == 'category' %}selected{% endif %}>Category</option><option value="name" {% if sort == 'name' %}selected{% endif %}>Product name</option><option value="recent" {% if sort == 'recent' %}selected{% endif %}>Recently added</option><option value="best_before" {% if sort == 'best_before' %}selected{% endif %}>Best before</option></select></label><label class="inventory-check"><input type="checkbox" name="use_soon" value="1" {% if use_soon == '1' %}checked{% endif %}> Use soon</label><button class="button" type="submit">Apply</button></form>
{% for item in items %}{% if sort == 'location' %}{% ifchanged item.location_id %}<h2 class="inventory-group">{{ item.location.name }}</h2>{% endifchanged %}{% endif %}<article class="food-card inventory-row">{% if item.product.image_url %}<img src="{{ item.product.image_url }}" alt="" loading="lazy">{% endif %}<div class="inventory-row-main"><h3>{{ item.product.product_name }}</h3>{% if item.product.brand %}<p>{{ item.product.brand }}</p>{% endif %}<p>Qty: {{ item.quantity }} · {{ item.location.name }}{% if item.category %} · {{ item.category.name }}{% endif %}</p>{% if item.opened %}<span class="inventory-tag">Opened</span>{% endif %}{% if item.best_before %}<span class="inventory-tag {% if item.best_before < today %}inventory-expired{% elif item.best_before <= soon_date %}inventory-soon{% endif %}">{% if item.best_before < today %}Expired{% elif item.best_before <= soon_date %}Use soon{% else %}Best before{% endif %} {{ item.best_before }}</span>{% endif %}</div><div class="inventory-row-actions"><form method="post" action="{% url 'food:inventory-quantity' item.pk %}">{% csrf_token %}<button type="submit" name="action" value="increase" aria-label="Increase quantity of {{ item.product.product_name }}">+1</button><button type="submit" name="action" value="used">Used up</button></form><a href="{% url 'food:inventory-edit' item.pk %}">Edit</a></div></article>{% empty %}<section class="food-card"><p>No inventory items found.</p><a class="button" href="{% url 'food:inventory-add' %}">Add your first item</a></section>{% endfor %}</div>{% endblock %}
+3 -3
View File
@@ -3,19 +3,19 @@
{% block content %}
<link rel="stylesheet" href="{% static 'food/food.css' %}">
<div class="food-scanner" data-food-scanner data-zxing-url="{% static 'food/vendor/zxing-browser.min.js' %}">
<header class="food-scanner-header"><a href="{% url 'food:add' %}?date={{ day|date:'Y-m-d' }}&amp;meal={{ meal }}" data-scanner-close aria-label="Close barcode scanner">×</a><h1>Scan barcode</h1></header>
<header class="food-scanner-header"><a href="{% if inventory_mode %}{% url 'food:inventory-add' %}{% else %}{% url 'food:add' %}?date={{ day|date:'Y-m-d' }}&amp;meal={{ meal }}{% endif %}" data-scanner-close aria-label="Close barcode scanner">×</a><h1>Scan barcode</h1></header>
<p>Point your camera at an EAN or UPC food barcode.</p>
<div class="food-camera-frame"><video data-scanner-video autoplay muted playsinline aria-label="Camera preview"></video><div class="food-scan-guide" aria-hidden="true"></div></div>
<p data-scanner-status role="status" aria-live="polite">Camera is off.</p>
<button class="button" type="button" data-scanner-start>Start camera</button>
<button class="button button--secondary" type="button" data-scanner-stop hidden>Stop camera</button>
<form method="post" action="{% url 'food:import-product' %}" data-scanner-form class="food-barcode-form">
<form method="post" action="{% if inventory_mode %}{% url 'food:inventory-lookup' %}{% else %}{% url 'food:import-product' %}{% endif %}" data-scanner-form class="food-barcode-form">
{% csrf_token %}<input type="hidden" name="date" value="{{ day|date:'Y-m-d' }}"><input type="hidden" name="meal" value="{{ meal }}">
<label for="scanner-barcode">Enter barcode manually</label><input id="scanner-barcode" data-scanner-barcode name="barcode" inputmode="numeric" pattern="[0-9]+" required>
<button class="button button--secondary" type="submit">Look up barcode</button>
</form>
<p class="food-attribution">Product data from <a href="https://world.openfoodfacts.org/" rel="noopener noreferrer">Open Food Facts</a>.</p>
</div>
<nav class="food-mobile-switch" aria-label="Add food method"><a href="{% url 'food:add' %}?date={{ day|date:'Y-m-d' }}&amp;meal={{ meal }}">Search</a><span aria-current="page">Barcode</span></nav>
<nav class="food-mobile-switch" aria-label="Add food method"><a href="{% if inventory_mode %}{% url 'food:inventory-add' %}{% else %}{% url 'food:add' %}?date={{ day|date:'Y-m-d' }}&amp;meal={{ meal }}{% endif %}">Search</a><span aria-current="page">Barcode</span></nav>
<script src="{% static 'food/scanner.js' %}" defer></script>
{% endblock %}