diff --git a/src/model/user/mod.rs b/src/model/user/mod.rs index 55ba4bb..ff00d28 100644 --- a/src/model/user/mod.rs +++ b/src/model/user/mod.rs @@ -1172,6 +1172,7 @@ special_user!(VorstandUser, +"Vorstand"); special_user!(EventUser, +"manage_events"); special_user!(AllowedToEditPaymentStatusUser, +"kassier", +"admin"); special_user!(ManageUserUser, +"admin", +"schriftfuehrer"); +special_user!(AdminAndSchriftfuehrerUser, +"admin", +"schriftfuehrer"); special_user!(AllowedToUpdateTripToAlwaysBeShownUser, +"admin"); #[derive(FromRow, Serialize, Deserialize, Clone, Debug)] diff --git a/src/tera/admin/boat.rs b/src/tera/admin/boat.rs index 11dddf5..8493110 100644 --- a/src/tera/admin/boat.rs +++ b/src/tera/admin/boat.rs @@ -2,7 +2,7 @@ use crate::model::{ boat::{Boat, BoatToAdd, BoatToUpdate}, location::Location, log::Log, - user::{AdminUser, User, UserWithDetails}, + user::{AdminAndSchriftfuehrerUser, AdminUser, User, UserWithDetails}, }; use rocket::{ form::Form, @@ -17,7 +17,7 @@ use sqlx::SqlitePool; #[get("/boat")] async fn index( db: &State, - admin: AdminUser, + admin: AdminAndSchriftfuehrerUser, flash: Option>, ) -> Template { let boats = Boat::all(db).await; @@ -40,7 +40,11 @@ async fn index( } #[get("/boat//delete")] -async fn delete(db: &State, admin: AdminUser, boat: i32) -> Flash { +async fn delete( + db: &State, + admin: AdminAndSchriftfuehrerUser, + boat: i32, +) -> Flash { let boat = Boat::find_by_id(db, boat).await; Log::create(db, format!("{} deleted boat: {boat:?}", admin.user.name)).await; @@ -61,7 +65,7 @@ async fn update( db: &State, data: Form>, boat_id: i32, - _admin: AdminUser, + _admin: AdminAndSchriftfuehrerUser, ) -> Flash { let boat = Boat::find_by_id(db, boat_id).await; let Some(boat) = boat else { @@ -78,7 +82,7 @@ async fn update( async fn create( db: &State, data: Form>, - _admin: AdminUser, + _admin: AdminAndSchriftfuehrerUser, ) -> Flash { match Boat::create(db, data.into_inner()).await { Ok(_) => Flash::success(Redirect::to("/admin/boat"), "Boot hinzugefügt"), diff --git a/templates/includes/macros.html.tera b/templates/includes/macros.html.tera index a8550a6..824b4c9 100644 --- a/templates/includes/macros.html.tera +++ b/templates/includes/macros.html.tera @@ -128,7 +128,7 @@ function setChoiceByLabel(choicesInstance, label) { Userverwaltung {% endif %} - {% if "admin" in loggedin_user.roles %} + {% if "admin" in loggedin_user.roles or "schriftfuehrer" in loggedin_user.roles %} Boote {% endif %} diff --git a/templates/index.html.tera b/templates/index.html.tera index 4e57bd5..287a1aa 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -421,6 +421,17 @@ {% endif %} + {% if "schriftfuehrer" in loggedin_user.roles %} + + {% endif %} {% if "admin" in loggedin_user.roles %}