diff --git a/kuhkal/routes.py b/kuhkal/routes.py index 2e0edfa..f3e90fd 100644 --- a/kuhkal/routes.py +++ b/kuhkal/routes.py @@ -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/") @@ -57,14 +58,14 @@ def edit_ingredient(id): db.session.flush() db.session.commit() - return "updated" + return redirect("/ingredients") @app.get("/ingredients/delete/") 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/") @@ -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") diff --git a/kuhkal/templates/includes/calculate_form.html b/kuhkal/templates/includes/calculate_form.html index b51d166..bbf6b19 100644 --- a/kuhkal/templates/includes/calculate_form.html +++ b/kuhkal/templates/includes/calculate_form.html @@ -1,9 +1,11 @@
- {% for recipe in data["recipes"] %} {% endfor %} +
diff --git a/kuhkal/templates/includes/edit_ingredient_form.html b/kuhkal/templates/includes/edit_ingredient_form.html index 627e939..5bcbe3f 100644 --- a/kuhkal/templates/includes/edit_ingredient_form.html +++ b/kuhkal/templates/includes/edit_ingredient_form.html @@ -1,11 +1,15 @@
+
- -
+ +
+
- -
-
+
+ +
diff --git a/kuhkal/templates/includes/edit_recipe_form.html b/kuhkal/templates/includes/edit_recipe_form.html index 0db4c29..841438d 100644 --- a/kuhkal/templates/includes/edit_recipe_form.html +++ b/kuhkal/templates/includes/edit_recipe_form.html @@ -1,15 +1,20 @@
+
- -
+ +
{% for ingredient in data["ingredients_inside"] %} - -
+
+ +
{% endfor %}
{% for ingredient in data["ingredients_rest"] %} - -
+
+ +
{% endfor %} - +
+ +
diff --git a/kuhkal/templates/includes/new_ingredient_form.html b/kuhkal/templates/includes/new_ingredient_form.html index d5f3985..a236de5 100644 --- a/kuhkal/templates/includes/new_ingredient_form.html +++ b/kuhkal/templates/includes/new_ingredient_form.html @@ -1,11 +1,13 @@
- - -
- - -
-
diff --git a/kuhkal/templates/includes/new_recipe_form.html b/kuhkal/templates/includes/new_recipe_form.html index f988c54..d87ddb4 100644 --- a/kuhkal/templates/includes/new_recipe_form.html +++ b/kuhkal/templates/includes/new_recipe_form.html @@ -1,10 +1,12 @@
- - -
+
+ + +
{% for ingredient in data["ingredients"] %} - -
+
+ +
{% endfor %} - +
diff --git a/kuhkal/templates/pages/index.html b/kuhkal/templates/pages/index.html index d65705d..e7e2561 100644 --- a/kuhkal/templates/pages/index.html +++ b/kuhkal/templates/pages/index.html @@ -2,9 +2,12 @@ {% block content %}
+ Dodaj recept {% for recipe in data["recipes"] %}
  • {{recipe.recipe.name}}

    + Izmeni + Obrisi