diff --git a/src/model/user.rs b/src/model/user.rs index 30f5ebd..aace4c8 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -625,7 +625,10 @@ impl<'r> FromRequest<'r> for DonauLinzUser { let db = req.rocket().state::().unwrap(); match User::from_request(req).await { Outcome::Success(user) => { - if user.has_role(db, "Donau Linz").await { + if user.has_role(db, "Donau Linz").await + && !user.has_role(db, "Unterstützend").await + && !user.has_role(db, "Förderndes Mitglied").await + { Outcome::Success(DonauLinzUser(user)) } else { Outcome::Error((Status::Forbidden, LoginError::NotACox)) diff --git a/src/tera/admin/user.rs b/src/tera/admin/user.rs index 01c6808..2e21f41 100644 --- a/src/tera/admin/user.rs +++ b/src/tera/admin/user.rs @@ -48,6 +48,46 @@ async fn index( Template::render("admin/user/index", context.into_json()) } +#[get("/user/fees")] +async fn fees( + db: &State, + admin: AdminUser, + flash: Option>, +) -> Template { + // Checks + // Fördernd -> Donau Linz + // Fördernd -> keine Family + // Unterstützend -> Donau Linz + // Unterstützend -> keine Family + // Schüler -> Donau Linz + // Student -> Donau Linz + + // Fördernd: 85€ + // Unterstützend: 25€ + + // select id, size_of_family, count_rennsport from family + // 2-Family: 220€ + // 3+-Family: 350€ + + // Normal: 220€ + // Student, Schüler: 80€ + + // Rennsportbeitrag: 110€ + + // Bootsplatz: 45€ + + let mut context = Context::new(); + if let Some(msg) = flash { + context.insert("flash", &msg.into_inner()); + } + context.insert( + "loggedin_user", + &UserWithRoles::from_user(admin.user, db).await, + ); + + Template::render("admin/user/fees", context.into_json()) +} + #[get("/user//reset-pw")] async fn resetpw(db: &State, _admin: AdminUser, user: i32) -> Flash { let user = User::find_by_id(db, user).await; @@ -136,5 +176,5 @@ async fn create( } pub fn routes() -> Vec { - routes![index, resetpw, update, create, delete] + routes![index, resetpw, update, create, delete, fees] } diff --git a/templates/index.html.tera b/templates/index.html.tera index 305cb2a..eff9c80 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -34,10 +34,10 @@ {% endif %} - {% if "Donau Linz" in loggedin_user.roles %} + {% if "Donau Linz" in loggedin_user.roles and "Unterstützend" not in loggedin_user.roles and "Förderndes Mitglied" not in loggedin_user.roles %}