brewery-website/beer/models.py
Chris Giacofei c3634141a3 Basic outline of yeast sample page.
None of the controls do anything yet.
2024-06-07 07:54:23 -04:00

39 lines
1.2 KiB
Python

from django.db import models
from django.utils import timezone
from config.extras import BREWFATHER_APP_ROOT
import logging
logger = logging.getLogger('django')
class CustomModel(models.Model):
""" Custom model class with default fields to use. """
created_date = models.DateTimeField(default=timezone.now)
class Meta:
abstract = True
class Batch(CustomModel):
brewfather_id = models.CharField(max_length=50)
brewfather_num = models.IntegerField(default=1)
brewfather_name = models.CharField(max_length=500, default='name')
recipe = models.ForeignKey('BatchRecipe', on_delete=models.CASCADE, default=1)
@property
def brewfather_url(self):
return '{}/tabs/batches/batch/{}'.format(BREWFATHER_APP_ROOT, self.brewfather_id)
def __str__(self):
# Return a string that represents the instance
return 'BF #{num}: {name}'.format(name=self.brewfather_name, num=self.brewfather_num)
class BatchRecipe(CustomModel):
""" Recipe to be stored with a batch."""
name = models.CharField(max_length=50)
class Recipe(CustomModel):
""" Recipes not attched to batches."""
name = models.CharField(max_length=50)