55 lines
1.1 KiB
Python
55 lines
1.1 KiB
Python
from django.db import models
|
|
|
|
# Create your models here.
|
|
|
|
|
|
class Ingredient(models.Model):
|
|
|
|
name = models.CharField(max_length=255)
|
|
description = models.CharField(max_length=255, blank=True, default="")
|
|
producer = models.ForeignKey("Producer", on_delete=models.CASCADE)
|
|
|
|
class Meta:
|
|
abstract = True
|
|
|
|
|
|
class Producer(models.Model):
|
|
name = models.CharField(max_length=255)
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
|
|
class Yeast(Ingredient):
|
|
UNIT = "g"
|
|
|
|
def __str__(self):
|
|
return f"Yeast: {self.name}"
|
|
|
|
|
|
class Chemical(Ingredient):
|
|
UNIT = "g"
|
|
|
|
def __str__(self):
|
|
return f"Chemical: {self.name}"
|
|
|
|
|
|
class Malt(Ingredient):
|
|
class Type(models.TextChoices):
|
|
DME = "DME", "Dry Malt Extract"
|
|
LME = "LME", "Liquid Malt Extract"
|
|
MALT = "MALT", "Malted Grain"
|
|
|
|
UNIT = "kg"
|
|
|
|
kind = models.CharField(max_length=4, choices=Type)
|
|
|
|
def __str__(self):
|
|
return f"Malt: {self.name}"
|
|
|
|
|
|
class Fermentable(Ingredient):
|
|
UNIT = "kg"
|
|
|
|
def __str__(self):
|
|
return f"Other Fermentable: {self.name}"
|