allow to change from schnupperant to scheckbuch
Some checks failed
CI/CD Pipeline / test (push) Has started running
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled

This commit is contained in:
2025-05-03 17:39:03 +02:00
parent 9dfcb4e2c4
commit afc32cc41e
4 changed files with 74 additions and 14 deletions

View File

@ -1100,6 +1100,36 @@ async fn change_membertype(
}
}
#[get("/user/<id>/schnupperant-to-scheckbuch")]
async fn schnupperant_to_scheckbook(
db: &State<SqlitePool>,
admin: ManageUserUser,
config: &State<Config>,
id: i32,
) -> Flash<Redirect> {
let Some(user) = User::find_by_id(db, id).await else {
return Flash::error(
Redirect::to("/admin/user"),
format!("User with ID {} does not exist!", id),
);
};
let Some(user) = SchnupperantUser::new(&db, &user).await else {
return Flash::error(
Redirect::to(format!("/admin/user/{id}")),
format!("User {user} ist kein Schnupperant"),
);
};
match user.move_to_scheckbook(db, &admin, &config.smtp_pw).await {
Ok(_) => Flash::success(
Redirect::to(format!("/admin/user/{}", id)),
"Mitgliedstyp umgewandelt und Infos versendet",
),
Err(e) => Flash::error(Redirect::to(format!("/admin/user/{}", id)), e),
}
}
pub fn routes() -> Vec<Route> {
routes![
index,
@ -1130,6 +1160,7 @@ pub fn routes() -> Vec<Route> {
//
scheckbook_to_regular,
schnupperant_to_regular,
schnupperant_to_scheckbook,
change_membertype,
]
}