allow move from schnuppern to scheckbuch
This commit is contained in:
parent
818cf0d40b
commit
eb15421d08
@ -7,8 +7,8 @@ use crate::{
|
|||||||
logbook::Logbook,
|
logbook::Logbook,
|
||||||
role::Role,
|
role::Role,
|
||||||
user::{
|
user::{
|
||||||
AdminUser, AllowedToEditPaymentStatusUser, User, UserWithDetails,
|
AdminUser, AllowedToEditPaymentStatusUser, SchnupperBetreuerUser, User,
|
||||||
UserWithMembershipPdf, UserWithRolesAndMembershipPdf, VorstandUser,
|
UserWithDetails, UserWithMembershipPdf, UserWithRolesAndMembershipPdf, VorstandUser,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
tera::Config,
|
tera::Config,
|
||||||
@ -408,6 +408,48 @@ async fn create_scheckbuch(
|
|||||||
Flash::success(Redirect::to("/admin/user/scheckbuch"), &format!("Scheckbuch erfolgreich erstellt. Eine E-Mail in der alles erklärt wird, wurde an {mail} verschickt."))
|
Flash::success(Redirect::to("/admin/user/scheckbuch"), &format!("Scheckbuch erfolgreich erstellt. Eine E-Mail in der alles erklärt wird, wurde an {mail} verschickt."))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[get("/user/move/schnupperant/<id>/to/scheckbuch")]
|
||||||
|
async fn schnupper_to_scheckbuch(
|
||||||
|
db: &State<SqlitePool>,
|
||||||
|
id: i32,
|
||||||
|
admin: SchnupperBetreuerUser,
|
||||||
|
config: &State<Config>,
|
||||||
|
) -> Flash<Redirect> {
|
||||||
|
let Some(user) = User::find_by_id(db, id).await else {
|
||||||
|
return Flash::error(
|
||||||
|
Redirect::to("/admin/schnupper"),
|
||||||
|
format!("user id not found"),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
if !user.has_role(db, "schnupperant").await {
|
||||||
|
return Flash::error(
|
||||||
|
Redirect::to("/admin/schnupper"),
|
||||||
|
format!("kein schnupperant..."),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let schnupperant = Role::find_by_name(db, "schnupperant").await.unwrap();
|
||||||
|
let paid = Role::find_by_name(db, "paid").await.unwrap();
|
||||||
|
user.remove_role(db, &schnupperant).await;
|
||||||
|
user.remove_role(db, &paid).await;
|
||||||
|
|
||||||
|
let scheckbuch = Role::find_by_name(db, "scheckbuch").await.unwrap();
|
||||||
|
user.add_role(db, &scheckbuch).await;
|
||||||
|
|
||||||
|
user.send_welcome_email(db, &config.smtp_pw).await.unwrap();
|
||||||
|
|
||||||
|
Log::create(
|
||||||
|
db,
|
||||||
|
format!(
|
||||||
|
"{} created new scheckbuch (from schnupperant): {}",
|
||||||
|
admin.name, user.name
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
Flash::success(Redirect::to("/admin/schnupper"), &format!("Scheckbuch erfolgreich erstellt. Eine E-Mail in der alles erklärt wird, wurde an {} verschickt.", user.mail.unwrap()))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn routes() -> Vec<Route> {
|
pub fn routes() -> Vec<Route> {
|
||||||
routes![
|
routes![
|
||||||
index,
|
index,
|
||||||
@ -416,6 +458,7 @@ pub fn routes() -> Vec<Route> {
|
|||||||
update,
|
update,
|
||||||
create,
|
create,
|
||||||
create_scheckbuch,
|
create_scheckbuch,
|
||||||
|
schnupper_to_scheckbuch,
|
||||||
delete,
|
delete,
|
||||||
fees,
|
fees,
|
||||||
fees_paid,
|
fees_paid,
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
{% for user in schnupperanten %}
|
{% for user in schnupperanten %}
|
||||||
<li class="py-1"
|
<li class="py-1"
|
||||||
{% if "paid" in user.roles %}style="background-color: green;"{% endif %}>
|
{% if "paid" in user.roles %}style="background-color: green;"{% endif %}>
|
||||||
{{ user.name }} ({{ user.mail }} | {{ user.notes }})
|
{{ user.name }} ({{ user.mail }} {% if user.notes %} | {{ user.notes }}{% endif %})
|
||||||
|
<a href="/admin/user/move/schnupperant/{{ user.id }}/to/scheckbuch">Zu Scheckbuch umwandeln</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ol>
|
</ol>
|
||||||
|
Loading…
Reference in New Issue
Block a user