Files
Django_TasksApp/main/groceries/templates/groceries/recipe_preview.html
T
2026-10-22 10:32:41 +02:00

4 lines
2.5 KiB
HTML

{% 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 %}