Ulepsane forme
This commit is contained in:
		| @@ -7,6 +7,7 @@ from .utils import get_all_recipes | ||||
|  | ||||
|  | ||||
| @app.get("/") | ||||
| @app.get("/recipes") | ||||
| def index(): | ||||
|     data = {"recipes": get_all_recipes()} | ||||
|     return render_template("pages/index.html", data=data) | ||||
| @@ -36,7 +37,7 @@ def add_new_ingredient(): | ||||
|     except Exception as e: | ||||
|         return "greska, vec postoji sastojak" | ||||
|  | ||||
|     return "napravljeno" | ||||
|     return redirect("/ingredients") | ||||
|  | ||||
|  | ||||
| @app.get("/ingredients/edit/<int:id>") | ||||
| @@ -57,14 +58,14 @@ def edit_ingredient(id): | ||||
|  | ||||
|     db.session.flush() | ||||
|     db.session.commit() | ||||
|     return "updated" | ||||
|     return redirect("/ingredients") | ||||
|  | ||||
|  | ||||
| @app.get("/ingredients/delete/<int:id>") | ||||
| def delete_ingredient(id): | ||||
|     Ingredient.query.filter_by(id=id).delete() | ||||
|     db.session.commit() | ||||
|     return "Deleted" | ||||
|     return redirect("/ingredients") | ||||
|  | ||||
|  | ||||
| # Recipes CRUD | ||||
| @@ -108,7 +109,7 @@ def create_recipe_in_db(): | ||||
|         assoc.ingredient_ammount = ammount | ||||
|     db.session.add(recipe) | ||||
|     db.session.commit() | ||||
|     return "created" | ||||
|     return redirect("/recipes") | ||||
|  | ||||
|  | ||||
| @app.get("/recipes/edit/<int:id>") | ||||
| @@ -165,7 +166,7 @@ def edit_recipe_in_db(id): | ||||
|  | ||||
|     db.session.add(old_recipe) | ||||
|     db.session.commit() | ||||
|     return "ok" | ||||
|     return redirect("/recipes") | ||||
|  | ||||
|  | ||||
| @app.get("/calculate") | ||||
|   | ||||
| @@ -1,9 +1,11 @@ | ||||
| <form @submit.prevent method="POST"> | ||||
| 	<select x-model.number="recipe_id" name="recipe_id"> | ||||
| 	<div class="form-group"> | ||||
| 	<select class="form-control" x-model.number="recipe_id" name="recipe_id"> | ||||
| 		{% for recipe in data["recipes"] %} | ||||
| 			<option value="{{recipe.id}}">{{recipe.name}}</option> | ||||
| 		{% endfor %} | ||||
| 	</select> | ||||
| 	<input @input.debounce.300="getResults()" x-model.number="ammount" type="number" step="1" name="ammount" placeholder="Koliko obroka"> | ||||
| 	</div> | ||||
| 	<!--<button @click="getResults()" type="submit">Izracunaj</button> --> | ||||
| </form> | ||||
|   | ||||
| @@ -1,11 +1,15 @@ | ||||
| <form method="POST"> | ||||
| 	<div class="form-group"> | ||||
| 	<label for="ingredient_name">Naziv</label> | ||||
| 	<input id="ingredient_name" type="text" required name="name" value="{{ingredient.name}}"> | ||||
| 	<br> | ||||
| 	<input class="form-control" id="ingredient_name" type="text" required name="name" value="{{ingredient.name}}"> | ||||
| 	</div> | ||||
| 	<div class="form-group"> | ||||
| 	<label for="ingredient_price">Cena</label> | ||||
| 	<input id="ingredient_price" type="number" required name="price" value="{{ingredient.price}}"> | ||||
| 	<br> | ||||
| 	<button> | ||||
| 	<input class="form-control" id="ingredient_price" type="number" required name="price" value="{{ingredient.price}}"> | ||||
| 	</div> | ||||
| 	<div class="form-group"> | ||||
| 	<button class="btn btn-danger"> | ||||
| 		Dodaj Sastojak | ||||
| 	</button> | ||||
| 	</div> | ||||
| </form> | ||||
|   | ||||
| @@ -1,15 +1,20 @@ | ||||
| <form method="POST"> | ||||
| 	<div class="form-group"> | ||||
| 	<label for="recipe_name">Naziv: </label> | ||||
| 	<input type="text" name="recipe_name" value='{{data["recipe"].name}}'> | ||||
| 	<br> | ||||
| 	<input class="form-control" type="text" name="recipe_name" value='{{data["recipe"].name}}'> | ||||
| 	</div> | ||||
| 	{% for ingredient in data["ingredients_inside"] %} | ||||
| 	<input checked type="checkbox" id="{{ingredient.name}}" name="ingredients" value="{{ingredient.id}}"> <label for="{{ingredient.name}}">{{ingredient.name}}</label> <input type="number" name="{{ingredient.id}}_ammount" placeholder="kg/L" value="{{ingredient.ammount}}"> | ||||
| 	<br> | ||||
| 	<div class="form-group"> | ||||
| 	<input class="form-check-input" checked type="checkbox" id="{{ingredient.name}}" name="ingredients" value="{{ingredient.id}}"> <label class="form-check-label"for="{{ingredient.name}}">{{ingredient.name}}</label> <input class="form-control" type="number" name="{{ingredient.id}}_ammount" placeholder="kg/L" value="{{ingredient.ammount}}"> | ||||
| 	</div> | ||||
| 	{% endfor %} | ||||
| 	<hr> | ||||
| 	{% for ingredient in data["ingredients_rest"] %} | ||||
| 	<input type="checkbox" id="{{ingredient.name}}" name="ingredients" value="{{ingredient.id}}"> <label for="{{ingredient.name}}">{{ingredient.name}}</label> <input type="number" name="{{ingredient.id}}_ammount" placeholder="kg/L"> | ||||
| 	<br> | ||||
| 	<div class="form-group"> | ||||
| 	<input class="form-check-input" type="checkbox" id="{{ingredient.name}}" name="ingredients" value="{{ingredient.id}}"> <label class="form-check-label" for="{{ingredient.name}}">{{ingredient.name}}</label> <input class="form-control" type="number" name="{{ingredient.id}}_ammount" placeholder="kg/L"> | ||||
| 	</div> | ||||
| 	{% endfor %} | ||||
| 	<button>Dodaj recept</button> | ||||
| 	<div class="form-group"> | ||||
| 	<button class="btn btn-danger">Dodaj recept</button> | ||||
| 	</div> | ||||
| </form> | ||||
|   | ||||
| @@ -1,11 +1,13 @@ | ||||
| <form method="POST"> | ||||
| 	<label for="ingredient_name">Naziv</label> | ||||
| 	<input id="ingredient_name" type="text" required name="name" placeholder="Naziv..."> | ||||
| 	<br> | ||||
| 	<label for="ingredient_price">Cena</label> | ||||
| 	<input id="ingredient_price" type="number" required name="price" placeholder="Cena..."> | ||||
| 	<br> | ||||
| 	<button> | ||||
| 	<div class="form-group"> | ||||
| 		<label for="ingredient_name">Naziv</label> | ||||
| 		<input class="form-control" id="ingredient_name" type="text" required name="name" placeholder="Naziv..."> | ||||
| 	</div> | ||||
| 	<div class="form-group"> | ||||
| 		<label for="ingredient_price">Cena</label> | ||||
| 		<input class="form-control" id="ingredient_price" type="number" required name="price" placeholder="Cena..."> | ||||
| 	</div> | ||||
| 	<button class="btn btn-danger"> | ||||
| 		Dodaj Sastojak | ||||
| 	</button> | ||||
| </form> | ||||
|   | ||||
| @@ -1,10 +1,12 @@ | ||||
| <form method="POST"> | ||||
| 	<label for="recipe_name">Naziv: </label> | ||||
| 	<input type="text" name="recipe_name"> | ||||
| 	<br> | ||||
| 	<div class="form-group"> | ||||
| 		<label for="recipe_name">Naziv: </label> | ||||
| 		<input class="form-control" type="text" name="recipe_name"> | ||||
| 	</div> | ||||
| 	{% for ingredient in data["ingredients"] %} | ||||
| 	<input type="checkbox" id="{{ingredient.name}}" name="ingredients" value="{{ingredient.id}}"> <label for="{{ingredient.name}}">{{ingredient.name}}</label> <input step="0.01"type="number" name="{{ingredient.id}}_ammount" placeholder="kg/L"> | ||||
| 	<br> | ||||
| 	<div class="form-group"> | ||||
| 		<input class="form-check-input"type="checkbox" id="{{ingredient.name}}" name="ingredients" value="{{ingredient.id}}"> <label class="form-check-label" for="{{ingredient.name}}">{{ingredient.name}}</label> <input class="form-control" step="0.01" type="number" name="{{ingredient.id}}_ammount" placeholder="kg/L"> | ||||
| 	</div> | ||||
| 	{% endfor %} | ||||
| 	<button>Dodaj recept</button> | ||||
| 	<button class="btn btn-danger">Dodaj recept</button> | ||||
| </form> | ||||
|   | ||||
| @@ -2,9 +2,12 @@ | ||||
|  | ||||
| {% block content %} | ||||
| 	<div class="row"> | ||||
| 		<a href="/recipes/new" class="btn btn-danger">Dodaj recept</a> | ||||
| 	{% for recipe in data["recipes"] %} | ||||
| 		<li> | ||||
| 			<h3>{{recipe.recipe.name}}</h3> | ||||
| 			<a href="/recipes/edit/{{recipe.recipe.id}}" class="btn btn-danger">Izmeni</a> | ||||
| 			<a href="/recipes/delete/{{recipe.recipe.id}}" class="btn btn-dark">Obrisi</a> | ||||
| 	<table class="table"> | ||||
| 			<thead> | ||||
| 				<tr> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user