Set user language to new recipe + cleaning
This commit is contained in:
parent
8b4b788562
commit
03ebbb74fa
12 changed files with 73 additions and 86 deletions
|
|
@ -6,7 +6,6 @@ use axum::{
|
|||
// use tracing::{event, Level};
|
||||
|
||||
use crate::{
|
||||
consts,
|
||||
data::{db, model},
|
||||
html_templates::*,
|
||||
translation::{self, Sentence},
|
||||
|
|
@ -37,21 +36,20 @@ pub async fn edit_recipe(
|
|||
if let Some(recipe) = connection.get_recipe(recipe_id, false).await? {
|
||||
if recipe.user_id == user.id {
|
||||
let recipes = Recipes {
|
||||
published: connection.get_all_published_recipe_titles().await?,
|
||||
published: connection
|
||||
.get_all_published_recipe_titles(tr.current_lang_code(), Some(user.id))
|
||||
.await?,
|
||||
unpublished: connection
|
||||
.get_all_unpublished_recipe_titles(user.id)
|
||||
.await?,
|
||||
current_id: Some(recipe_id),
|
||||
};
|
||||
|
||||
dbg!(&recipe);
|
||||
|
||||
Ok(RecipeEditTemplate {
|
||||
user: Some(user),
|
||||
tr,
|
||||
recipes,
|
||||
recipe,
|
||||
languages: *consts::LANGUAGES,
|
||||
}
|
||||
.into_response())
|
||||
} else {
|
||||
|
|
@ -89,7 +87,12 @@ pub async fn view(
|
|||
}
|
||||
|
||||
let recipes = Recipes {
|
||||
published: connection.get_all_published_recipe_titles().await?,
|
||||
published: connection
|
||||
.get_all_published_recipe_titles(
|
||||
tr.current_lang_code(),
|
||||
user.as_ref().map(|u| u.id),
|
||||
)
|
||||
.await?,
|
||||
unpublished: if let Some(user) = user.as_ref() {
|
||||
connection
|
||||
.get_all_unpublished_recipe_titles(user.id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue