allow vorstand to edit boats
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled

This commit is contained in:
2025-02-11 09:22:22 +01:00
parent 5cc77c39ff
commit 3406b66f41
4 changed files with 6 additions and 22 deletions

View File

@ -2,7 +2,7 @@ use crate::model::{
boat::{Boat, BoatToAdd, BoatToUpdate},
location::Location,
log::Log,
user::{AdminAndSchriftfuehrerUser, AdminUser, User, UserWithDetails},
user::{User, UserWithDetails, VorstandUser},
};
use rocket::{
form::Form,
@ -17,7 +17,7 @@ use sqlx::SqlitePool;
#[get("/boat")]
async fn index(
db: &State<SqlitePool>,
admin: AdminAndSchriftfuehrerUser,
admin: VorstandUser,
flash: Option<FlashMessage<'_>>,
) -> Template {
let boats = Boat::all(db).await;
@ -40,11 +40,7 @@ async fn index(
}
#[get("/boat/<boat>/delete")]
async fn delete(
db: &State<SqlitePool>,
admin: AdminAndSchriftfuehrerUser,
boat: i32,
) -> Flash<Redirect> {
async fn delete(db: &State<SqlitePool>, admin: VorstandUser, boat: i32) -> Flash<Redirect> {
let boat = Boat::find_by_id(db, boat).await;
Log::create(db, format!("{} deleted boat: {boat:?}", admin.user.name)).await;
@ -65,7 +61,7 @@ async fn update(
db: &State<SqlitePool>,
data: Form<BoatToUpdate<'_>>,
boat_id: i32,
_admin: AdminAndSchriftfuehrerUser,
_admin: VorstandUser,
) -> Flash<Redirect> {
let boat = Boat::find_by_id(db, boat_id).await;
let Some(boat) = boat else {
@ -82,7 +78,7 @@ async fn update(
async fn create(
db: &State<SqlitePool>,
data: Form<BoatToAdd<'_>>,
_admin: AdminAndSchriftfuehrerUser,
_admin: VorstandUser,
) -> Flash<Redirect> {
match Boat::create(db, data.into_inner()).await {
Ok(_) => Flash::success(Redirect::to("/admin/boat"), "Boot hinzugefügt"),