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 $to == jenseluc@oregonstate.edu
$subject == whole wheat loaf $subject == White Bread SD Conversion
$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; $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 = request.files['photo']
f.save(os.path.join('static', f"image_{_id}.jpg")) f.save(os.path.join('static', f"image_{_id}.jpg"))
# return "Success" # 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: else:
# user wants to download a pdf # user wants to download a pdf
path = write_txt(_id) path = write_txt(_id)

View File

@@ -172,6 +172,24 @@ class Recipe:
return scaled_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(): def default_recipes():
"""Adds some sample data""" """Adds some sample data"""
@@ -203,3 +221,5 @@ if __name__ == "__main__":
book = RecipeBook() book = RecipeBook()
for recipe in recipes: for recipe in recipes:
book.add_recipe(recipe) 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": { "2": {
"quantity": "1", "quantity": "1",
"name": "Sandwich Loaf", "name": "Sandwich Loaf",
@@ -25,16 +12,29 @@
"Starter": 0 "Starter": 0
} }
}, },
"1": { "0": {
"quantity": "1", "quantity": "1",
"name": "tobi", "name": "Country Brown Loaf",
"ingredients": { "ingredients": {
"AP Flour": 100, "AP Flour": 300,
"WW Flour": 0, "WW Flour": 150,
"Rye Flour": 0, "Rye Flour": 50,
"Water": 0, "Water": 300,
"Salt": 0, "Salt": 12,
"Yeast": 0, "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 "Starter": 0
} }
} }

View File

@@ -12,16 +12,29 @@
<p>Number of loaves: {{ content.get_num_loaves() }}</p> <p>Number of loaves: {{ content.get_num_loaves() }}</p>
<table> <table>
<tr> <tr>
<th>Ingredient</th> <td>
<th>Grams</th> <table>
</tr> <tr>
{% for item in content.get_ingredients() %} <th>Ingredient</th>
<tr> <th>Grams</th>
<td>{{ item }}</td> </tr>
<td>{{ content.get_ingredients()[item] }}</td> {% for item in content.get_ingredients() %}
</tr> <tr>
{% endfor %} <td>{{ item }}</td>
<td>{{ content.get_ingredients()[item] }}</td>
</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> </table>
<h2>Scaling</h2> <h2>Scaling</h2>
@@ -31,10 +44,19 @@
<button type="submit">Go!</button> <button type="submit">Go!</button>
</form> </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"> <form name="photo upload" id="photo upload" method="post" enctype="multipart/form-data">
<label for="photo">Upload a Photo: </label> <label for="photo">Upload a Photo: </label>
<input id="photo" type="file" name="photo"> <input required id="photo" type="file" name="photo">
<input type="submit"> <button type="submit">Upload</button>
</form> </form>
<input type="button" onclick="location.href='/recipes/{{_id}}/delete'" value=Delete /> <input type="button" onclick="location.href='/recipes/{{_id}}/delete'" value=Delete />
@@ -45,13 +67,7 @@
<a href="/recipes/{{_id}}/email">Email me!</a> <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 %} {% endblock %}