mirror of
https://github.com/shouptech/humulus.git
synced 2026-02-03 15:09:42 +00:00
Adds a recipe type field for recipe form.
This commit is contained in:
parent
221ddbafe0
commit
7505390f52
5 changed files with 20 additions and 2 deletions
|
|
@ -148,6 +148,11 @@ class YeastForm(Form):
|
|||
class RecipeForm(FlaskForm):
|
||||
"""Form for recipes."""
|
||||
name = StringField('Name', validators=[DataRequired()])
|
||||
type = SelectField('Type', default='',
|
||||
choices=[(c, c) for c in ['All-Grain',
|
||||
'Partial Extract',
|
||||
'Extract']],
|
||||
validators=[Optional()])
|
||||
efficiency = DecimalField('Batch Efficiency (%)',
|
||||
validators=[DataRequired()])
|
||||
volume = DecimalField('Batch Volume (gal)', validators=[DataRequired()])
|
||||
|
|
@ -176,6 +181,7 @@ class RecipeForm(FlaskForm):
|
|||
'volume': str(self.volume.data),
|
||||
'notes': self.notes.data,
|
||||
'$type': 'recipe',
|
||||
'type': self.type.data
|
||||
}
|
||||
|
||||
recipe['fermentables'] = [f.doc for f in self.fermentables]
|
||||
|
|
@ -191,6 +197,7 @@ class RecipeForm(FlaskForm):
|
|||
def copyfrom(self, data):
|
||||
"""Copies from a dictionary (data) into the current object"""
|
||||
self.name.data = data['name']
|
||||
self.type.data = data['type']
|
||||
self.efficiency.data = Decimal(data['efficiency'])
|
||||
self.volume.data = Decimal(data['volume'])
|
||||
self.notes.data = data['notes']
|
||||
|
|
|
|||
|
|
@ -26,8 +26,9 @@
|
|||
-#}
|
||||
<div class="row">
|
||||
<div class="col-sm-6">{{ render_field_with_errors(form.name) }}</div>
|
||||
<div class="col-sm-3">{{ render_field_with_errors(form.efficiency, 'ingredient-field') }}</div>
|
||||
<div class="col-sm-3">{{ render_field_with_errors(form.volume, 'ingredient-field') }}</div>
|
||||
<div class="col-sm-2">{{ render_field_with_errors(form.type) }}</div>
|
||||
<div class="col-sm-2">{{ render_field_with_errors(form.efficiency, 'ingredient-field') }}</div>
|
||||
<div class="col-sm-2">{{ render_field_with_errors(form.volume, 'ingredient-field') }}</div>
|
||||
</div>
|
||||
{#-
|
||||
Fermentable Ingredients
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
<div class="row">
|
||||
<div class="col">
|
||||
<dl>
|
||||
<dt>Recipe Type</dt>
|
||||
<dd>{{ recipe.type }}</dd>
|
||||
<dt>Batch Efficiency</dt>
|
||||
<dd>{{ recipe.efficiency|int }}%</dd>
|
||||
<dt>Batch Volume</dt>
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ def app():
|
|||
put_doc({
|
||||
'_id': 'awesome-lager',
|
||||
'$type': 'recipe',
|
||||
'type': 'All-Grain',
|
||||
'efficiency': '65',
|
||||
'name': 'Awesome Lager',
|
||||
'notes': 'Test',
|
||||
|
|
@ -56,6 +57,7 @@ def app():
|
|||
'$type': 'recipe',
|
||||
'efficiency': '75',
|
||||
'name': 'Partial Beer',
|
||||
'type': 'Extract',
|
||||
'notes': 'Contains only required fields for yeast.',
|
||||
'volume': '3.5',
|
||||
'fermentables': [],
|
||||
|
|
@ -70,6 +72,7 @@ def app():
|
|||
'_id': 'full-recipe',
|
||||
'$type': 'recipe',
|
||||
'efficiency': '78',
|
||||
'type': 'All-Grain',
|
||||
'name': 'Awesome Beer',
|
||||
'notes': 'This is a test beer that contains most possible fields.',
|
||||
'volume': '2.5',
|
||||
|
|
@ -160,6 +163,7 @@ def sample_recipes():
|
|||
return {
|
||||
'lager': {
|
||||
'efficiency': '72',
|
||||
'type': 'All-Grain',
|
||||
'fermentables': [
|
||||
{
|
||||
'amount': '9.5',
|
||||
|
|
@ -217,6 +221,7 @@ def sample_recipes():
|
|||
},
|
||||
'sweetstout': {
|
||||
'efficiency': '72',
|
||||
'type': 'All-Grain',
|
||||
'fermentables': [
|
||||
{
|
||||
'amount': '2.75',
|
||||
|
|
|
|||
|
|
@ -253,10 +253,12 @@ def test_recipe_form_doc(app):
|
|||
recipe.efficiency.data = Decimal('65')
|
||||
recipe.volume.data = Decimal('5.5')
|
||||
recipe.notes.data = 'This is a test'
|
||||
recipe.type.data = 'All-Grain'
|
||||
|
||||
assert recipe.doc == {
|
||||
'name': 'Test',
|
||||
'efficiency': '65',
|
||||
'type': 'All-Grain',
|
||||
'volume': '5.5',
|
||||
'notes': 'This is a test',
|
||||
'fermentables': [],
|
||||
|
|
@ -290,6 +292,7 @@ def test_recipe_form_doc(app):
|
|||
assert recipe.doc == {
|
||||
'name': 'Test',
|
||||
'efficiency': '65',
|
||||
'type': 'All-Grain',
|
||||
'volume': '5.5',
|
||||
'notes': 'This is a test',
|
||||
'$type': 'recipe',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue