Merge pull request 'staging' (#360) from staging into main
Reviewed-on: #360
This commit is contained in:
commit
e2a30dad52
@ -5,6 +5,8 @@ use rocket::serde::{Deserialize, Serialize};
|
|||||||
use rocket::FromForm;
|
use rocket::FromForm;
|
||||||
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
||||||
|
|
||||||
|
use crate::model::boathouse::Boathouse;
|
||||||
|
|
||||||
use super::location::Location;
|
use super::location::Location;
|
||||||
use super::user::User;
|
use super::user::User;
|
||||||
|
|
||||||
@ -357,6 +359,17 @@ ORDER BY amount_seats DESC
|
|||||||
.await
|
.await
|
||||||
.unwrap(); //Okay, because we can only create a Boat of a valid id
|
.unwrap(); //Okay, because we can only create a Boat of a valid id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn boathouse(&self, db: &SqlitePool) -> Option<Boathouse> {
|
||||||
|
sqlx::query_as!(
|
||||||
|
Boathouse,
|
||||||
|
"SELECT * FROM boathouse WHERE boat_id like ?",
|
||||||
|
self.id
|
||||||
|
)
|
||||||
|
.fetch_one(db)
|
||||||
|
.await
|
||||||
|
.ok()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -25,7 +25,16 @@ async fn index(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let boats = Boat::all_for_boatshouse(db).await;
|
let boats = Boat::all_for_boatshouse(db).await;
|
||||||
context.insert("boats", &boats);
|
let mut final_boats = Vec::new();
|
||||||
|
for boat in boats {
|
||||||
|
if boat.boat.boathouse(db).await.is_none() {
|
||||||
|
if boat.boat.name != "Externes Boot" {
|
||||||
|
final_boats.push(boat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
context.insert("boats", &final_boats);
|
||||||
|
|
||||||
let boathouse = Boathouse::get(db).await;
|
let boathouse = Boathouse::get(db).await;
|
||||||
context.insert("boathouse", &boathouse);
|
context.insert("boathouse", &boathouse);
|
||||||
|
Loading…
Reference in New Issue
Block a user