From f406d133abe3b4c852d1f6af247116dd399f9a01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Wo=C5=BAniak?= Date: Thu, 14 Nov 2024 17:30:44 +0100 Subject: [PATCH] Fix edit ingredients --- cooked/src/routes.rs | 7 ++++--- cooked/templates/recipies/update_form.jinja | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cooked/src/routes.rs b/cooked/src/routes.rs index a8c9e4a..7fbc200 100644 --- a/cooked/src/routes.rs +++ b/cooked/src/routes.rs @@ -10,7 +10,6 @@ use actix_web::HttpMessage; use actix_web::{get, post, HttpRequest, HttpResponse, Responder}; use askama::Template; use askama_actix::TemplateToResponse; -use itertools::Itertools; use sea_orm::{ prelude::*, DatabaseTransaction, JoinType, QueryOrder, QuerySelect, TransactionTrait, }; @@ -499,6 +498,7 @@ async fn save_recipe(form: RecipeForm, t: &mut DatabaseTransaction) -> Result>(); tracing::debug!("Known tag names: {known:?}"); + let mut missing = Vec::with_capacity(text_tags.len()); for tag_name in text_tags .into_iter() @@ -651,7 +651,7 @@ async fn edit_recipe( { Ok(Some(recipe)) => recipe, Ok(_) => todo!("index & not found"), - Err(err) => { + Err(_err) => { todo!() } }; @@ -723,7 +723,7 @@ async fn edit_recipe( "{} {} {}", ingredient.qty, ingredient.unit, - ingredients.get(&ingredient.id)?.name + ingredients.get(&ingredient.ingredient_id)?.name )) }) .collect::>() @@ -804,6 +804,7 @@ async fn tmp_cleanup() { let d = tokio::time::Duration::from_secs(10); loop { tokio::time::sleep(d).await; + let _ = std::fs::create_dir_all("/tmp/assets/recipies/images"); // tracing::info!("Starting files cleanup"); let Ok(mut dir) = tokio::fs::read_dir("/tmp/assets/recipies/images").await else { diff --git a/cooked/templates/recipies/update_form.jinja b/cooked/templates/recipies/update_form.jinja index 70bbf6f..cea73b8 100644 --- a/cooked/templates/recipies/update_form.jinja +++ b/cooked/templates/recipies/update_form.jinja @@ -78,7 +78,7 @@
{% for tag in known_tags %}