Add a way to delete recipe
This commit is contained in:
parent
5ce3391466
commit
31bc31035a
10 changed files with 247 additions and 175 deletions
|
|
@ -33,25 +33,28 @@ pub async fn edit_recipe(
|
|||
Path(recipe_id): Path<i64>,
|
||||
) -> Result<Response> {
|
||||
if let Some(user) = user {
|
||||
let recipe = connection.get_recipe(recipe_id).await?.unwrap();
|
||||
if recipe.user_id == user.id {
|
||||
let recipes = Recipes {
|
||||
published: connection.get_all_published_recipe_titles().await?,
|
||||
unpublished: connection
|
||||
.get_all_unpublished_recipe_titles(user.id)
|
||||
.await?,
|
||||
current_id: Some(recipe_id),
|
||||
};
|
||||
if let Some(recipe) = connection.get_recipe(recipe_id).await? {
|
||||
if recipe.user_id == user.id {
|
||||
let recipes = Recipes {
|
||||
published: connection.get_all_published_recipe_titles().await?,
|
||||
unpublished: connection
|
||||
.get_all_unpublished_recipe_titles(user.id)
|
||||
.await?,
|
||||
current_id: Some(recipe_id),
|
||||
};
|
||||
|
||||
Ok(RecipeEditTemplate {
|
||||
user: Some(user),
|
||||
recipes,
|
||||
recipe,
|
||||
languages: consts::LANGUAGES,
|
||||
Ok(RecipeEditTemplate {
|
||||
user: Some(user),
|
||||
recipes,
|
||||
recipe,
|
||||
languages: consts::LANGUAGES,
|
||||
}
|
||||
.into_response())
|
||||
} else {
|
||||
Ok(MessageTemplate::new("Not allowed to edit this recipe").into_response())
|
||||
}
|
||||
.into_response())
|
||||
} else {
|
||||
Ok(MessageTemplate::new("Not allowed to edit this recipe").into_response())
|
||||
Ok(MessageTemplate::new("Recipe not found").into_response())
|
||||
}
|
||||
} else {
|
||||
Ok(MessageTemplate::new("Not logged in").into_response())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue