disable rowers in logbook if they are on water
This commit is contained in:
		
							
								
								
									
										14
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										14
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							@@ -625,6 +625,7 @@ checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40"
 | 
				
			|||||||
dependencies = [
 | 
					dependencies = [
 | 
				
			||||||
 "futures-channel",
 | 
					 "futures-channel",
 | 
				
			||||||
 "futures-core",
 | 
					 "futures-core",
 | 
				
			||||||
 | 
					 "futures-executor",
 | 
				
			||||||
 "futures-io",
 | 
					 "futures-io",
 | 
				
			||||||
 "futures-sink",
 | 
					 "futures-sink",
 | 
				
			||||||
 "futures-task",
 | 
					 "futures-task",
 | 
				
			||||||
@@ -675,6 +676,17 @@ version = "0.3.28"
 | 
				
			|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
					source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
				
			||||||
checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964"
 | 
					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]]
 | 
					[[package]]
 | 
				
			||||||
name = "futures-sink"
 | 
					name = "futures-sink"
 | 
				
			||||||
version = "0.3.28"
 | 
					version = "0.3.28"
 | 
				
			||||||
@@ -696,6 +708,7 @@ dependencies = [
 | 
				
			|||||||
 "futures-channel",
 | 
					 "futures-channel",
 | 
				
			||||||
 "futures-core",
 | 
					 "futures-core",
 | 
				
			||||||
 "futures-io",
 | 
					 "futures-io",
 | 
				
			||||||
 | 
					 "futures-macro",
 | 
				
			||||||
 "futures-sink",
 | 
					 "futures-sink",
 | 
				
			||||||
 "futures-task",
 | 
					 "futures-task",
 | 
				
			||||||
 "memchr",
 | 
					 "memchr",
 | 
				
			||||||
@@ -1850,6 +1863,7 @@ dependencies = [
 | 
				
			|||||||
 "argon2",
 | 
					 "argon2",
 | 
				
			||||||
 "chrono",
 | 
					 "chrono",
 | 
				
			||||||
 "env_logger",
 | 
					 "env_logger",
 | 
				
			||||||
 | 
					 "futures",
 | 
				
			||||||
 "ics",
 | 
					 "ics",
 | 
				
			||||||
 "log",
 | 
					 "log",
 | 
				
			||||||
 "rocket",
 | 
					 "rocket",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,3 +20,4 @@ serde_json = "1.0"
 | 
				
			|||||||
chrono =  { version = "0.4", features = ["serde"]}
 | 
					chrono =  { version = "0.4", features = ["serde"]}
 | 
				
			||||||
tera =  { version = "1.18", features = ["date-locale"], optional = true}
 | 
					tera =  { version = "1.18", features = ["date-locale"], optional = true}
 | 
				
			||||||
ics = "0.5"
 | 
					ics = "0.5"
 | 
				
			||||||
 | 
					futures = "0.3"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,22 @@ pub struct User {
 | 
				
			|||||||
    pub last_access: Option<chrono::NaiveDateTime>,
 | 
					    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 {
 | 
					impl PartialEq for User {
 | 
				
			||||||
    fn eq(&self, other: &Self) -> bool {
 | 
					    fn eq(&self, other: &Self) -> bool {
 | 
				
			||||||
        self.id == other.id
 | 
					        self.id == other.id
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,7 +17,7 @@ use crate::model::{
 | 
				
			|||||||
    boat::Boat,
 | 
					    boat::Boat,
 | 
				
			||||||
    logbook::{LogToAdd, LogToFinalize, Logbook, LogbookCreateError, LogbookUpdateError},
 | 
					    logbook::{LogToAdd, LogToFinalize, Logbook, LogbookCreateError, LogbookUpdateError},
 | 
				
			||||||
    logtype::LogType,
 | 
					    logtype::LogType,
 | 
				
			||||||
    user::{AdminUser, User},
 | 
					    user::{AdminUser, User, UserWithWaterStatus},
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub struct KioskCookie(String);
 | 
					pub struct KioskCookie(String);
 | 
				
			||||||
@@ -41,8 +41,21 @@ async fn index(
 | 
				
			|||||||
    adminuser: AdminUser,
 | 
					    adminuser: AdminUser,
 | 
				
			||||||
) -> Template {
 | 
					) -> Template {
 | 
				
			||||||
    let boats = Boat::all(db).await;
 | 
					    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 logtypes = LogType::all(db).await;
 | 
				
			||||||
    let distances = Logbook::distances(db).await;
 | 
					    let distances = Logbook::distances(db).await;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,12 +35,12 @@
 | 
				
			|||||||
			<select name="shipmaster" id="shipmaster" class="input rounded-md h-10">
 | 
								<select name="shipmaster" id="shipmaster" class="input rounded-md h-10">
 | 
				
			||||||
				<optgroup label="Steuerleute">
 | 
									<optgroup label="Steuerleute">
 | 
				
			||||||
					{% for cox in coxes %}
 | 
										{% 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 %}
 | 
										{% endfor %}
 | 
				
			||||||
				</optgroup>
 | 
									</optgroup>
 | 
				
			||||||
				<optgroup label="Mitglieder">
 | 
									<optgroup label="Mitglieder">
 | 
				
			||||||
					{% for user in users | filter(attribute="is_cox", value=false) %}
 | 
										{% 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 %}
 | 
										{% endfor %}
 | 
				
			||||||
				</optgroup>
 | 
									</optgroup>
 | 
				
			||||||
			</select>
 | 
								</select>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user