Recipes phase 4

This commit is contained in:
Joren de Graaf
2026-10-12 10:00:02 +02:00
parent b0e95c62f5
commit 2a888e5346
17 changed files with 590 additions and 5 deletions
+25 -1
View File
@@ -1,4 +1,4 @@
"""Owned, structured recipes. Calculations and cooking workflows arrive in later passes."""
"""Owned, structured recipes and audited cooking actions."""
import uuid
from decimal import Decimal
@@ -209,3 +209,27 @@ class RecipeUseLine(models.Model):
recipe_use = models.ForeignKey(RecipeUse, on_delete=models.CASCADE, related_name='lines')
consumption = models.OneToOneField('food.InventoryConsumption', on_delete=models.PROTECT,
related_name='recipe_use_line')
class RecipeCookingRun(models.Model):
"""A confirmed cooking completion; each selected action is recorded at most once."""
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
recipe = models.ForeignKey(Recipe, on_delete=models.SET_NULL, null=True, related_name='cooking_runs')
recipe_title_snapshot = models.CharField(max_length=180)
prepared_servings = models.DecimalField(max_digits=7, decimal_places=2)
consumed_servings = models.DecimalField(max_digits=10, decimal_places=3, null=True, blank=True)
request_signature = models.CharField(max_length=64)
nutrition_snapshot = models.JSONField(default=dict)
ingredient_snapshot = models.JSONField(default=list)
food_entry = models.OneToOneField('food.FoodLogEntry', on_delete=models.SET_NULL,
null=True, blank=True, related_name='recipe_cooking_run')
stock_use = models.OneToOneField(RecipeUse, on_delete=models.SET_NULL,
null=True, blank=True, related_name='cooking_run')
food_logged_at = models.DateTimeField(null=True, blank=True)
stock_used_at = models.DateTimeField(null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
ordering = ('-created_at',)