complete tests for logbook

This commit is contained in:
2023-10-01 15:53:45 +02:00
parent 6d0501d3b0
commit 02e1546f0e
3 changed files with 282 additions and 30 deletions

View File

@ -78,6 +78,18 @@ impl Boat {
.ok()
}
pub async fn shipmaster_allowed(&self, user: &User) -> bool {
if let Some(owner_id) = self.owner {
return owner_id == user.id;
}
if self.amount_seats == 1 {
return true;
}
user.is_cox
}
pub async fn is_locked(&self, db: &SqlitePool) -> bool {
sqlx::query!("SELECT * FROM boat_damage WHERE boat_id=? AND lock_boat=true AND user_id_verified is null", self.id).fetch_optional(db).await.unwrap().is_some()
}
@ -136,7 +148,7 @@ ORDER BY amount_seats DESC
if user.is_admin {
return Self::all(db).await;
}
let mut boats;
let boats;
if user.is_cox {
boats = sqlx::query_as!(
Boat,