Compare commits

..

No commits in common. "54058b091779dd3fa5c8aed3e6d7aa2c7af95912" and "e228deb6cd00566d95c1c873cb5c008d70676d06" have entirely different histories.

2 changed files with 8 additions and 27 deletions

View File

@ -6,7 +6,6 @@ use rocket::{post, FromForm};
use rocket_dyn_templates::{tera::Context, Template};
use sqlx::SqlitePool;
use crate::model::log::Log;
use crate::model::mail::Mail;
use crate::model::role::Role;
use crate::model::user::AdminUser;
@ -35,8 +34,7 @@ async fn index(
}
#[get("/mail/fee")]
async fn fee(db: &State<SqlitePool>, admin: AdminUser, config: &State<Config>) -> &'static str {
Log::create(db, format!("{admin:?} trying to send fee")).await;
async fn fee(db: &State<SqlitePool>, _admin: AdminUser, config: &State<Config>) -> &'static str {
Mail::fees(db, config.smtp_pw.clone()).await;
"SUCC"
}
@ -44,10 +42,9 @@ async fn fee(db: &State<SqlitePool>, admin: AdminUser, config: &State<Config>) -
#[get("/mail/fee-final")]
async fn fee_final(
db: &State<SqlitePool>,
admin: AdminUser,
_admin: AdminUser,
config: &State<Config>,
) -> &'static str {
Log::create(db, format!("{admin:?} trying to send fee_final")).await;
Mail::fees_final(db, config.smtp_pw.clone()).await;
"SUCC"
}
@ -65,15 +62,12 @@ async fn update(
db: &State<SqlitePool>,
data: Form<MailToSend<'_>>,
config: &State<Config>,
admin: AdminUser,
_admin: AdminUser,
) -> Flash<Redirect> {
let d = data.into_inner();
Log::create(db, format!("{admin:?} trying to send this mail: {d:?}")).await;
if Mail::send(db, d, config.smtp_pw.clone()).await {
Log::create(db, "Mail successfully sent".into()).await;
Flash::success(Redirect::to("/admin/mail"), "Mail versendet")
} else {
Log::create(db, "Error sending the mail".into()).await;
Flash::error(Redirect::to("/admin/mail"), "Fehler")
}
}

View File

@ -2,7 +2,6 @@ use std::collections::HashMap;
use crate::model::{
family::Family,
log::Log,
logbook::Logbook,
role::Role,
user::{AdminUser, User, UserWithRoles, VorstandUser},
@ -164,15 +163,10 @@ async fn scheckbuch(
#[get("/user/fees/paid?<user_ids>")]
async fn fees_paid(
db: &State<SqlitePool>,
admin: AdminUser,
_admin: AdminUser,
user_ids: Vec<i32>,
referer: Referer,
) -> Flash<Redirect> {
Log::create(
db,
format!("{admin:?} set fees paid for user_ids: {user_ids:?}"),
)
.await;
let mut res = String::new();
for user_id in user_ids {
let user = User::find_by_id(db, user_id).await.unwrap();
@ -210,9 +204,8 @@ async fn resetpw(db: &State<SqlitePool>, _admin: AdminUser, user: i32) -> Flash<
}
#[get("/user/<user>/delete")]
async fn delete(db: &State<SqlitePool>, admin: AdminUser, user: i32) -> Flash<Redirect> {
async fn delete(db: &State<SqlitePool>, _admin: AdminUser, user: i32) -> Flash<Redirect> {
let user = User::find_by_id(db, user).await;
Log::create(db, format!("{admin:?} deleted user: {user:?}")).await;
match user {
Some(user) => {
user.delete(db).await;
@ -246,14 +239,9 @@ pub struct UserEditForm {
async fn update(
db: &State<SqlitePool>,
data: Form<UserEditForm>,
admin: AdminUser,
_admin: AdminUser,
) -> Flash<Redirect> {
let user = User::find_by_id(db, data.id).await;
Log::create(
db,
format!("{admin:?} updated user from {user:?} to {data:?}"),
)
.await;
let Some(user) = user else {
return Flash::error(
Redirect::to("/admin/user"),
@ -266,7 +254,7 @@ async fn update(
Flash::success(Redirect::to("/admin/user"), "Successfully updated user")
}
#[derive(FromForm, Debug)]
#[derive(FromForm)]
struct UserAddForm<'r> {
name: &'r str,
}
@ -275,9 +263,8 @@ struct UserAddForm<'r> {
async fn create(
db: &State<SqlitePool>,
data: Form<UserAddForm<'_>>,
admin: AdminUser,
_admin: AdminUser,
) -> Flash<Redirect> {
Log::create(db, format!("{admin:?} created new user: {data:?}")).await;
if User::create(db, data.name).await {
Flash::success(Redirect::to("/admin/user"), "Successfully created user")
} else {