diff options
Diffstat (limited to 'src/controller/incomes.rs')
-rw-r--r-- | src/controller/incomes.rs | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/src/controller/incomes.rs b/src/controller/incomes.rs index f22098b..ac3a332 100644 --- a/src/controller/incomes.rs +++ b/src/controller/incomes.rs @@ -4,7 +4,6 @@ use http_body_util::Full; use hyper::body::Bytes; use hyper::Response; use std::collections::HashMap; -use tera::Context; use crate::controller::utils; use crate::controller::wallet::Wallet; @@ -24,13 +23,14 @@ pub async fn table( let incomes = db::incomes::list(&wallet.pool, page, PER_PAGE).await; let max_page = (count as f32 / PER_PAGE as f32).ceil() as i64; - let mut context = Context::new(); - context.insert("header", &templates::Header::Incomes); - context.insert("connected_user", &wallet.user); - context.insert("incomes", &incomes); - context.insert("page", &page); - context.insert("max_page", &max_page); - context.insert("highlight", &query.highlight); + let context = minijinja::context!( + header => templates::Header::Incomes, + connected_user => wallet.user, + incomes => incomes, + page => page, + max_page => max_page, + highlight => query.highlight + ); utils::template( &wallet.assets, @@ -70,15 +70,16 @@ async fn create_form_feedback( ) -> Response<Full<Bytes>> { let users = db::users::list(&wallet.pool).await; - let mut context = Context::new(); - context.insert("header", &templates::Header::Incomes); - context.insert("connected_user", &wallet.user); - context.insert("users", &users); - context.insert("query", &query); - context.insert("current_month", &Utc::now().date_naive().month()); - context.insert("months", &MONTHS); - context.insert("form", &form); - context.insert("error", &error); + let context = minijinja::context!( + header => templates::Header::Incomes, + connected_user => wallet.user, + users => users, + query => query, + current_month => Utc::now().date_naive().month(), + months => MONTHS, + form => form, + error => error, + ); utils::template( &wallet.assets, @@ -144,16 +145,17 @@ async fn update_form_feedback( let users = db::users::list(&wallet.pool).await; let income = db::incomes::get(&wallet.pool, id).await; - let mut context = Context::new(); - context.insert("header", &templates::Header::Incomes); - context.insert("connected_user", &wallet.user); - context.insert("users", &users); - context.insert("id", &id); - context.insert("income", &income); - context.insert("query", &query); - context.insert("months", &MONTHS); - context.insert("form", &form); - context.insert("error", &error); + let context = minijinja::context!( + header => &templates::Header::Incomes, + connected_user => &wallet.user, + users => &users, + id => &id, + income => &income, + query => &query, + months => &MONTHS, + form => &form, + error => &error + ); utils::template( &wallet.assets, |