start working on calculating member fees
All checks were successful
CI/CD Pipeline / test (push) Successful in 8m54s
CI/CD Pipeline / deploy-staging (push) Successful in 4m20s
CI/CD Pipeline / deploy-main (push) Has been skipped

This commit is contained in:
philipp 2024-01-18 21:36:38 +01:00
parent dc794bde37
commit 474db1232d
3 changed files with 47 additions and 4 deletions

View File

@ -625,7 +625,10 @@ impl<'r> FromRequest<'r> for DonauLinzUser {
let db = req.rocket().state::<SqlitePool>().unwrap(); let db = req.rocket().state::<SqlitePool>().unwrap();
match User::from_request(req).await { match User::from_request(req).await {
Outcome::Success(user) => { 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)) Outcome::Success(DonauLinzUser(user))
} else { } else {
Outcome::Error((Status::Forbidden, LoginError::NotACox)) Outcome::Error((Status::Forbidden, LoginError::NotACox))

View File

@ -48,6 +48,46 @@ async fn index(
Template::render("admin/user/index", context.into_json()) Template::render("admin/user/index", context.into_json())
} }
#[get("/user/fees")]
async fn fees(
db: &State<SqlitePool>,
admin: AdminUser,
flash: Option<FlashMessage<'_>>,
) -> 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/<user>/reset-pw")] #[get("/user/<user>/reset-pw")]
async fn resetpw(db: &State<SqlitePool>, _admin: AdminUser, user: i32) -> Flash<Redirect> { async fn resetpw(db: &State<SqlitePool>, _admin: AdminUser, user: i32) -> Flash<Redirect> {
let user = User::find_by_id(db, user).await; let user = User::find_by_id(db, user).await;
@ -136,5 +176,5 @@ async fn create(
} }
pub fn routes() -> Vec<Route> { pub fn routes() -> Vec<Route> {
routes![index, resetpw, update, create, delete] routes![index, resetpw, update, create, delete, fees]
} }

View File

@ -34,10 +34,10 @@
</div> </div>
{% endif %} {% 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 %}
<div class="grid gap-3"> <div class="grid gap-3">
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5" role="alert"> <div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5" role="alert">
<h2 class="h2">Vereinsmitglieder</h2> <h2 class="h2">Aktives Vereinsmitglied</h2>
<div class="text-sm p-3"> <div class="text-sm p-3">
<ul class="list-disc ms-2"> <ul class="list-disc ms-2">
<li class="py-1"><a href="/planned" class="link-primary">Geplante Ausfahrten</a></li> <li class="py-1"><a href="/planned" class="link-primary">Geplante Ausfahrten</a></li>