be able to update data individually; Fixes #951
All checks were successful
CI/CD Pipeline / test (push) Successful in 14m36s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped

This commit is contained in:
2025-04-30 11:06:10 +02:00
parent 90087843ad
commit c8d5c633d7
8 changed files with 589 additions and 221 deletions

View File

@ -1,7 +1,7 @@
use super::User;
use crate::model::user::LoginError;
use crate::{
model::{mail::Mail, notification::Notification, role::Role},
model::{mail::Mail, notification::Notification},
special_user, SCHECKBUCH,
};
use rocket::async_trait;
@ -16,24 +16,24 @@ use std::ops::Deref;
special_user!(ScheckbuchUser, +"scheckbuch");
impl ScheckbuchUser {
async fn from(user: User, db: &SqlitePool, mail: &str, smtp_pw: &str) -> Result<(), String> {
// TODO: see when/how to invoke this function (explicit `Neue Person hinzufügen` button?
// Button to transition existing users to scheckbuch? Automatically called when
// `scheckbuch` is newly selected as role?
if user.has_role(db, "scheckbuch").await {
return Err("User is already a scheckbuch".into());
}
//async fn from(user: User, db: &SqlitePool, mail: &str, smtp_pw: &str) -> Result<(), String> {
// // TODO: see when/how to invoke this function (explicit `Neue Person hinzufügen` button?
// // Button to transition existing users to scheckbuch? Automatically called when
// // `scheckbuch` is newly selected as role?
// if user.has_role(db, "scheckbuch").await {
// return Err("User is already a scheckbuch".into());
// }
// TODO: do we allow e.g. DonauLinz to scheckbuch?
// // TODO: do we allow e.g. DonauLinz to scheckbuch?
let scheckbuch = Role::find_by_name(db, "scheckbuch").await.unwrap();
user.add_role(db, &scheckbuch).await.unwrap();
// let scheckbuch = Role::find_by_name(db, "scheckbuch").await.unwrap();
// user.add_role(db, &scheckbuch).await.unwrap();
// TODO: remove all other `membership_type` roles
let new_user = Self::new(db, &user).await.unwrap();
// // TODO: remove all other `membership_type` roles
// let new_user = Self::new(db, &user).await.unwrap();
new_user.notify(db, mail, smtp_pw).await
}
// new_user.notify(db, mail, smtp_pw).await
//}
pub(crate) async fn notify(
&self,