Compare commits
2 Commits
dd9ae6cd21
...
12fca700da
Author | SHA1 | Date | |
---|---|---|---|
12fca700da | |||
ea803ed009 |
@ -2,7 +2,7 @@ from django.contrib import admin
|
|||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
from django.apps import apps
|
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
|
RecipeFermentable, RecipeHop, RecipeMisc, RecipeYeast
|
||||||
from yeast.models import Yeast
|
from yeast.models import Yeast
|
||||||
|
|
||||||
@ -34,8 +34,8 @@ class StrainInline(admin.TabularInline):
|
|||||||
extra = 1
|
extra = 1
|
||||||
|
|
||||||
|
|
||||||
@admin.register(BatchRecipe)
|
@admin.register(Recipe)
|
||||||
class BatchRecipeAdmin(admin.ModelAdmin):
|
class RecipeAdmin(admin.ModelAdmin):
|
||||||
list_display = ['name']
|
list_display = ['name']
|
||||||
inlines = [
|
inlines = [
|
||||||
FermentableInline,
|
FermentableInline,
|
||||||
|
17
beer/migrations/0010_alter_batchrecipe_options.py
Normal file
17
beer/migrations/0010_alter_batchrecipe_options.py
Normal 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'},
|
||||||
|
),
|
||||||
|
]
|
17
beer/migrations/0011_rename_batchrecipe_recipe.py
Normal file
17
beer/migrations/0011_rename_batchrecipe_recipe.py
Normal 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',
|
||||||
|
),
|
||||||
|
]
|
@ -33,7 +33,7 @@ class Batch(CustomModel):
|
|||||||
brewfather_num = models.IntegerField(default=1)
|
brewfather_num = models.IntegerField(default=1)
|
||||||
brewfather_name = models.CharField(max_length=500, default='name')
|
brewfather_name = models.CharField(max_length=500, default='name')
|
||||||
recipe = models.OneToOneField(
|
recipe = models.OneToOneField(
|
||||||
'BatchRecipe', on_delete=models.CASCADE, default=1)
|
'Recipe', on_delete=models.CASCADE, default=1)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def brewfather_url(self):
|
def brewfather_url(self):
|
||||||
@ -93,7 +93,7 @@ class CustomIngredient(CustomModel):
|
|||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
|
|
||||||
class BatchRecipe(CustomModel):
|
class Recipe(CustomModel):
|
||||||
""" Recipe to be stored with a batch."""
|
""" Recipe to be stored with a batch."""
|
||||||
name = models.CharField(max_length=50)
|
name = models.CharField(max_length=50)
|
||||||
batch_recipe = models.BooleanField(null=True)
|
batch_recipe = models.BooleanField(null=True)
|
||||||
@ -282,7 +282,7 @@ class Fermentable(CustomIngredient):
|
|||||||
|
|
||||||
|
|
||||||
class RecipeFermentable(CustomModel):
|
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)
|
fermentable = models.ForeignKey(Fermentable, on_delete=models.CASCADE)
|
||||||
quantity = models.DecimalField(max_digits=6, decimal_places=4)
|
quantity = models.DecimalField(max_digits=6, decimal_places=4)
|
||||||
|
|
||||||
@ -328,7 +328,7 @@ class RecipeHop(CustomModel):
|
|||||||
4: 'Mash',
|
4: 'Mash',
|
||||||
5: 'First Wort'
|
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)
|
hop = models.ForeignKey(Hop, on_delete=models.CASCADE)
|
||||||
quantity = models.DecimalField(max_digits=6, decimal_places=4)
|
quantity = models.DecimalField(max_digits=6, decimal_places=4)
|
||||||
time = models.IntegerField(default=60, validators=[MinValueValidator(0)])
|
time = models.IntegerField(default=60, validators=[MinValueValidator(0)])
|
||||||
@ -390,7 +390,7 @@ class Misc(CustomIngredient):
|
|||||||
|
|
||||||
|
|
||||||
class RecipeMisc(CustomModel):
|
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)
|
misc = models.ForeignKey(Misc, on_delete=models.CASCADE)
|
||||||
quantity = models.DecimalField(max_digits=6, decimal_places=4)
|
quantity = models.DecimalField(max_digits=6, decimal_places=4)
|
||||||
|
|
||||||
@ -399,7 +399,7 @@ class RecipeMisc(CustomModel):
|
|||||||
|
|
||||||
|
|
||||||
class RecipeYeast(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)
|
yeast = models.ForeignKey('yeast.Strain', on_delete=models.CASCADE)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from django.shortcuts import render, get_object_or_404
|
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
|
from .extras import get_batches
|
||||||
|
|
||||||
import json
|
import json
|
||||||
@ -20,7 +20,7 @@ def home(request):
|
|||||||
if Batch.objects.filter(brewfather_id=batch['_id']).first() is None:
|
if Batch.objects.filter(brewfather_id=batch['_id']).first() is None:
|
||||||
recipe_name = batch['recipe']['name']
|
recipe_name = batch['recipe']['name']
|
||||||
|
|
||||||
recipe_obj = BatchRecipe(
|
recipe_obj = Recipe(
|
||||||
name=recipe_name,
|
name=recipe_name,
|
||||||
batch_recipe=True, recipe_json=json.dumps(batch['recipe'])
|
batch_recipe=True, recipe_json=json.dumps(batch['recipe'])
|
||||||
)
|
)
|
||||||
@ -36,13 +36,13 @@ def home(request):
|
|||||||
batch_obj.save()
|
batch_obj.save()
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'recipes': BatchRecipe.objects.all(),
|
'recipes': Recipe.objects.all(),
|
||||||
}
|
}
|
||||||
return render(request, 'beer/home.html', context)
|
return render(request, 'beer/home.html', context)
|
||||||
|
|
||||||
|
|
||||||
def view_recipe(request, recipe_id):
|
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 = {
|
context = {
|
||||||
'recipe': recipe,
|
'recipe': recipe,
|
||||||
|
4
run.sh
4
run.sh
@ -1,5 +1,7 @@
|
|||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
source .env/bin/activate
|
source .env/bin/activate
|
||||||
pip install --upgrade -r requirements.txt
|
pip install --upgrade -r requirements.txt > /dev/null
|
||||||
|
python manage.py makemigrations
|
||||||
|
python manage.py migrate
|
||||||
python manage.py runserver 0.0.0.0:9595
|
python manage.py runserver 0.0.0.0:9595
|
||||||
|
Loading…
Reference in New Issue
Block a user