complete tests for logbook
This commit is contained in:
@ -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,
|
||||
|
Reference in New Issue
Block a user