Current recipe id was not set
This commit is contained in:
parent
812ba9dc3b
commit
9dccd553bc
5 changed files with 28 additions and 12 deletions
|
|
@ -8,9 +8,9 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Recipes {
|
pub struct Recipes {
|
||||||
pub public: Vec<(i64, String)>,
|
public: Vec<(i64, String)>,
|
||||||
pub private: Vec<(i64, String)>,
|
private: Vec<(i64, String)>,
|
||||||
pub current_id: Option<i64>,
|
current_id: Option<i64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Recipes {
|
impl Recipes {
|
||||||
|
|
@ -18,6 +18,7 @@ impl Recipes {
|
||||||
connection: db::Connection,
|
connection: db::Connection,
|
||||||
user: &Option<model::User>,
|
user: &Option<model::User>,
|
||||||
lang: &str,
|
lang: &str,
|
||||||
|
current_id: Option<i64>,
|
||||||
) -> Result<Self, db::DBError> {
|
) -> Result<Self, db::DBError> {
|
||||||
Ok(Recipes {
|
Ok(Recipes {
|
||||||
public: connection
|
public: connection
|
||||||
|
|
@ -28,7 +29,7 @@ impl Recipes {
|
||||||
} else {
|
} else {
|
||||||
vec![]
|
vec![]
|
||||||
},
|
},
|
||||||
current_id: None,
|
current_id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use tracing::{Level, event};
|
|
||||||
use tracing_appender::{
|
use tracing_appender::{
|
||||||
non_blocking::WorkerGuard,
|
non_blocking::WorkerGuard,
|
||||||
rolling::{RollingFileAppender, Rotation},
|
rolling::{RollingFileAppender, Rotation},
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,13 @@ pub async fn recipes_list_fragments(
|
||||||
) -> Result<impl IntoResponse> {
|
) -> Result<impl IntoResponse> {
|
||||||
Ok(Html(
|
Ok(Html(
|
||||||
RecipesListFragmentTemplate {
|
RecipesListFragmentTemplate {
|
||||||
recipes: Recipes::new(connection, &context.user, context.tr.current_lang_code())
|
recipes: Recipes::new(
|
||||||
.await?,
|
connection,
|
||||||
|
&context.user,
|
||||||
|
context.tr.current_lang_code(),
|
||||||
|
current_recipe.current_recipe_id,
|
||||||
|
)
|
||||||
|
.await?,
|
||||||
context,
|
context,
|
||||||
}
|
}
|
||||||
.render()?,
|
.render()?,
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,13 @@ pub async fn home_page(
|
||||||
) -> Result<impl IntoResponse> {
|
) -> Result<impl IntoResponse> {
|
||||||
Ok(Html(
|
Ok(Html(
|
||||||
HomeTemplate {
|
HomeTemplate {
|
||||||
recipes: Recipes::new(connection, &context.user, context.tr.current_lang_code())
|
recipes: Recipes::new(
|
||||||
.await?,
|
connection,
|
||||||
|
&context.user,
|
||||||
|
context.tr.current_lang_code(),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.await?,
|
||||||
context,
|
context,
|
||||||
}
|
}
|
||||||
.render()?,
|
.render()?,
|
||||||
|
|
@ -79,8 +84,13 @@ pub async fn dev_panel(
|
||||||
if context.user.is_some() && context.user.as_ref().unwrap().is_admin {
|
if context.user.is_some() && context.user.as_ref().unwrap().is_admin {
|
||||||
Ok(Html(
|
Ok(Html(
|
||||||
DevPanelTemplate {
|
DevPanelTemplate {
|
||||||
recipes: Recipes::new(connection, &context.user, context.tr.current_lang_code())
|
recipes: Recipes::new(
|
||||||
.await?,
|
connection,
|
||||||
|
&context.user,
|
||||||
|
context.tr.current_lang_code(),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.await?,
|
||||||
context,
|
context,
|
||||||
log,
|
log,
|
||||||
current_log_file: log_file.log_file.clone(),
|
current_log_file: log_file.log_file.clone(),
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ use axum::{
|
||||||
extract::{Extension, Path, State},
|
extract::{Extension, Path, State},
|
||||||
response::{Html, IntoResponse, Redirect, Response},
|
response::{Html, IntoResponse, Redirect, Response},
|
||||||
};
|
};
|
||||||
// use tracing::{event, Level};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Context, Result,
|
Context, Result,
|
||||||
|
|
@ -49,6 +48,7 @@ pub async fn edit(
|
||||||
connection,
|
connection,
|
||||||
&context.user,
|
&context.user,
|
||||||
context.tr.current_lang_code(),
|
context.tr.current_lang_code(),
|
||||||
|
Some(recipe_id),
|
||||||
)
|
)
|
||||||
.await?,
|
.await?,
|
||||||
context,
|
context,
|
||||||
|
|
@ -112,6 +112,7 @@ pub async fn view(
|
||||||
connection,
|
connection,
|
||||||
&context.user,
|
&context.user,
|
||||||
context.tr.current_lang_code(),
|
context.tr.current_lang_code(),
|
||||||
|
Some(recipe_id),
|
||||||
)
|
)
|
||||||
.await?,
|
.await?,
|
||||||
context,
|
context,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue