start with activity + fix tests
This commit is contained in:
@ -327,6 +327,34 @@ async fn update_mail(
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(FromForm, Debug)]
|
||||
pub struct AddNoteForm {
|
||||
note: String,
|
||||
}
|
||||
|
||||
#[post("/user/<id>/add-note", data = "<data>")]
|
||||
async fn add_note(
|
||||
db: &State<SqlitePool>,
|
||||
data: Form<AddNoteForm>,
|
||||
admin: ManageUserUser,
|
||||
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),
|
||||
);
|
||||
};
|
||||
|
||||
match user.add_note(db, &admin, &data.note).await {
|
||||
Ok(_) => Flash::success(
|
||||
Redirect::to(format!("/admin/user/{}", user.id)),
|
||||
"Notiz hinzugefügt",
|
||||
),
|
||||
Err(e) => Flash::error(Redirect::to(format!("/admin/user/{}", user.id)), e),
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(FromForm, Debug)]
|
||||
pub struct PhoneUpdateForm {
|
||||
phone: String,
|
||||
@ -1147,6 +1175,7 @@ pub fn routes() -> Vec<Route> {
|
||||
update_family,
|
||||
add_membership_pdf,
|
||||
add_role,
|
||||
add_note,
|
||||
remove_role,
|
||||
//
|
||||
scheckbook_to_regular,
|
||||
|
Reference in New Issue
Block a user