Final commit for Demo

This commit is contained in:
Lucas Jensen
2022-06-01 20:08:58 -07:00
parent c474aaae3f
commit a446be7e8b
6 changed files with 84 additions and 44 deletions

View File

@@ -1,3 +1,3 @@
$to == jenseluc@oregonstate.edu
$subject == whole wheat loaf
$message == whole wheat loaf; Num loaves: 1; AP Flour: 100 grams; WW Flour: 400 grams; Rye Flour: 0 grams; Water: 300 grams; Salt: 20 grams; Yeast: 2 grams; Starter: 10 grams;
$subject == White Bread SD Conversion
$message == White Bread SD Conversion; Num loaves: 2; AP Flour: 790 grams; WW Flour: 90 grams; Rye Flour: 95 grams; Water: 625 grams; Salt: 25 grams; Yeast: 0 grams; Starter: 50 grams;

View File

@@ -71,7 +71,11 @@ def recipe_page(_id):
f = request.files['photo']
f.save(os.path.join('static', f"image_{_id}.jpg"))
# return "Success"
elif 'convert' in request.form:
# user wants to convert to sourdough
new_recipe = recipe.convert()
book.add_recipe(new_recipe)
return redirect('/recipes')
else:
# user wants to download a pdf
path = write_txt(_id)

View File

@@ -172,6 +172,24 @@ class Recipe:
return scaled_recipe
def convert(self) -> object:
"""
converts a conventional recipe into a sourdough recipe
:return: the newly converted recipe object
"""
new_recipe = Recipe(f"{self._name} SD Conversion", self._num_loaves)
new_recipe._ingredients = {
'AP Flour': self._ingredients['AP Flour'] - 10,
'WW Flour': self._ingredients['WW Flour'] - 10,
'Rye Flour': self._ingredients['Rye Flour'] - 5,
'Water': self._ingredients['Water'] - 25,
'Salt': self._ingredients['Salt'],
'Yeast': 0,
'Starter': 50}
return new_recipe
def default_recipes():
"""Adds some sample data"""
@@ -203,3 +221,5 @@ if __name__ == "__main__":
book = RecipeBook()
for recipe in recipes:
book.add_recipe(recipe)
recipe = book.find_by_id(1)

View File

@@ -1 +1 @@
0
recipe2.pdf

View File

@@ -1,17 +1,4 @@
{
"0": {
"quantity": "2",
"name": "Sourdough",
"ingredients": {
"AP Flour": 500,
"WW Flour": 500,
"Rye Flour": 0,
"Water": 0,
"Salt": 0,
"Yeast": 0,
"Starter": 0
}
},
"2": {
"quantity": "1",
"name": "Sandwich Loaf",
@@ -25,16 +12,29 @@
"Starter": 0
}
},
"1": {
"0": {
"quantity": "1",
"name": "tobi",
"name": "Country Brown Loaf",
"ingredients": {
"AP Flour": 100,
"WW Flour": 0,
"Rye Flour": 0,
"Water": 0,
"Salt": 0,
"Yeast": 0,
"AP Flour": 300,
"WW Flour": 150,
"Rye Flour": 50,
"Water": 300,
"Salt": 12,
"Yeast": 10,
"Starter": 0
}
},
"1": {
"quantity": "2",
"name": "White Bread",
"ingredients": {
"AP Flour": 800,
"WW Flour": 100,
"Rye Flour": 100,
"Water": 650,
"Salt": 25,
"Yeast": 15,
"Starter": 0
}
}

View File

@@ -11,6 +11,9 @@
<p>Number of loaves: {{ content.get_num_loaves() }}</p>
<table>
<tr>
<td>
<table>
<tr>
<th>Ingredient</th>
@@ -23,6 +26,16 @@
</tr>
{% endfor %}
</table>
</td>
<td>
<div style="padding-left: 50px">
{% for photo in photos %}
<img src="{{ url_for('static', filename=photo) }}" width="250" alt="bread photo">
{% endfor %}
</div>
</td>
</tr>
</table>
<h2>Scaling</h2>
<form method="post">
@@ -31,10 +44,19 @@
<button type="submit">Go!</button>
</form>
{% if content._ingredients['Starter'] == 0 %}
<form method="post">
<input type="text" hidden name="convert">
<button type="submit" value="convert">Convert to SD</button>
</form>
{% endif %}
<form name="photo upload" id="photo upload" method="post" enctype="multipart/form-data">
<label for="photo">Upload a Photo: </label>
<input id="photo" type="file" name="photo">
<input type="submit">
<input required id="photo" type="file" name="photo">
<button type="submit">Upload</button>
</form>
<input type="button" onclick="location.href='/recipes/{{_id}}/delete'" value=Delete />
@@ -45,13 +67,7 @@
<a href="/recipes/{{_id}}/email">Email me!</a>
<div>
<!--<p>Photos: {{photos}}</p>-->
{% for photo in photos %}
<!-- <p>{{photo}}</p>-->
<img src="{{ url_for('static', filename=photo) }}" width="250" alt="bread photo">
{% endfor %}
</div>
{% endblock %}