Recipes phase 3

This commit is contained in:
Joren de Graaf
2026-10-12 09:37:04 +02:00
parent 13cd65622e
commit b0e95c62f5
15 changed files with 788 additions and 13 deletions
@@ -0,0 +1,75 @@
# Generated by Django 6.1.1 on 2026-10-11 23:56
import django.core.validators
import django.db.models.deletion
import uuid
from decimal import Decimal
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('food', '0009_backfill_food_hydration'),
('recipes', '0002_recipe_markdown_revision'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.AddField(
model_name='recipe',
name='yield_amount',
field=models.DecimalField(blank=True, decimal_places=3, max_digits=10, null=True, validators=[django.core.validators.MinValueValidator(Decimal('0.001'))]),
),
migrations.AddField(
model_name='recipe',
name='yield_unit',
field=models.CharField(blank=True, choices=[('g', 'g'), ('ml', 'ml')], max_length=2),
),
migrations.AddField(
model_name='recipeingredient',
name='amount_per_unit',
field=models.DecimalField(blank=True, decimal_places=3, max_digits=10, null=True, validators=[django.core.validators.MinValueValidator(Decimal('0.001'))]),
),
migrations.AddField(
model_name='recipeingredient',
name='amount_per_unit_unit',
field=models.CharField(blank=True, choices=[('g', 'g'), ('ml', 'ml')], max_length=2),
),
migrations.AddField(
model_name='recipeingredientsubstitution',
name='amount_per_unit',
field=models.DecimalField(blank=True, decimal_places=3, max_digits=10, null=True, validators=[django.core.validators.MinValueValidator(Decimal('0.001'))]),
),
migrations.AddField(
model_name='recipeingredientsubstitution',
name='amount_per_unit_unit',
field=models.CharField(blank=True, choices=[('g', 'g'), ('ml', 'ml')], max_length=2),
),
migrations.CreateModel(
name='RecipeUse',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('recipe_title_snapshot', models.CharField(max_length=180)),
('servings', models.DecimalField(decimal_places=2, max_digits=7)),
('request_signature', models.CharField(max_length=64)),
('plan_snapshot', models.JSONField(default=dict)),
('created_at', models.DateTimeField(auto_now_add=True)),
('undone_at', models.DateTimeField(blank=True, null=True)),
('recipe', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='stock_uses', to='recipes.recipe')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ('-created_at',),
},
),
migrations.CreateModel(
name='RecipeUseLine',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('consumption', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, related_name='recipe_use_line', to='food.inventoryconsumption')),
('recipe_use', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lines', to='recipes.recipeuse')),
],
),
]