Just PEP8 stuff.

This commit is contained in:
Chris Giacofei 2024-06-26 14:56:20 -04:00
parent e8c9196fc0
commit 53b7a1b128
2 changed files with 19 additions and 12 deletions

View File

@ -7,7 +7,6 @@ from beer.models import Batch, Recipe, Mash, MashStep, \
from yeast.models import Yeast from yeast.models import Yeast
from config.extras import BREWFATHER_APP_ROOT from config.extras import BREWFATHER_APP_ROOT
from beer.extras import plato_sg
class SampleInline(admin.TabularInline): class SampleInline(admin.TabularInline):

View File

@ -44,13 +44,13 @@ class Batch(CustomModel):
# Brewday Measurements # Brewday Measurements
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
## Mash # Mash
first_runnings = models.DecimalField( first_runnings = models.DecimalField(
max_digits=8, decimal_places=4, null=True, blank=True) max_digits=8, decimal_places=4, null=True, blank=True)
mash_ph = models.DecimalField( mash_ph = models.DecimalField(
max_digits=4, decimal_places=3, null=True, blank=True) max_digits=4, decimal_places=3, null=True, blank=True)
## Boil # Boil
pre_boil_vol = models.DecimalField( pre_boil_vol = models.DecimalField(
max_digits=8, decimal_places=4, null=True, blank=True) max_digits=8, decimal_places=4, null=True, blank=True)
pre_boil_sg = models.DecimalField( pre_boil_sg = models.DecimalField(
@ -60,7 +60,7 @@ class Batch(CustomModel):
post_boil_sg = models.DecimalField( post_boil_sg = models.DecimalField(
max_digits=5, decimal_places=4, null=True, blank=True) max_digits=5, decimal_places=4, null=True, blank=True)
## Ferment # Ferment
fermenter_topup_vol = models.DecimalField( fermenter_topup_vol = models.DecimalField(
max_digits=8, decimal_places=4, null=True, blank=True) max_digits=8, decimal_places=4, null=True, blank=True)
fermenter_vol = models.DecimalField( fermenter_vol = models.DecimalField(
@ -70,11 +70,11 @@ class Batch(CustomModel):
final_sg = models.DecimalField( final_sg = models.DecimalField(
max_digits=5, decimal_places=4, null=True, blank=True) max_digits=5, decimal_places=4, null=True, blank=True)
# Properties Needed: (https://braukaiser.com/wiki/index.php/Troubleshooting_Brewhouse_Efficiency) # Properties Needed:
# braukaiser.com/wiki/index.php/Troubleshooting_Brewhouse_Efficiency
# - Mash Efficiency # - Mash Efficiency
# - ABV # - ABV
# - Attenuation # - Attenuation
# - Actual Boil-Off Rate
# - Actual Trub/Chiller Loss # - Actual Trub/Chiller Loss
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
@ -83,7 +83,7 @@ class Batch(CustomModel):
@property @property
def brewhouse_efficiency(self): def brewhouse_efficiency(self):
try: try:
return round(self.boil_extract_kg/self.recipe.total_extract_kg,4) return round(self.boil_extract_kg/self.recipe.total_extract_kg, 4)
except ZeroDivisionError: except ZeroDivisionError:
return 0 return 0
@ -94,17 +94,23 @@ class Batch(CustomModel):
@property @property
def conversion_efficiency(self): def conversion_efficiency(self):
""" Calculate conversion efficiency of mash.""" """ Calculate conversion efficiency of mash."""
if self.first_runnings is None or self.recipe.fermentable_weight_kg == 0: if (self.first_runnings is None
or self.recipe.fermentable_weight_kg == 0):
return '-' return '-'
return round((sg_plato(self.first_runnings)/self.recipe.fw_max) return round((sg_plato(self.first_runnings)/self.recipe.fw_max)
* (100-self.recipe.fw_max) / (100-sg_plato(self.first_runnings)) * (100-self.recipe.fw_max)
, 4) / (100-sg_plato(self.first_runnings)), 4)
@property @property
def boil_off_calcualted(self): def boil_off_calcualted(self):
return float(self.pre_boil_vol - self.post_boil_vol) * .96 return float(self.pre_boil_vol - self.post_boil_vol) * .96
@property
def trub_loss_calculated(self):
transfered_volume = self.fermenter_vol - self.fermenter_topup_vol
return self.post_boil_vol-transfered_volume
@property @property
def brewfather_url(self): def brewfather_url(self):
return '{}/tabs/batches/batch/{}'.format( return '{}/tabs/batches/batch/{}'.format(
@ -392,7 +398,8 @@ class Fermentable(CustomIngredient):
@property @property
def extract_percent(self): def extract_percent(self):
return ((float(self.potential)-1)*1000/46.17) * (1-float(self.moisture)/100) return (((float(self.potential)-1)*1000/46.17)
* (1-float(self.moisture)/100))
def __str__(self): def __str__(self):
return self.name return self.name
@ -485,7 +492,8 @@ class RecipeHop(CustomModel):
+ (self.recipe.original_sg-1)) / 2) + (self.recipe.original_sg-1)) / 2)
if self.use == 1: if self.use == 1:
conc = (float((self.hop.alpha/100)) * float(self.quantity)*0.0352739619 conc = (float(self.hop.alpha/100)
* convert(self.quantity, 'g', 'oz')
* 7490/convert(self.recipe.final_volume, 'l', 'gal')) * 7490/convert(self.recipe.final_volume, 'l', 'gal'))
util = (hop_bonus*1.65*0.000125**average_wort_sg util = (hop_bonus*1.65*0.000125**average_wort_sg
* ((1-2.71828182845904**(-0.04*self.time)) / 4.15)) * ((1-2.71828182845904**(-0.04*self.time)) / 4.15))