diff --git a/src/tera/ergo.rs b/src/tera/ergo.rs index b2a8aab..b2decf6 100644 --- a/src/tera/ergo.rs +++ b/src/tera/ergo.rs @@ -67,11 +67,7 @@ async fn reset(db: &State, _user: AdminUser) -> Flash { } #[get("/")] -async fn index( - db: &State, - user: NonGuestUser, - flash: Option>, -) -> Template { +async fn index(db: &State, user: User, flash: Option>) -> Template { let users = User::ergo(db).await; let thirty = sqlx::query_as!( @@ -94,7 +90,7 @@ async fn index( if let Some(msg) = flash { context.insert("flash", &msg.into_inner()); } - context.insert("loggedin_user", &user.user); + context.insert("loggedin_user", &user); context.insert("users", &users); context.insert("thirty", &thirty); context.insert("dozen", &dozen); @@ -113,7 +109,7 @@ pub struct ErgoToAdd<'a> { async fn new_thirty( db: &State, mut data: Form>, - created_by: NonGuestUser, + created_by: User, ) -> Flash { let user = User::find_by_id(db, data.user as i32).await.unwrap(); @@ -139,10 +135,7 @@ async fn new_thirty( Log::create( db, - format!( - "{} created thirty-ergo entry: {data:?}", - created_by.user.name - ), + format!("{} created thirty-ergo entry: {data:?}", created_by.name), ) .await; @@ -153,7 +146,7 @@ async fn new_thirty( async fn new_dozen( db: &State, mut data: Form>, - created_by: NonGuestUser, + created_by: User, ) -> Flash { let user = User::find_by_id(db, data.user as i32).await.unwrap(); @@ -179,10 +172,7 @@ async fn new_dozen( Log::create( db, - format!( - "{} created dozen-ergo entry: {data:?}", - created_by.user.name - ), + format!("{} created dozen-ergo entry: {data:?}", created_by.name), ) .await; diff --git a/templates/includes/macros.html.tera b/templates/includes/macros.html.tera index 7d53179..f97150c 100644 --- a/templates/includes/macros.html.tera +++ b/templates/includes/macros.html.tera @@ -19,6 +19,29 @@ {% include "includes/question-icon" %} FAQs + {% if loggedin_user.is_guest and loggedin_user.weight and loggedin_user.sex and loggedin_user.dob %} + + {% include "includes/book" %} + Ergo + + + {% endif %} {% if not loggedin_user.is_guest %} - {% endif %} {% if loggedin_user.is_admin %} + {% endif %} + {% if loggedin_user.is_admin %}