Rename BatchRecipe -> Recipe.

Much better now thanks.
This commit is contained in:
Chris Giacofei 2024-06-20 15:02:17 -04:00
parent ea803ed009
commit 12fca700da
5 changed files with 47 additions and 13 deletions

View File

@ -2,7 +2,7 @@ from django.contrib import admin
from django.utils.html import format_html
from django.apps import apps
from beer.models import Batch, BatchRecipe, Mash, MashStep, \
from beer.models import Batch, Recipe, Mash, MashStep, \
RecipeFermentable, RecipeHop, RecipeMisc, RecipeYeast
from yeast.models import Yeast
@ -34,8 +34,8 @@ class StrainInline(admin.TabularInline):
extra = 1
@admin.register(BatchRecipe)
class BatchRecipeAdmin(admin.ModelAdmin):
@admin.register(Recipe)
class RecipeAdmin(admin.ModelAdmin):
list_display = ['name']
inlines = [
FermentableInline,

View File

@ -0,0 +1,17 @@
# Generated by Django 5.0.6 on 2024-06-20 18:33
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('beer', '0009_batchrecipe_equipment_and_more'),
]
operations = [
migrations.AlterModelOptions(
name='batchrecipe',
options={'verbose_name': 'Recipe', 'verbose_name_plural': 'Recipes'},
),
]

View File

@ -0,0 +1,17 @@
# Generated by Django 5.0.6 on 2024-06-20 18:59
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('beer', '0010_alter_batchrecipe_options'),
]
operations = [
migrations.RenameModel(
old_name='BatchRecipe',
new_name='Recipe',
),
]

View File

@ -33,7 +33,7 @@ class Batch(CustomModel):
brewfather_num = models.IntegerField(default=1)
brewfather_name = models.CharField(max_length=500, default='name')
recipe = models.OneToOneField(
'BatchRecipe', on_delete=models.CASCADE, default=1)
'Recipe', on_delete=models.CASCADE, default=1)
@property
def brewfather_url(self):
@ -93,7 +93,7 @@ class CustomIngredient(CustomModel):
abstract = True
class BatchRecipe(CustomModel):
class Recipe(CustomModel):
""" Recipe to be stored with a batch."""
name = models.CharField(max_length=50)
batch_recipe = models.BooleanField(null=True)
@ -282,7 +282,7 @@ class Fermentable(CustomIngredient):
class RecipeFermentable(CustomModel):
recipe = models.ForeignKey(BatchRecipe, on_delete=models.CASCADE)
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE)
fermentable = models.ForeignKey(Fermentable, on_delete=models.CASCADE)
quantity = models.DecimalField(max_digits=6, decimal_places=4)
@ -328,7 +328,7 @@ class RecipeHop(CustomModel):
4: 'Mash',
5: 'First Wort'
}
recipe = models.ForeignKey(BatchRecipe, on_delete=models.CASCADE)
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE)
hop = models.ForeignKey(Hop, on_delete=models.CASCADE)
quantity = models.DecimalField(max_digits=6, decimal_places=4)
time = models.IntegerField(default=60, validators=[MinValueValidator(0)])
@ -390,7 +390,7 @@ class Misc(CustomIngredient):
class RecipeMisc(CustomModel):
recipe = models.ForeignKey(BatchRecipe, on_delete=models.CASCADE)
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE)
misc = models.ForeignKey(Misc, on_delete=models.CASCADE)
quantity = models.DecimalField(max_digits=6, decimal_places=4)
@ -399,7 +399,7 @@ class RecipeMisc(CustomModel):
class RecipeYeast(CustomModel):
recipe = models.ForeignKey(BatchRecipe, on_delete=models.CASCADE)
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE)
yeast = models.ForeignKey('yeast.Strain', on_delete=models.CASCADE)

View File

@ -1,6 +1,6 @@
from django.shortcuts import render, get_object_or_404
from .models import UserProfile, BatchRecipe, Batch
from .models import UserProfile, Recipe, Batch
from .extras import get_batches
import json
@ -20,7 +20,7 @@ def home(request):
if Batch.objects.filter(brewfather_id=batch['_id']).first() is None:
recipe_name = batch['recipe']['name']
recipe_obj = BatchRecipe(
recipe_obj = Recipe(
name=recipe_name,
batch_recipe=True, recipe_json=json.dumps(batch['recipe'])
)
@ -36,13 +36,13 @@ def home(request):
batch_obj.save()
context = {
'recipes': BatchRecipe.objects.all(),
'recipes': Recipe.objects.all(),
}
return render(request, 'beer/home.html', context)
def view_recipe(request, recipe_id):
recipe = get_object_or_404(BatchRecipe, pk=recipe_id)
recipe = get_object_or_404(Recipe, pk=recipe_id)
context = {
'recipe': recipe,