Fix edit ingredients

This commit is contained in:
Adrian Woźniak 2024-11-14 17:30:44 +01:00
parent a3ccefb118
commit f406d133ab
2 changed files with 5 additions and 4 deletions

View File

@ -10,7 +10,6 @@ use actix_web::HttpMessage;
use actix_web::{get, post, HttpRequest, HttpResponse, Responder}; use actix_web::{get, post, HttpRequest, HttpResponse, Responder};
use askama::Template; use askama::Template;
use askama_actix::TemplateToResponse; use askama_actix::TemplateToResponse;
use itertools::Itertools;
use sea_orm::{ use sea_orm::{
prelude::*, DatabaseTransaction, JoinType, QueryOrder, QuerySelect, TransactionTrait, prelude::*, DatabaseTransaction, JoinType, QueryOrder, QuerySelect, TransactionTrait,
}; };
@ -499,6 +498,7 @@ async fn save_recipe(form: RecipeForm, t: &mut DatabaseTransaction) -> Result<i3
.map(|model| &model.name) .map(|model| &model.name)
.collect::<BTreeSet<_>>(); .collect::<BTreeSet<_>>();
tracing::debug!("Known tag names: {known:?}"); tracing::debug!("Known tag names: {known:?}");
let mut missing = Vec::with_capacity(text_tags.len()); let mut missing = Vec::with_capacity(text_tags.len());
for tag_name in text_tags for tag_name in text_tags
.into_iter() .into_iter()
@ -651,7 +651,7 @@ async fn edit_recipe(
{ {
Ok(Some(recipe)) => recipe, Ok(Some(recipe)) => recipe,
Ok(_) => todo!("index & not found"), Ok(_) => todo!("index & not found"),
Err(err) => { Err(_err) => {
todo!() todo!()
} }
}; };
@ -723,7 +723,7 @@ async fn edit_recipe(
"{} {} {}", "{} {} {}",
ingredient.qty, ingredient.qty,
ingredient.unit, ingredient.unit,
ingredients.get(&ingredient.id)?.name ingredients.get(&ingredient.ingredient_id)?.name
)) ))
}) })
.collect::<Vec<_>>() .collect::<Vec<_>>()
@ -804,6 +804,7 @@ async fn tmp_cleanup() {
let d = tokio::time::Duration::from_secs(10); let d = tokio::time::Duration::from_secs(10);
loop { loop {
tokio::time::sleep(d).await; tokio::time::sleep(d).await;
let _ = std::fs::create_dir_all("/tmp/assets/recipies/images");
// tracing::info!("Starting files cleanup"); // tracing::info!("Starting files cleanup");
let Ok(mut dir) = tokio::fs::read_dir("/tmp/assets/recipies/images").await else { let Ok(mut dir) = tokio::fs::read_dir("/tmp/assets/recipies/images").await else {

View File

@ -78,7 +78,7 @@
<label for="tags" class="flex gap-4"> <label for="tags" class="flex gap-4">
<span class="w-24 shrink-0">Tags:</span> <span class="w-24 shrink-0">Tags:</span>
<input id="tags" name="tags" class="textarea-with-view" value="{{tags}}" /> <input id="tags" name="tags" class="input border border-solid border-gray-200 rounded-lg w-full" value="{{tags}}" />
</label> </label>
<div class="w-full flex gap-4 flex-wrap"> <div class="w-full flex gap-4 flex-wrap">
{% for tag in known_tags %} {% for tag in known_tags %}