From 7a6bea3c46e254f0ce80f01032bb396f7e5fd67d Mon Sep 17 00:00:00 2001 From: philipp Date: Tue, 5 Mar 2024 09:35:08 +0100 Subject: [PATCH 1/6] fix ci (#245) Reviewed-on: https://git.hofer.link/Ruderverein-Donau-Linz/rowt/pulls/245 --- src/tera/log.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tera/log.rs b/src/tera/log.rs index e2dca51..3ff330b 100644 --- a/src/tera/log.rs +++ b/src/tera/log.rs @@ -86,7 +86,7 @@ async fn index( Template::render("log", context.into_json()) } -#[get("/show", rank = 2)] +#[get("/show", rank = 3)] async fn show(db: &State, user: DonauLinzUser) -> Template { let logs = Logbook::completed(db).await; @@ -96,7 +96,7 @@ async fn show(db: &State, user: DonauLinzUser) -> Template { ) } -#[get("/show?")] +#[get("/show?", rank = 2)] async fn show_for_year(db: &State, user: AdminUser, year: i32) -> Template { let logs = Logbook::completed_in_year(db, year).await; From aadc1b315ee7fe5aba2d5ed87f20df21b8a3260e Mon Sep 17 00:00:00 2001 From: philipp Date: Tue, 5 Mar 2024 09:46:53 +0100 Subject: [PATCH 2/6] staging (#246) Reviewed-on: https://git.hofer.link/Ruderverein-Donau-Linz/rowt/pulls/246 --- templates/log.completed.html.tera | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/log.completed.html.tera b/templates/log.completed.html.tera index 1edaefa..0b2b75c 100644 --- a/templates/log.completed.html.tera +++ b/templates/log.completed.html.tera @@ -5,7 +5,7 @@

Logbuch - {% if "admin" in loggedin_user.roles %} + {% if loggedin_user and "admin" in loggedin_user.roles %} @@ -62,6 +63,11 @@ {% for role in roles %} {{ macros::checkbox(label=role.name, name="roles[" ~ role.id ~ "]", id=loop.index , checked=role.name in user.roles, disabled=allowed_to_edit == false) }} {% endfor %} + {% if user.membership_pdf %} + Beitrittserklärung herunterladen + {% endif %} + {{ macros::input(label='Beitrittserklärung', name='membership_pdf', id=loop.index, type="file", readonly=allowed_to_edit == false) }} {{ macros::input(label='DOB', name='dob', id=loop.index, type="text", value=user.dob, readonly=allowed_to_edit == false) }} {{ macros::input(label='Weight (kg)', name='weight', id=loop.index, type="text", value=user.weight, readonly=allowed_to_edit == false) }} {{ macros::input(label='Sex', name='sex', id=loop.index, type="text", value=user.sex, readonly=allowed_to_edit == false) }} From 35900f3059b3ad04e47d3a13a8dc601ea7b959b7 Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 20 Mar 2024 21:16:55 +0100 Subject: [PATCH 4/6] fix ci --- src/model/user.rs | 10 +++------- src/tera/admin/user.rs | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/model/user.rs b/src/model/user.rs index e4f7eb3..5057f23 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -1,16 +1,11 @@ -use std::{ - fs::File, - io::Read, - ops::{Deref, DerefMut}, -}; +use std::ops::{Deref, DerefMut}; use argon2::{password_hash::SaltString, Argon2, PasswordHasher}; use chrono::{Datelike, Local, NaiveDate}; use log::info; use rocket::{ async_trait, - data::ToByteUnit, - http::{ext::IntoCollection, Cookie, Status}, + http::{Cookie, Status}, request::{self, FromRequest, Outcome}, time::{Duration, OffsetDateTime}, tokio::io::AsyncReadExt, @@ -1069,6 +1064,7 @@ mod test { phone: None, address: None, family_id: None, + membership_pdf: None, }, ) .await; diff --git a/src/tera/admin/user.rs b/src/tera/admin/user.rs index ea0eb56..aca09e9 100644 --- a/src/tera/admin/user.rs +++ b/src/tera/admin/user.rs @@ -15,7 +15,7 @@ use rocket::{ http::{ContentType, Status}, post, request::{FlashMessage, FromRequest, Outcome}, - response::{content, Flash, Redirect}, + response::{Flash, Redirect}, routes, FromForm, Request, Route, State, }; use rocket_dyn_templates::{tera::Context, Template}; From 868847f778d386a7cf81cb722791863bd3c2a100 Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 20 Mar 2024 21:40:08 +0100 Subject: [PATCH 5/6] only accept pdf --- templates/admin/user/index.html.tera | 2 +- templates/includes/macros.html.tera | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/templates/admin/user/index.html.tera b/templates/admin/user/index.html.tera index 5da8e7b..cc26f46 100644 --- a/templates/admin/user/index.html.tera +++ b/templates/admin/user/index.html.tera @@ -67,7 +67,7 @@ Beitrittserklärung herunterladen {% endif %} - {{ macros::input(label='Beitrittserklärung', name='membership_pdf', id=loop.index, type="file", readonly=allowed_to_edit == false) }} + {{ macros::input(label='Beitrittserklärung', name='membership_pdf', id=loop.index, type="file", readonly=allowed_to_edit == false, accept='application/pdf') }} {{ macros::input(label='DOB', name='dob', id=loop.index, type="text", value=user.dob, readonly=allowed_to_edit == false) }} {{ macros::input(label='Weight (kg)', name='weight', id=loop.index, type="text", value=user.weight, readonly=allowed_to_edit == false) }} {{ macros::input(label='Sex', name='sex', id=loop.index, type="text", value=user.sex, readonly=allowed_to_edit == false) }} diff --git a/templates/includes/macros.html.tera b/templates/includes/macros.html.tera index b958f4f..497b872 100644 --- a/templates/includes/macros.html.tera +++ b/templates/includes/macros.html.tera @@ -115,7 +115,7 @@
{% endmacro header %} - {% macro input(label, name, type, required=false, class='rounded-md', value='', min='', hide_label=false, id='', autofocus=false, wrapper_class='', pattern='', readonly=false) %} + {% macro input(label, name, type, required=false, class='rounded-md', value='', min='', hide_label=false, id='', autofocus=false, wrapper_class='', pattern='', readonly=false, accept='') %}
From ac90dbedeab4309965ab8c16821d69bb8139a758 Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 20 Mar 2024 22:13:18 +0100 Subject: [PATCH 6/6] push --- templates/admin/user/index.html.tera | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/admin/user/index.html.tera b/templates/admin/user/index.html.tera index cc26f46..985ce62 100644 --- a/templates/admin/user/index.html.tera +++ b/templates/admin/user/index.html.tera @@ -66,8 +66,9 @@ {% if user.membership_pdf %} Beitrittserklärung herunterladen + {% else %} + {{ macros::input(label='Beitrittserklärung', name='membership_pdf', id=loop.index, type="file", readonly=allowed_to_edit == false, accept='application/pdf') }} {% endif %} - {{ macros::input(label='Beitrittserklärung', name='membership_pdf', id=loop.index, type="file", readonly=allowed_to_edit == false, accept='application/pdf') }} {{ macros::input(label='DOB', name='dob', id=loop.index, type="text", value=user.dob, readonly=allowed_to_edit == false) }} {{ macros::input(label='Weight (kg)', name='weight', id=loop.index, type="text", value=user.weight, readonly=allowed_to_edit == false) }} {{ macros::input(label='Sex', name='sex', id=loop.index, type="text", value=user.sex, readonly=allowed_to_edit == false) }}