Compare commits

..

No commits in common. "a1126e05096879d9ae971b69479731934ef94c2d" and "b075b8803b862c4d6ab0f0b3ec365ff4e76f8627" have entirely different histories.

View File

@ -168,24 +168,19 @@ async fn fees_paid(
user_ids: Vec<i32>, user_ids: Vec<i32>,
referer: Referer, referer: Referer,
) -> Flash<Redirect> { ) -> Flash<Redirect> {
Log::create(
db,
format!("{admin:?} set fees paid for user_ids: {user_ids:?}"),
)
.await;
let mut res = String::new(); let mut res = String::new();
for user_id in user_ids { for user_id in user_ids {
let user = User::find_by_id(db, user_id).await.unwrap(); let user = User::find_by_id(db, user_id).await.unwrap();
res.push_str(&format!("{} + ", user.name)); res.push_str(&format!("{} + ", user.name));
if user.has_role(db, "paid").await { if user.has_role(db, "paid").await {
Log::create(
db,
format!("{} set fees NOT paid for '{}'", admin.user.name, user.name),
)
.await;
user.remove_role(db, &Role::find_by_name(db, "paid").await.unwrap()) user.remove_role(db, &Role::find_by_name(db, "paid").await.unwrap())
.await; .await;
} else { } else {
Log::create(
db,
format!("{} set fees paid for '{}'", admin.user.name, user.name),
)
.await;
user.add_role(db, &Role::find_by_name(db, "paid").await.unwrap()) user.add_role(db, &Role::find_by_name(db, "paid").await.unwrap())
.await; .await;
} }
@ -217,7 +212,7 @@ async fn resetpw(db: &State<SqlitePool>, _admin: AdminUser, user: i32) -> Flash<
#[get("/user/<user>/delete")] #[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; let user = User::find_by_id(db, user).await;
Log::create(db, format!("{} deleted user: {user:?}", admin.user.name)).await; Log::create(db, format!("{admin:?} deleted user: {user:?}")).await;
match user { match user {
Some(user) => { Some(user) => {
user.delete(db).await; user.delete(db).await;
@ -256,7 +251,7 @@ async fn update(
let user = User::find_by_id(db, data.id).await; let user = User::find_by_id(db, data.id).await;
Log::create( Log::create(
db, db,
format!("{} updated user from {user:?} to {data:?}", admin.user.name), format!("{admin:?} updated user from {user:?} to {data:?}"),
) )
.await; .await;
let Some(user) = user else { let Some(user) = user else {
@ -282,12 +277,8 @@ async fn create(
data: Form<UserAddForm<'_>>, data: Form<UserAddForm<'_>>,
admin: AdminUser, admin: AdminUser,
) -> Flash<Redirect> { ) -> Flash<Redirect> {
Log::create(db, format!("{admin:?} created new user: {data:?}")).await;
if User::create(db, data.name).await { if User::create(db, data.name).await {
Log::create(
db,
format!("{} created new user: {data:?}", admin.user.name),
)
.await;
Flash::success(Redirect::to("/admin/user"), "Successfully created user") Flash::success(Redirect::to("/admin/user"), "Successfully created user")
} else { } else {
Flash::error( Flash::error(