code cleanup #214
@ -1,3 +1,5 @@
|
||||
#![allow(clippy::blocks_in_conditions)]
|
||||
|
||||
pub mod model;
|
||||
|
||||
#[cfg(feature = "rowing-tera")]
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![allow(clippy::blocks_in_conditions)]
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
#[cfg(feature = "rest")]
|
||||
|
@ -22,7 +22,7 @@ impl Family {
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub async fn new(db: &SqlitePool) -> i64 {
|
||||
pub async fn insert(db: &SqlitePool) -> i64 {
|
||||
let result: SqliteQueryResult = sqlx::query("INSERT INTO family DEFAULT VALUES")
|
||||
.execute(db)
|
||||
.await
|
||||
|
@ -96,7 +96,7 @@ impl Mail {
|
||||
}
|
||||
None => {
|
||||
if let Some(mail) = &user.mail {
|
||||
send_to.push_str(&mail)
|
||||
send_to.push_str(mail)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ impl Fee {
|
||||
pub fn add_person(&mut self, user: &User) {
|
||||
if !self.name.is_empty() {
|
||||
self.name.push_str(" + ");
|
||||
self.user_ids.push_str("&");
|
||||
self.user_ids.push('&');
|
||||
}
|
||||
self.name.push_str(&user.name);
|
||||
|
||||
@ -171,7 +171,7 @@ impl User {
|
||||
fee.add("Familie 2 Personen".into(), FAMILY_TWO);
|
||||
}
|
||||
} else {
|
||||
fee.add_person(&self);
|
||||
fee.add_person(self);
|
||||
if self.has_role(db, "paid").await {
|
||||
fee.paid();
|
||||
}
|
||||
@ -440,7 +440,7 @@ ORDER BY last_access DESC
|
||||
let mut family_id = data.family_id;
|
||||
|
||||
if family_id.is_some_and(|x| x == -1) {
|
||||
family_id = Some(Family::new(db).await)
|
||||
family_id = Some(Family::insert(db).await)
|
||||
}
|
||||
|
||||
sqlx::query!(
|
||||
@ -779,9 +779,7 @@ impl<'r> FromRequest<'r> for AllowedForPlannedTripsUser {
|
||||
let db = req.rocket().state::<SqlitePool>().unwrap();
|
||||
match User::from_request(req).await {
|
||||
Outcome::Success(user) => {
|
||||
if user.has_role(db, "Donau Linz").await {
|
||||
Outcome::Success(AllowedForPlannedTripsUser(user))
|
||||
} else if user.has_role(db, "scheckbuch").await {
|
||||
if user.has_role(db, "Donau Linz").await | user.has_role(db, "scheckbuch").await {
|
||||
Outcome::Success(AllowedForPlannedTripsUser(user))
|
||||
} else {
|
||||
Outcome::Error((Status::Forbidden, LoginError::NotACox))
|
||||
|
@ -171,7 +171,7 @@ async fn create_logbook(
|
||||
match Logbook::create(
|
||||
db,
|
||||
data.into_inner(),
|
||||
&user
|
||||
user
|
||||
)
|
||||
.await
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user