Merge commit '36d84e8157bb54c3cc215ca588a46e3d3a4cf0df' into staging
This commit is contained in:
commit
03f31a89b6
14
Cargo.lock
generated
14
Cargo.lock
generated
@ -625,6 +625,7 @@ checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-executor",
|
||||
"futures-io",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
@ -675,6 +676,17 @@ version = "0.3.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964"
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.37",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-sink"
|
||||
version = "0.3.28"
|
||||
@ -696,6 +708,7 @@ dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-macro",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"memchr",
|
||||
@ -1850,6 +1863,7 @@ dependencies = [
|
||||
"argon2",
|
||||
"chrono",
|
||||
"env_logger",
|
||||
"futures",
|
||||
"ics",
|
||||
"log",
|
||||
"rocket",
|
||||
|
@ -20,3 +20,4 @@ serde_json = "1.0"
|
||||
chrono = { version = "0.4", features = ["serde"]}
|
||||
tera = { version = "1.18", features = ["date-locale"], optional = true}
|
||||
ics = "0.5"
|
||||
futures = "0.3"
|
||||
|
@ -28,6 +28,22 @@ pub struct User {
|
||||
pub last_access: Option<chrono::NaiveDateTime>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct UserWithWaterStatus {
|
||||
#[serde(flatten)]
|
||||
pub user: User,
|
||||
pub on_water: bool,
|
||||
}
|
||||
|
||||
impl UserWithWaterStatus {
|
||||
pub async fn from_user(user: User, db: &SqlitePool) -> Self {
|
||||
Self {
|
||||
on_water: user.on_water(db).await,
|
||||
user,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for User {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.id == other.id
|
||||
|
@ -17,7 +17,7 @@ use crate::model::{
|
||||
boat::Boat,
|
||||
logbook::{LogToAdd, LogToFinalize, Logbook, LogbookCreateError, LogbookUpdateError},
|
||||
logtype::LogType,
|
||||
user::{AdminUser, User},
|
||||
user::{AdminUser, User, UserWithWaterStatus},
|
||||
};
|
||||
|
||||
pub struct KioskCookie(String);
|
||||
@ -41,8 +41,21 @@ async fn index(
|
||||
adminuser: AdminUser,
|
||||
) -> Template {
|
||||
let boats = Boat::all(db).await;
|
||||
let coxes = User::cox(db).await;
|
||||
let users = User::all(db).await;
|
||||
|
||||
let coxes: Vec<UserWithWaterStatus> = futures::future::join_all(
|
||||
User::cox(db)
|
||||
.await
|
||||
.into_iter()
|
||||
.map(|user| UserWithWaterStatus::from_user(user, db)),
|
||||
)
|
||||
.await;
|
||||
let users: Vec<UserWithWaterStatus> = futures::future::join_all(
|
||||
User::all(db)
|
||||
.await
|
||||
.into_iter()
|
||||
.map(|user| UserWithWaterStatus::from_user(user, db)),
|
||||
)
|
||||
.await;
|
||||
let logtypes = LogType::all(db).await;
|
||||
let distances = Logbook::distances(db).await;
|
||||
|
||||
|
@ -35,12 +35,12 @@
|
||||
<select name="shipmaster" id="shipmaster" class="input rounded-md h-10">
|
||||
<optgroup label="Steuerleute">
|
||||
{% for cox in coxes %}
|
||||
<option value="{{ cox.id }}" {% if cox.id == shipmaster%} selected {% endif %}>{{ cox.name }}</option>
|
||||
<option value="{{ cox.id }}" {% if cox.id == shipmaster%} selected {% endif %} {% if cox.on_water %} disabled="disabled" {% endif %}>{{ cox.name }} {% if cox.on_water %} (am Wasser) {% endif %}</option>
|
||||
{% endfor %}
|
||||
</optgroup>
|
||||
<optgroup label="Mitglieder">
|
||||
{% for user in users | filter(attribute="is_cox", value=false) %}
|
||||
<option value="{{ user.id }}" {% if user.id == shipmaster%} selected {% endif %}>{{ user.name }}</option>
|
||||
<option value="{{ user.id }}" {% if user.id == shipmaster%} selected {% endif %} {% if user.on_water %} disabled="disabled" {% endif %}>{{ user.name }} {% if cox.on_water %} (am Wasser) {% endif %}</option>
|
||||
{% endfor %}
|
||||
</optgroup>
|
||||
</select>
|
||||
|
Loading…
Reference in New Issue
Block a user