kassier-role #685
@ -968,22 +968,18 @@ macro_rules! special_user {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
(@check_roles $user:ident, $db:ident, $(+$role:expr),* $(,-$neg_role:expr)*) => {
|
(@check_roles $user:ident, $db:ident, $(+$role:expr),* $(,-$neg_role:expr)*) => {
|
||||||
{
|
{
|
||||||
|
let mut has_positive_role = false;
|
||||||
$(
|
$(
|
||||||
if !$user.has_role($db, $role).await {
|
if $user.has_role($db, $role).await {
|
||||||
false
|
has_positive_role = true;
|
||||||
} else
|
|
||||||
)*
|
|
||||||
$(
|
|
||||||
if $user.has_role($db, $neg_role).await {
|
|
||||||
false
|
|
||||||
} else
|
|
||||||
)*
|
|
||||||
{
|
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
)*
|
||||||
|
has_positive_role
|
||||||
|
$(
|
||||||
|
&& !$user.has_role($db, $neg_role).await
|
||||||
|
)*
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -996,6 +992,7 @@ special_user!(DonauLinzUser, +"Donau Linz", -"Unterstützend", -"Förderndes Mit
|
|||||||
special_user!(SchnupperBetreuerUser, +"schnupper-betreuer");
|
special_user!(SchnupperBetreuerUser, +"schnupper-betreuer");
|
||||||
special_user!(VorstandUser, +"Vorstand");
|
special_user!(VorstandUser, +"Vorstand");
|
||||||
special_user!(EventUser, +"manage_events");
|
special_user!(EventUser, +"manage_events");
|
||||||
|
special_user!(AllowedToEditPaymentStatusUser, +"kassier", +"admin");
|
||||||
|
|
||||||
#[derive(FromRow, Serialize, Deserialize, Clone, Debug)]
|
#[derive(FromRow, Serialize, Deserialize, Clone, Debug)]
|
||||||
pub struct UserWithRolesAndMembershipPdf {
|
pub struct UserWithRolesAndMembershipPdf {
|
||||||
|
@ -7,8 +7,8 @@ use crate::{
|
|||||||
logbook::Logbook,
|
logbook::Logbook,
|
||||||
role::Role,
|
role::Role,
|
||||||
user::{
|
user::{
|
||||||
AdminUser, User, UserWithDetails, UserWithMembershipPdf, UserWithRolesAndMembershipPdf,
|
AdminUser, AllowedToEditPaymentStatusUser, User, UserWithDetails,
|
||||||
VorstandUser,
|
UserWithMembershipPdf, UserWithRolesAndMembershipPdf, VorstandUser,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
tera::Config,
|
tera::Config,
|
||||||
@ -110,7 +110,7 @@ async fn index_admin(
|
|||||||
#[get("/user/fees")]
|
#[get("/user/fees")]
|
||||||
async fn fees(
|
async fn fees(
|
||||||
db: &State<SqlitePool>,
|
db: &State<SqlitePool>,
|
||||||
admin: VorstandUser,
|
user: AllowedToEditPaymentStatusUser,
|
||||||
flash: Option<FlashMessage<'_>>,
|
flash: Option<FlashMessage<'_>>,
|
||||||
) -> Template {
|
) -> Template {
|
||||||
let mut context = Context::new();
|
let mut context = Context::new();
|
||||||
@ -130,7 +130,7 @@ async fn fees(
|
|||||||
}
|
}
|
||||||
context.insert(
|
context.insert(
|
||||||
"loggedin_user",
|
"loggedin_user",
|
||||||
&UserWithDetails::from_user(admin.into_inner(), db).await,
|
&UserWithDetails::from_user(user.into_inner(), db).await,
|
||||||
);
|
);
|
||||||
|
|
||||||
Template::render("admin/user/fees", context.into_json())
|
Template::render("admin/user/fees", context.into_json())
|
||||||
@ -170,7 +170,7 @@ async fn scheckbuch(
|
|||||||
#[get("/user/fees/paid?<user_ids>")]
|
#[get("/user/fees/paid?<user_ids>")]
|
||||||
async fn fees_paid(
|
async fn fees_paid(
|
||||||
db: &State<SqlitePool>,
|
db: &State<SqlitePool>,
|
||||||
admin: AdminUser,
|
calling_user: AllowedToEditPaymentStatusUser,
|
||||||
user_ids: Vec<i32>,
|
user_ids: Vec<i32>,
|
||||||
referer: Referer,
|
referer: Referer,
|
||||||
) -> Flash<Redirect> {
|
) -> Flash<Redirect> {
|
||||||
@ -181,7 +181,10 @@ async fn fees_paid(
|
|||||||
if user.has_role(db, "paid").await {
|
if user.has_role(db, "paid").await {
|
||||||
Log::create(
|
Log::create(
|
||||||
db,
|
db,
|
||||||
format!("{} set fees NOT paid for '{}'", admin.user.name, user.name),
|
format!(
|
||||||
|
"{} set fees NOT paid for '{}'",
|
||||||
|
calling_user.user.name, user.name
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.await;
|
.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())
|
||||||
@ -189,7 +192,10 @@ async fn fees_paid(
|
|||||||
} else {
|
} else {
|
||||||
Log::create(
|
Log::create(
|
||||||
db,
|
db,
|
||||||
format!("{} set fees paid for '{}'", admin.user.name, user.name),
|
format!(
|
||||||
|
"{} set fees paid for '{}'",
|
||||||
|
calling_user.user.name, user.name
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.await;
|
.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())
|
||||||
|
Loading…
Reference in New Issue
Block a user