From 8b4b7885628e99ed3e41de8986cdff03b131fa18 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Mon, 6 Jan 2025 19:51:19 +0100 Subject: [PATCH] Translation of the recipe edit page --- backend/{askama.toml => rinja.toml} | 0 backend/src/data/db/user.rs | 1 - backend/src/data/model.rs | 10 ++-- backend/src/services/recipe.rs | 2 + backend/src/translation.rs | 25 ++++++++++ backend/templates/recipe_edit.html | 77 +++++++++++------------------ backend/translation.ron | 50 +++++++++++++++++++ 7 files changed, 112 insertions(+), 53 deletions(-) rename backend/{askama.toml => rinja.toml} (100%) diff --git a/backend/askama.toml b/backend/rinja.toml similarity index 100% rename from backend/askama.toml rename to backend/rinja.toml diff --git a/backend/src/data/db/user.rs b/backend/src/data/db/user.rs index 53a62c1..b960379 100644 --- a/backend/src/data/db/user.rs +++ b/backend/src/data/db/user.rs @@ -7,7 +7,6 @@ use crate::{ consts, data::model, hash::{hash, verify_password}, - services::user, }; #[derive(Debug)] diff --git a/backend/src/data/model.rs b/backend/src/data/model.rs index d38db56..c1aed25 100644 --- a/backend/src/data/model.rs +++ b/backend/src/data/model.rs @@ -10,14 +10,14 @@ pub struct User { pub lang: String, } -#[derive(FromRow)] +#[derive(Debug, FromRow)] pub struct UserLoginInfo { pub last_login_datetime: DateTime, pub ip: String, pub user_agent: String, } -#[derive(FromRow)] +#[derive(Debug, FromRow)] pub struct Recipe { pub id: i64, pub user_id: i64, @@ -36,7 +36,7 @@ pub struct Recipe { pub groups: Vec, } -#[derive(FromRow)] +#[derive(Debug, FromRow)] pub struct Group { pub id: i64, pub name: String, @@ -46,7 +46,7 @@ pub struct Group { pub steps: Vec, } -#[derive(FromRow)] +#[derive(Debug, FromRow)] pub struct Step { pub id: i64, pub action: String, @@ -55,7 +55,7 @@ pub struct Step { pub ingredients: Vec, } -#[derive(FromRow)] +#[derive(Debug, FromRow)] pub struct Ingredient { pub id: i64, pub name: String, diff --git a/backend/src/services/recipe.rs b/backend/src/services/recipe.rs index 7367d40..6d1e0cd 100644 --- a/backend/src/services/recipe.rs +++ b/backend/src/services/recipe.rs @@ -44,6 +44,8 @@ pub async fn edit_recipe( current_id: Some(recipe_id), }; + dbg!(&recipe); + Ok(RecipeEditTemplate { user: Some(user), tr, diff --git a/backend/src/translation.rs b/backend/src/translation.rs index ccf22c8..2049ac2 100644 --- a/backend/src/translation.rs +++ b/backend/src/translation.rs @@ -80,6 +80,31 @@ pub enum Sentence { RecipeNotAllowedToEdit, RecipeNotAllowedToView, RecipeNotFound, + RecipeTitle, + RecipeDescription, + RecipeServings, + RecipeEstimatedTime, + RecipeDifficulty, + RecipeDifficultyEasy, + RecipeDifficultyMedium, + RecipeDifficultyHard, + RecipeTags, + RecipeLanguage, + RecipeIsPublished, + RecipeDelete, + RecipeAddAGroup, + RecipeRemoveGroup, + RecipeGroupName, + RecipeGroupComment, + RecipeAddAStep, + RecipeRemoveStep, + RecipeStepAction, + RecipeAddAnIngredient, + RecipeRemoveIngredient, + RecipeIngredientName, + RecipeIngredientQuantity, + RecipeIngredientUnit, + RecipeIngredientComment, } #[derive(Clone)] diff --git a/backend/templates/recipe_edit.html b/backend/templates/recipe_edit.html index 529457f..be5a91c 100644 --- a/backend/templates/recipe_edit.html +++ b/backend/templates/recipe_edit.html @@ -9,64 +9,47 @@ {% block content %}
- + - + - + - {% endmatch %}"/> - - + + {% endif %}"/> - + -
- +
- + +
- +
- + - + - +
- +
- + - +
- +
- + - + - + - + - +
diff --git a/backend/translation.ron b/backend/translation.ron index 4ed85ca..ab0ad78 100644 --- a/backend/translation.ron +++ b/backend/translation.ron @@ -68,6 +68,31 @@ RecipeNotAllowedToEdit: "Not allowed to edit this recipe", RecipeNotAllowedToView: "Not allowed the view the recipe {}", RecipeNotFound: "Recipe not found", + RecipeTitle : "Title", + RecipeDescription : "Description", + RecipeServings : "Servings", + RecipeEstimatedTime : "Estimated time [min]", + RecipeDifficulty : "Difficulty", + RecipeDifficultyEasy : "Easy", + RecipeDifficultyMedium : "Medium", + RecipeDifficultyHard : "Hard", + RecipeTags : "Tags", + RecipeLanguage : "Language", + RecipeIsPublished : "Is published", + RecipeDelete : "Delete recipe", + RecipeAddAGroup : "Add a group", + RecipeRemoveGroup : "Remove group", + RecipeGroupName : "Name", + RecipeGroupComment : "Comment", + RecipeAddAStep : "Add a step", + RecipeRemoveStep : "Remove step", + RecipeStepAction : "Action", + RecipeAddAnIngredient : "Add an ingredient", + RecipeRemoveIngredient : "Remove ingredient", + RecipeIngredientName : "Name", + RecipeIngredientQuantity : "Quantity", + RecipeIngredientUnit : "Unit", + RecipeIngredientComment : "Comment", } ), ( @@ -139,6 +164,31 @@ RecipeNotAllowedToEdit: "Vous n'êtes pas autorisé à éditer cette recette", RecipeNotAllowedToView: "Vous n'êtes pas autorisé à voir la recette {}", RecipeNotFound: "Recette non-trouvée", + RecipeTitle : "Titre", + RecipeDescription : "Description", + RecipeServings : "Nombre de personnes", + RecipeEstimatedTime : "Temps estimé", + RecipeDifficulty : "Difficulté", + RecipeDifficultyEasy : "Facile", + RecipeDifficultyMedium : "Moyen", + RecipeDifficultyHard : "Difficile", + RecipeTags : "Tags", + RecipeLanguage : "Langue", + RecipeIsPublished : "Est publié", + RecipeDelete : "Supprimer la recette", + RecipeAddAGroup : "Ajouter un groupe", + RecipeRemoveGroup : "Supprimer le groupe", + RecipeGroupName : "Nom", + RecipeGroupComment : "Commentaire", + RecipeAddAStep : "Ajouter une étape", + RecipeRemoveStep : "Supprimer l'étape", + RecipeStepAction : "Action", + RecipeAddAnIngredient : "Ajouter un ingrédient", + RecipeRemoveIngredient : "Supprimer l'ingrédient", + RecipeIngredientName : "Nom", + RecipeIngredientQuantity : "Quantité", + RecipeIngredientUnit : "Unité", + RecipeIngredientComment : "Commentaire", } ) ] \ No newline at end of file -- 2.49.0