aboutsummaryrefslogtreecommitdiff
path: root/src/controller/payments.rs
diff options
context:
space:
mode:
authorJoris2025-01-26 17:58:57 +0100
committerJoris2025-01-26 17:58:57 +0100
commit24eeb54a6b7159964e8887ade7fa5173b50feb3a (patch)
tree91af6253df784445db9b084b02b38b37a83224e8 /src/controller/payments.rs
parentc5759f348e70cf54b4bfa4cd17e1fe1828ead30a (diff)
Replace tera by minijinjamain
tera was doing the job all right, but minijinja has fewer dependencies.
Diffstat (limited to 'src/controller/payments.rs')
-rw-r--r--src/controller/payments.rs62
1 files changed, 32 insertions, 30 deletions
diff --git a/src/controller/payments.rs b/src/controller/payments.rs
index 8184015..b5c0256 100644
--- a/src/controller/payments.rs
+++ b/src/controller/payments.rs
@@ -3,7 +3,6 @@ use hyper::body::Bytes;
use hyper::header::CONTENT_TYPE;
use hyper::Response;
use std::collections::HashMap;
-use tera::Context;
use crate::controller::utils;
use crate::controller::wallet::Wallet;
@@ -27,17 +26,18 @@ pub async fn table(
let users = db::users::list(&wallet.pool).await;
let categories = db::categories::list(&wallet.pool).await;
- let mut context = Context::new();
- context.insert("header", &templates::Header::Payments);
- context.insert("connected_user", &wallet.user);
- context.insert("payments", &payments);
- context.insert("page", &page);
- context.insert("max_page", &max_page);
- context.insert("query", &query);
- context.insert("count", &count.count);
- context.insert("total_cost", &count.total_cost);
- context.insert("users", &users);
- context.insert("categories", &categories);
+ let context = minijinja::context!(
+ header => templates::Header::Payments,
+ connected_user => wallet.user,
+ payments => payments,
+ page => page,
+ max_page => max_page,
+ query => query,
+ count => count.count,
+ total_cost => count.total_cost,
+ users => users,
+ categories => categories
+ );
utils::template(
&wallet.assets,
@@ -63,14 +63,15 @@ async fn create_form_feedback(
let users = db::users::list(&wallet.pool).await;
let categories = db::categories::list(&wallet.pool).await;
- let mut context = Context::new();
- context.insert("header", &templates::Header::Payments);
- context.insert("connected_user", &wallet.user);
- context.insert("users", &users);
- context.insert("categories", &categories);
- context.insert("query", &query);
- context.insert("form", &form);
- context.insert("error", &error);
+ let context = minijinja::context!(
+ header => templates::Header::Payments,
+ connected_user => wallet.user,
+ users => users,
+ categories => categories,
+ query => query,
+ form => form,
+ error => error
+ );
utils::template(
&wallet.assets,
@@ -142,16 +143,17 @@ async fn update_form_feedback(
let users = db::users::list(&wallet.pool).await;
let categories = db::categories::list(&wallet.pool).await;
- let mut context = Context::new();
- context.insert("header", &templates::Header::Payments);
- context.insert("connected_user", &wallet.user);
- context.insert("id", &id);
- context.insert("payment", &payment);
- context.insert("users", &users);
- context.insert("categories", &categories);
- context.insert("query", &query);
- context.insert("form", &form);
- context.insert("error", &error);
+ let context = minijinja::context!(
+ header => templates::Header::Payments,
+ connected_user => wallet.user,
+ id => id,
+ payment => payment,
+ users => users,
+ categories => categories,
+ query => query,
+ form => form,
+ error => error
+ );
utils::template(
&wallet.assets,