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>,
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();
res.push_str(&format!("{} + ", user.name));
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())
.await;
} 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())
.await;
}
@ -217,7 +212,7 @@ 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> {
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 {
Some(user) => {
user.delete(db).await;
@ -256,7 +251,7 @@ async fn update(
let user = User::find_by_id(db, data.id).await;
Log::create(
db,
format!("{} updated user from {user:?} to {data:?}", admin.user.name),
format!("{admin:?} updated user from {user:?} to {data:?}"),
)
.await;
let Some(user) = user else {
@ -282,12 +277,8 @@ async fn create(
data: Form<UserAddForm<'_>>,
admin: AdminUser,
) -> Flash<Redirect> {
Log::create(db, format!("{admin:?} created new user: {data:?}")).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")
} else {
Flash::error(