From 3ef15d64c60d943b64d998449ed0eaa1dee0ac3e Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Wed, 1 Aug 2018 13:38:35 +0200 Subject: Fix display of flash messages. Pass full flash to template, and style according to flash name/type. --- src/controllers/home_controller.rs | 2 +- src/controllers/login_controller.rs | 2 +- src/controllers/users_controller.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/controllers') diff --git a/src/controllers/home_controller.rs b/src/controllers/home_controller.rs index bef47de..38db52a 100644 --- a/src/controllers/home_controller.rs +++ b/src/controllers/home_controller.rs @@ -16,7 +16,7 @@ implement_responder_for!(IndexTemplate); fn index(flash: Option, conn: utils::DbConn) -> utils::Page { utils::Page { title: String::from("Bloggen"), - flash: flash.map_or(None, |f| Some(f.msg().to_string())), + flash: flash, content: IndexTemplate { posts: models::Post::get_all(conn).into_iter() .map(|p| ShowPostTemplate { post: p }) diff --git a/src/controllers/login_controller.rs b/src/controllers/login_controller.rs index 800a6b2..564deff 100644 --- a/src/controllers/login_controller.rs +++ b/src/controllers/login_controller.rs @@ -14,7 +14,7 @@ implement_responder_for!(LoginTemplate); pub fn new(flash: Option) -> utils::Page { utils::Page { title: String::from("Log in"), - flash: flash.map_or(None, |f| Some(f.msg().to_string())), + flash: flash, content: LoginTemplate{} } } diff --git a/src/controllers/users_controller.rs b/src/controllers/users_controller.rs index a3281de..91cfc5c 100644 --- a/src/controllers/users_controller.rs +++ b/src/controllers/users_controller.rs @@ -15,7 +15,7 @@ implement_responder_for!(UsersTemplate); fn index(flash: Option, conn: utils::DbConn) -> utils::Page { utils::Page { title: String::from("Users"), - flash: flash.map_or(None, |f| Some(f.msg().to_string())), + flash: flash, content: UsersTemplate { users: ::models::User::all(conn).unwrap() } @@ -67,7 +67,7 @@ implement_responder_for!(NewUserTemplate); fn new(flash: Option) -> utils::Page { utils::Page { title: String::from("New user"), - flash: flash.map_or(None, |f| Some(f.msg().to_string())), + flash: flash, content: NewUserTemplate { user: Default::default() } -- cgit v1.2.3