From 5aa1deb32359fb50f1c1371e3c09062950008f90 Mon Sep 17 00:00:00 2001 From: philipp Date: Thu, 6 Apr 2023 19:21:40 +0200 Subject: [PATCH 1/3] use helper variable to compute amount of needed cox --- templates/index.html.tera | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/index.html.tera b/templates/index.html.tera index ad9ba52..6747cd9 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -77,7 +77,8 @@
{% if planned_event.planned_amount_cox > 0 %} -
{{ planned_event.planned_amount_cox }} - {{ planned_event.cox | length }} Steuerleute werden benötigt ({{ planned_event.planned_amount_cox }})
+ {% set amount_cur_cox = planned_event.cox | length %} +
{{ planned_event.planned_amount_cox - amount_cur_cox }} Steuerleute werden benötigt ({{ planned_event.planned_amount_cox }})
{% if planned_event.cox | length > 0 %} {% for cox in planned_event.cox %} From 12672917bb81fdc645d1a4824cae0c35bee7026c Mon Sep 17 00:00:00 2001 From: philipp Date: Thu, 6 Apr 2023 19:53:22 +0200 Subject: [PATCH 2/3] hide register button when necessary --- frontend/scss/app.scss | 6 ------ templates/index.html.tera | 37 ++++++++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/frontend/scss/app.scss b/frontend/scss/app.scss index 71b73ac..c9e7c41 100644 --- a/frontend/scss/app.scss +++ b/frontend/scss/app.scss @@ -84,10 +84,4 @@ z-index: 1; } } - -.deregister-btn { - + .register-btn { - display: none; - } -} /* purgecss end ignore */ diff --git a/templates/index.html.tera b/templates/index.html.tera index 6747cd9..466028d 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -34,30 +34,41 @@ Details
+ {% set_global cur_user_participates = false %} {% for rower in planned_event.rower%} {% if rower.name == loggedin_user.name %} - Abmelden + {% set_global cur_user_participates = true %} {% endif %} {% endfor %} + {% if cur_user_participates %} + Abmelden + {% endif %} {% if planned_event.max_people > planned_event.rower | length %} - Mitrudern - {% endif %} + {% if cur_user_participates == false %} + Mitrudern + {% endif %} + {% endif %}
{% if loggedin_user.is_cox %} + {% set_global cur_user_participates = false %} {% for cox in planned_event.cox %} {% if cox.name == loggedin_user.name %} + {% set_global cur_user_participates = true %} + {% endif %} + {% endfor %} + {% if cur_user_participates %} Abmelden - {% endif %} - {% endfor %} - - - Steuern - + {% else %} + + + Steuern + + {% endif %} {% endif %}
+ {% set_global cur_user_participates = false %} {% for rower in trip.rower %} {% if rower.name == loggedin_user.name %} - Abmelden + {% set_global cur_user_participates = true %} {% endif %} {% endfor %} - {% if trip.max_people > trip.rower | length and trip.cox_id != loggedin_user.id %} + {% if cur_user_participates %} + Abmelden + {% endif %} + {% if trip.max_people > trip.rower | length and trip.cox_id != loggedin_user.id and cur_user_participates == false%} Mitrudern {% endif %}
From 4d49574ebb9565523acf16853be3d4922f2a6e63 Mon Sep 17 00:00:00 2001 From: philipp Date: Thu, 6 Apr 2023 20:08:58 +0200 Subject: [PATCH 3/3] add cox_needed attribute --- src/model/planned_event.rs | 5 ++++- templates/index.html.tera | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/model/planned_event.rs b/src/model/planned_event.rs index c1718c2..f837149 100644 --- a/src/model/planned_event.rs +++ b/src/model/planned_event.rs @@ -19,6 +19,7 @@ pub struct PlannedEvent { pub struct PlannedEventWithUser { #[serde(flatten)] planned_event: PlannedEvent, + cox_needed: bool, cox: Vec, rower: Vec, } @@ -47,9 +48,11 @@ WHERE day=?", let mut ret = Vec::new(); for event in events { + let cox = Self::get_all_cox_for_id(db, event.id).await; ret.push(PlannedEventWithUser { planned_event: event.clone(), - cox: Self::get_all_cox_for_id(db, event.id).await, + cox_needed: event.planned_amount_cox > cox.len() as i64, + cox, rower: Self::get_all_rower_for_id(db, event.id).await, }); } diff --git a/templates/index.html.tera b/templates/index.html.tera index 466028d..20e6ad8 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -30,6 +30,11 @@
+ {% if planned_event.cox_needed %} + zusätzliche steuerperson notwendig!!!!!!elf!! + {% else %} + keine zusätzliche unbedingt notwendig + {% endif %} {{ planned_event.planned_starting_time }} Uhr ({{ planned_event.name }})
Details