Merge branch 'main' of gitlab.com:PhilippHofer/rot
This commit is contained in:
commit
a4c4d917a8
@ -4,7 +4,10 @@
|
||||
|
||||
## New large features
|
||||
### Logbuch
|
||||
- Next: add rower to logbook
|
||||
- Next: Allow editing of rowers on "Ausfahrt beenden"
|
||||
- Then
|
||||
- Allow editing own logbook entries of same day
|
||||
- Stats (Personenliste mit Gesamt-KM vom Jahr)
|
||||
|
||||
### Guest-Scheckbuch
|
||||
- guest_trip
|
||||
@ -91,7 +94,7 @@ user_details
|
||||
- [x] (remove) GET /remove/<trip_details_id>
|
||||
- [x] (create) POST /cox/trip
|
||||
- [x] (update) POST /cox/trip/<trip_id>
|
||||
- [ ] (join) GET /cox/join/<planned_event_id>
|
||||
- [x] (join) GET /cox/join/<planned_event_id>
|
||||
- [ ] (remove) GET /cox/remove/<planned_event_id>
|
||||
- [ ] (remove_trip) GET /cox/remove/trip/<trip_id>
|
||||
- [ ] (index) GET /auth/
|
||||
|
@ -103,7 +103,8 @@ CREATE TABLE IF NOT EXISTS "logbook" (
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "rower" (
|
||||
"logbook_id" INTEGER NOT NULL REFERENCES logbook(id),
|
||||
"rower_id" INTEGER NOT NULL REFERENCES user(id)
|
||||
"rower_id" INTEGER NOT NULL REFERENCES user(id),
|
||||
CONSTRAINT unq UNIQUE (logbook_id, rower_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "boat_damage" (
|
||||
|
@ -48,7 +48,22 @@ impl Boat {
|
||||
// .await
|
||||
// .ok()
|
||||
// }
|
||||
//
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
pub async fn on_water(&self, db: &SqlitePool) -> bool {
|
||||
sqlx::query!(
|
||||
"SELECT * FROM logbook WHERE boat_id=? AND arrival is null",
|
||||
self.id
|
||||
)
|
||||
.fetch_optional(db)
|
||||
.await
|
||||
.unwrap()
|
||||
.is_some()
|
||||
}
|
||||
|
||||
pub async fn all(db: &SqlitePool) -> Vec<Self> {
|
||||
sqlx::query_as!(
|
||||
Boat,
|
||||
|
@ -1,10 +1,10 @@
|
||||
use chrono::NaiveDateTime;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::Serialize;
|
||||
use sqlx::{FromRow, SqlitePool};
|
||||
|
||||
use super::user::User;
|
||||
use super::{boat::Boat, rower::Rower, user::User};
|
||||
|
||||
#[derive(FromRow, Debug, Serialize, Deserialize)]
|
||||
#[derive(FromRow, Serialize, Clone)]
|
||||
pub struct Logbook {
|
||||
pub id: i64,
|
||||
pub boat_id: i64,
|
||||
@ -19,21 +19,13 @@ pub struct Logbook {
|
||||
pub logtype: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, FromRow)]
|
||||
pub struct LogbookWithBoatAndUsers {
|
||||
pub id: i64,
|
||||
pub boat_id: i64,
|
||||
pub shipmaster: i64,
|
||||
#[serde(default = "bool::default")]
|
||||
pub shipmaster_only_steering: bool,
|
||||
pub departure: String, //TODO: Switch to chrono::nativedatetime
|
||||
pub arrival: Option<String>, //TODO: Switch to chrono::nativedatetime
|
||||
pub destination: Option<String>,
|
||||
pub distance_in_km: Option<i64>,
|
||||
pub comments: Option<String>,
|
||||
pub logtype: Option<i64>,
|
||||
pub boat: String,
|
||||
pub shipmaster_name: String,
|
||||
#[derive(Serialize)]
|
||||
pub struct LogbookWithBoatAndRowers {
|
||||
#[serde(flatten)]
|
||||
pub logbook: Logbook,
|
||||
pub boat: Boat,
|
||||
pub shipmaster_user: User,
|
||||
pub rowers: Vec<User>,
|
||||
}
|
||||
|
||||
pub enum LogbookUpdateError {
|
||||
@ -43,6 +35,8 @@ pub enum LogbookUpdateError {
|
||||
pub enum LogbookCreateError {
|
||||
BoatAlreadyOnWater,
|
||||
BoatLocked,
|
||||
BoatNotFound,
|
||||
TooManyRowers(usize, usize),
|
||||
}
|
||||
|
||||
impl Logbook {
|
||||
@ -76,43 +70,61 @@ impl Logbook {
|
||||
// .ok()
|
||||
// }
|
||||
//
|
||||
pub async fn on_water(db: &SqlitePool) -> Vec<LogbookWithBoatAndUsers> {
|
||||
sqlx::query_as!(
|
||||
LogbookWithBoatAndUsers,
|
||||
pub async fn on_water(db: &SqlitePool) -> Vec<LogbookWithBoatAndRowers> {
|
||||
let logs = sqlx::query_as!(
|
||||
Logbook,
|
||||
"
|
||||
SELECT logbook.id, boat_id, shipmaster, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype, boat.name as boat, user.name as shipmaster_name
|
||||
SELECT id, boat_id, shipmaster, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype
|
||||
FROM logbook
|
||||
INNER JOIN boat ON logbook.boat_id = boat.id
|
||||
INNER JOIN user ON shipmaster = user.id
|
||||
WHERE arrival is null
|
||||
ORDER BY departure DESC
|
||||
"
|
||||
)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap() //TODO: fixme
|
||||
.unwrap(); //TODO: fixme
|
||||
|
||||
let mut ret = Vec::new();
|
||||
for log in logs {
|
||||
ret.push(LogbookWithBoatAndRowers {
|
||||
rowers: Rower::for_log(db, &log).await,
|
||||
boat: Boat::find_by_id(db, log.boat_id as i32).await.unwrap(),
|
||||
shipmaster_user: User::find_by_id(db, log.shipmaster as i32).await.unwrap(),
|
||||
logbook: log,
|
||||
})
|
||||
}
|
||||
ret
|
||||
}
|
||||
|
||||
pub async fn completed(db: &SqlitePool) -> Vec<LogbookWithBoatAndUsers> {
|
||||
sqlx::query_as!(
|
||||
LogbookWithBoatAndUsers,
|
||||
pub async fn completed(db: &SqlitePool) -> Vec<LogbookWithBoatAndRowers> {
|
||||
let logs = sqlx::query_as!(
|
||||
Logbook,
|
||||
"
|
||||
SELECT logbook.id, boat_id, shipmaster, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype, boat.name as boat, user.name as shipmaster_name
|
||||
SELECT id, boat_id, shipmaster, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype
|
||||
FROM logbook
|
||||
INNER JOIN boat ON logbook.boat_id = boat.id
|
||||
INNER JOIN user ON shipmaster = user.id
|
||||
WHERE arrival is not null
|
||||
ORDER BY arrival DESC
|
||||
ORDER BY departure DESC
|
||||
"
|
||||
)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap() //TODO: fixme
|
||||
.unwrap(); //TODO: fixme
|
||||
|
||||
let mut ret = Vec::new();
|
||||
for log in logs {
|
||||
ret.push(LogbookWithBoatAndRowers {
|
||||
rowers: Rower::for_log(db, &log).await,
|
||||
boat: Boat::find_by_id(db, log.boat_id as i32).await.unwrap(),
|
||||
shipmaster_user: User::find_by_id(db, log.shipmaster as i32).await.unwrap(),
|
||||
logbook: log,
|
||||
})
|
||||
}
|
||||
ret
|
||||
}
|
||||
|
||||
pub async fn create(
|
||||
db: &SqlitePool,
|
||||
boat_id: i64,
|
||||
boat_id: i32,
|
||||
shipmaster: i64,
|
||||
shipmaster_only_steering: bool,
|
||||
departure: NaiveDateTime,
|
||||
@ -121,15 +133,40 @@ impl Logbook {
|
||||
distance_in_km: Option<i64>,
|
||||
comments: Option<String>,
|
||||
logtype: Option<i64>,
|
||||
rower: Vec<i64>,
|
||||
) -> Result<(), LogbookCreateError> {
|
||||
//Check if boat is not locked
|
||||
//Check if boat is already on water
|
||||
let _ = sqlx::query!(
|
||||
"INSERT INTO logbook(boat_id, shipmaster, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype) VALUES (?,?,?,?,?,?,?,?,?)",
|
||||
let boat = match Boat::find_by_id(db, boat_id).await {
|
||||
Some(b) => b,
|
||||
None => {
|
||||
return Err(LogbookCreateError::BoatNotFound);
|
||||
}
|
||||
};
|
||||
|
||||
if boat.is_locked(db).await {
|
||||
return Err(LogbookCreateError::BoatLocked);
|
||||
}
|
||||
|
||||
if boat.on_water(db).await {
|
||||
return Err(LogbookCreateError::BoatAlreadyOnWater);
|
||||
}
|
||||
|
||||
if rower.len() > boat.amount_seats as usize - 1 {
|
||||
return Err(LogbookCreateError::TooManyRowers(
|
||||
boat.amount_seats as usize,
|
||||
rower.len() + 1,
|
||||
));
|
||||
}
|
||||
|
||||
let inserted_row = sqlx::query!(
|
||||
"INSERT INTO logbook(boat_id, shipmaster, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype) VALUES (?,?,?,?,?,?,?,?,?) RETURNING id",
|
||||
boat_id, shipmaster, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype
|
||||
)
|
||||
.execute(db)
|
||||
.await;
|
||||
.fetch_one(db)
|
||||
.await.unwrap();
|
||||
|
||||
for rower in &rower {
|
||||
Rower::create(db, inserted_row.id, *rower).await;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ pub mod log;
|
||||
pub mod logbook;
|
||||
pub mod logtype;
|
||||
pub mod planned_event;
|
||||
pub mod rower;
|
||||
pub mod trip;
|
||||
pub mod tripdetails;
|
||||
pub mod triptype;
|
||||
|
134
src/model/rower.rs
Normal file
134
src/model/rower.rs
Normal file
@ -0,0 +1,134 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, SqlitePool};
|
||||
|
||||
use super::{logbook::Logbook, user::User};
|
||||
|
||||
#[derive(FromRow, Debug, Serialize, Deserialize)]
|
||||
pub struct Rower {
|
||||
pub logbook_id: i64,
|
||||
pub rower_id: i64,
|
||||
}
|
||||
|
||||
impl Rower {
|
||||
//pub async fn find_by_id(db: &SqlitePool, id: i32) -> Option<Self> {
|
||||
// sqlx::query_as!(
|
||||
// Self,
|
||||
// "
|
||||
//SELECT id,boat_id,shipmaster,shipmaster_only_steering,departure,arrival,destination,distance_in_km,comments,logtype
|
||||
//FROM logbook
|
||||
//WHERE id like ?
|
||||
// ",
|
||||
// id
|
||||
// )
|
||||
// .fetch_one(db)
|
||||
// .await
|
||||
// .ok()
|
||||
//}
|
||||
|
||||
pub async fn for_log(db: &SqlitePool, log: &Logbook) -> Vec<User> {
|
||||
sqlx::query_as!(
|
||||
User,
|
||||
"
|
||||
SELECT id, name, pw, is_cox, is_admin, is_guest, deleted, last_access
|
||||
FROM user
|
||||
WHERE id in (SELECT rower_id FROM rower WHERE logbook_id=?)
|
||||
",
|
||||
log.id
|
||||
)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub async fn create(db: &SqlitePool, logbook_id: i64, rower_id: i64) {
|
||||
//Check if boat is not locked
|
||||
//Check if boat is already on water
|
||||
let _ = sqlx::query!(
|
||||
"INSERT INTO rower(logbook_id, rower_id) VALUES (?,?)",
|
||||
logbook_id,
|
||||
rower_id
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
// pub async fn delete(&self, db: &SqlitePool) {
|
||||
// sqlx::query!("DELETE FROM boat WHERE id=?", self.id)
|
||||
// .execute(db)
|
||||
// .await
|
||||
// .unwrap(); //Okay, because we can only create a User of a valid id
|
||||
// }
|
||||
}
|
||||
//
|
||||
//#[cfg(test)]
|
||||
//mod test {
|
||||
// use crate::{model::boat::Boat, testdb};
|
||||
//
|
||||
// use sqlx::SqlitePool;
|
||||
//
|
||||
// #[sqlx::test]
|
||||
// fn test_find_correct_id() {
|
||||
// let pool = testdb!();
|
||||
// let boat = Boat::find_by_id(&pool, 1).await.unwrap();
|
||||
// assert_eq!(boat.id, 1);
|
||||
// }
|
||||
//
|
||||
// #[sqlx::test]
|
||||
// fn test_find_wrong_id() {
|
||||
// let pool = testdb!();
|
||||
// let boat = Boat::find_by_id(&pool, 1337).await;
|
||||
// assert!(boat.is_none());
|
||||
// }
|
||||
//
|
||||
// #[sqlx::test]
|
||||
// fn test_all() {
|
||||
// let pool = testdb!();
|
||||
// let res = Boat::all(&pool).await;
|
||||
// assert!(res.len() > 3);
|
||||
// }
|
||||
//
|
||||
// #[sqlx::test]
|
||||
// fn test_succ_create() {
|
||||
// let pool = testdb!();
|
||||
//
|
||||
// assert_eq!(
|
||||
// Boat::create(
|
||||
// &pool,
|
||||
// "new-boat-name".into(),
|
||||
// 42,
|
||||
// None,
|
||||
// "Best Boatbuilder".into(),
|
||||
// true,
|
||||
// true,
|
||||
// false,
|
||||
// Some(1),
|
||||
// None
|
||||
// )
|
||||
// .await,
|
||||
// true
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// #[sqlx::test]
|
||||
// fn test_duplicate_name_create() {
|
||||
// let pool = testdb!();
|
||||
//
|
||||
// assert_eq!(
|
||||
// Boat::create(
|
||||
// &pool,
|
||||
// "Haichenbach".into(),
|
||||
// 42,
|
||||
// None,
|
||||
// "Best Boatbuilder".into(),
|
||||
// true,
|
||||
// true,
|
||||
// false,
|
||||
// Some(1),
|
||||
// None
|
||||
// )
|
||||
// .await,
|
||||
// false
|
||||
// );
|
||||
// }
|
||||
//}
|
@ -20,12 +20,12 @@ use super::{tripdetails::TripDetails, Day};
|
||||
pub struct User {
|
||||
pub id: i64,
|
||||
pub name: String,
|
||||
pw: Option<String>,
|
||||
pub pw: Option<String>,
|
||||
pub is_cox: bool,
|
||||
pub is_admin: bool,
|
||||
pub is_guest: bool,
|
||||
#[serde(default = "bool::default")]
|
||||
deleted: bool,
|
||||
pub deleted: bool,
|
||||
pub last_access: Option<chrono::NaiveDateTime>,
|
||||
}
|
||||
|
||||
|
103
src/tera/cox.rs
103
src/tera/cox.rs
@ -345,4 +345,107 @@ mod test {
|
||||
|
||||
assert_eq!(flash_cookie.value(), "5:errorNicht deine Ausfahrt!");
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
||||
fn test_trip_join() {
|
||||
let db = testdb!();
|
||||
|
||||
let rocket = rocket::build().manage(db.clone());
|
||||
let rocket = crate::tera::config(rocket);
|
||||
|
||||
let client = Client::tracked(rocket).await.unwrap();
|
||||
let login = client
|
||||
.post("/auth")
|
||||
.header(ContentType::Form) // Set the content type to form
|
||||
.body("name=cox&password=cox"); // Add the form data to the request body;
|
||||
login.dispatch().await;
|
||||
|
||||
let req = client.get("/cox/join/1");
|
||||
let response = req.dispatch().await;
|
||||
|
||||
assert_eq!(response.status(), Status::SeeOther);
|
||||
assert_eq!(response.headers().get("Location").next(), Some("/"));
|
||||
|
||||
let flash_cookie = response
|
||||
.cookies()
|
||||
.get("_flash")
|
||||
.expect("Expected flash cookie");
|
||||
|
||||
assert_eq!(flash_cookie.value(), "7:successDanke für's helfen!");
|
||||
|
||||
let req = client.get("/cox/join/1");
|
||||
let response = req.dispatch().await;
|
||||
|
||||
assert_eq!(response.status(), Status::SeeOther);
|
||||
assert_eq!(response.headers().get("Location").next(), Some("/"));
|
||||
|
||||
let flash_cookie = response
|
||||
.cookies()
|
||||
.get("_flash")
|
||||
.expect("Expected flash cookie");
|
||||
|
||||
assert_eq!(flash_cookie.value(), "5:errorDu hilfst bereits aus!");
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
||||
fn test_trip_join_already_rower() {
|
||||
let db = testdb!();
|
||||
|
||||
let rocket = rocket::build().manage(db.clone());
|
||||
let rocket = crate::tera::config(rocket);
|
||||
|
||||
let client = Client::tracked(rocket).await.unwrap();
|
||||
let login = client
|
||||
.post("/auth")
|
||||
.header(ContentType::Form) // Set the content type to form
|
||||
.body("name=cox&password=cox"); // Add the form data to the request body;
|
||||
login.dispatch().await;
|
||||
|
||||
let req = client.get("/join/1");
|
||||
let response = req.dispatch().await;
|
||||
|
||||
let req = client.get("/cox/join/1");
|
||||
let response = req.dispatch().await;
|
||||
|
||||
assert_eq!(response.status(), Status::SeeOther);
|
||||
assert_eq!(response.headers().get("Location").next(), Some("/"));
|
||||
|
||||
let flash_cookie = response
|
||||
.cookies()
|
||||
.get("_flash")
|
||||
.expect("Expected flash cookie");
|
||||
|
||||
assert_eq!(
|
||||
flash_cookie.value(),
|
||||
"5:errorDu hast dich bereits als Ruderer angemeldet!"
|
||||
);
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
||||
fn test_trip_join_invalid_event() {
|
||||
let db = testdb!();
|
||||
|
||||
let rocket = rocket::build().manage(db.clone());
|
||||
let rocket = crate::tera::config(rocket);
|
||||
|
||||
let client = Client::tracked(rocket).await.unwrap();
|
||||
let login = client
|
||||
.post("/auth")
|
||||
.header(ContentType::Form) // Set the content type to form
|
||||
.body("name=cox&password=cox"); // Add the form data to the request body;
|
||||
login.dispatch().await;
|
||||
|
||||
let req = client.get("/cox/join/9999");
|
||||
let response = req.dispatch().await;
|
||||
|
||||
assert_eq!(response.status(), Status::SeeOther);
|
||||
assert_eq!(response.headers().get("Location").next(), Some("/"));
|
||||
|
||||
let flash_cookie = response
|
||||
.cookies()
|
||||
.get("_flash")
|
||||
.expect("Expected flash cookie");
|
||||
|
||||
assert_eq!(flash_cookie.value(), "5:errorEvent gibt's nicht");
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ use tera::Context;
|
||||
|
||||
use crate::model::{
|
||||
boat::Boat,
|
||||
logbook::Logbook,
|
||||
logbook::{Logbook, LogbookCreateError},
|
||||
logtype::LogType,
|
||||
user::{AdminUser, User},
|
||||
};
|
||||
@ -24,7 +24,8 @@ async fn index(
|
||||
adminuser: AdminUser,
|
||||
) -> Template {
|
||||
let boats = Boat::all(db).await;
|
||||
let users = User::cox(db).await;
|
||||
let coxes = User::cox(db).await;
|
||||
let users = User::all(db).await;
|
||||
let logtypes = LogType::all(db).await;
|
||||
|
||||
let on_water = Logbook::on_water(db).await;
|
||||
@ -36,6 +37,7 @@ async fn index(
|
||||
}
|
||||
|
||||
context.insert("boats", &boats);
|
||||
context.insert("coxes", &coxes);
|
||||
context.insert("users", &users);
|
||||
context.insert("logtypes", &logtypes);
|
||||
context.insert("loggedin_user", &adminuser.user);
|
||||
@ -47,7 +49,7 @@ async fn index(
|
||||
|
||||
#[derive(FromForm)]
|
||||
struct LogAddForm {
|
||||
boat_id: i64,
|
||||
boat_id: i32,
|
||||
shipmaster: i64,
|
||||
shipmaster_only_steering: bool,
|
||||
departure: String,
|
||||
@ -56,6 +58,7 @@ struct LogAddForm {
|
||||
distance_in_km: Option<i64>,
|
||||
comments: Option<String>,
|
||||
logtype: Option<i64>,
|
||||
rower: Vec<i64>,
|
||||
}
|
||||
|
||||
#[post("/", data = "<data>")]
|
||||
@ -77,14 +80,16 @@ async fn create(
|
||||
data.distance_in_km,
|
||||
data.comments.clone(), //TODO: fix
|
||||
data.logtype,
|
||||
data.rower.clone(), //TODO: fix
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => Flash::success(Redirect::to("/log"), "Ausfahrt erfolgreich hinzugefügt"),
|
||||
Err(_) => Flash::error(Redirect::to("/log"), format!("Fehler beim hinzufügen!"))
|
||||
Err(LogbookCreateError::BoatAlreadyOnWater) => Flash::error(Redirect::to("/log"), format!("Boot schon am Wasser")),
|
||||
Err(LogbookCreateError::BoatLocked) => Flash::error(Redirect::to("/log"), format!("Boot gesperrt")),
|
||||
Err(LogbookCreateError::BoatNotFound) => Flash::error(Redirect::to("/log"), format!("Boot gibt's ned")),
|
||||
Err(LogbookCreateError::TooManyRowers(expected, actual)) => Flash::error(Redirect::to("/log"), format!("Zu viele Ruderer (Boot fasst maximal {expected}, es wurden jedoch {actual} Ruderer ausgewählt)")),
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#[derive(FromForm)]
|
||||
@ -117,22 +122,18 @@ async fn home(
|
||||
data.destination.clone(), //TODO: fixme
|
||||
data.distance_in_km,
|
||||
data.comments.clone(), //TODO: fixme
|
||||
data.logtype
|
||||
data.logtype,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => Flash::success(Redirect::to("/log"), "Successfully updated log"),
|
||||
Err(_) =>
|
||||
Flash::error(
|
||||
Err(_) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
format!("Logbook with ID {} could not be updated!", logbook_id),
|
||||
)
|
||||
),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
pub fn routes() -> Vec<Route> {
|
||||
routes![index, create, home]
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
<h2>Neue Ausfahrt starten</h2>
|
||||
<form action="/log" method="post" id="form">
|
||||
{{ macros::select(data=boats, select_name='boat_id') }}
|
||||
{{ macros::select(data=users, select_name='shipmaster', selected_id=loggedin_user.id) }}
|
||||
{{ macros::select(data=coxes, select_name='shipmaster', selected_id=loggedin_user.id) }}
|
||||
{{ macros::checkbox(label='shipmaster_only_steering', name='shipmaster_only_steering') }} <!-- TODO: depending on boat, deselect by default -->
|
||||
Departure: <input type="datetime-local" id="datetime-dep" value="2023-07-24T08:00" name="departure" required/>
|
||||
Arrival: <input type="datetime-local" id="datetime-arr" name="arrival" />
|
||||
@ -35,6 +35,11 @@
|
||||
{{ macros::input(label="Distanz", name="distance_in_km", type="number", min=0) }}
|
||||
{{ macros::input(label="Kommentar", name="comments", type="text") }}
|
||||
{{ macros::select(data=logtypes, select_name='logtype', default="Normal") }}
|
||||
<select multiple="multiple" name="rower[]">
|
||||
{% for user in users %}
|
||||
<option value="{{ user.id }}" onmousedown="event.preventDefault(); this.selected = !this.selected; return false;">{{user.name}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<input type="submit" />
|
||||
|
||||
<script>
|
||||
@ -53,8 +58,8 @@
|
||||
|
||||
<h2 style="font-size: 100px">Am Wasser</h2>
|
||||
{% for log in on_water %}
|
||||
Bootsname: {{ log.boat }}<br />
|
||||
Schiffsführer: {{ log.shipmaster_name }}<br />
|
||||
Bootsname: {{ log.boat.name }}<br />
|
||||
Schiffsführer: {{ log.shipmaster_user.name }}<br />
|
||||
{% if log.shipmaster_only_steering %}
|
||||
Schiffsführer steuert nur
|
||||
{% endif %}
|
||||
@ -62,6 +67,13 @@
|
||||
Ziel: {{ log.destination }}<br />
|
||||
Kommentare: {{ log.comments }}<br />
|
||||
Logtype: {{ log.logtype }}<br />
|
||||
Ruderer:
|
||||
{% for rower in log.rowers %}
|
||||
{{ rower.name }}
|
||||
{% endfor %}
|
||||
{% set amount_rowers = log.rowers | length %}
|
||||
{% set amount_guests = log.boat.amount_seats - amount_rowers -1 %}
|
||||
{{ amount_guests }} Gäste (ohne Account)
|
||||
{% if log.shipmaster == loggedin_user.id %}
|
||||
<form action="/log/{{log.id}}" method="post">
|
||||
Destination: <input type="search" list="destinations" placeholder="Destination" id="destination-home" name="destination" value="{{log.destination}}" oninput="var inputElement = document.getElementById('destination-home');
|
||||
@ -85,11 +97,18 @@
|
||||
|
||||
<h2 style="font-size: 100px">Einträge</h2>
|
||||
{% for log in completed %}
|
||||
Bootsname: {{ log.boat }}<br />
|
||||
Schiffsführer: {{ log.shipmaster_name }}<br />
|
||||
Bootsname: {{ log.boat.name }}<br />
|
||||
Schiffsführer: {{ log.shipmaster_user.name }}<br />
|
||||
{% if log.shipmaster_only_steering %}
|
||||
Schiffsführer steuert nur
|
||||
{% endif %}
|
||||
Ruderer:
|
||||
{% for rower in log.rowers %}
|
||||
{{ rower.name }}
|
||||
{% endfor %}
|
||||
{% set amount_rowers = log.rowers | length %}
|
||||
{% set amount_guests = log.boat.amount_seats - amount_rowers -1 %}
|
||||
{{ amount_guests }} Gäste (ohne Account)
|
||||
Weggefahren: {{ log.departure }}<br />
|
||||
Angekommen: {{ log.arrival}}<br />
|
||||
Ziel: {{ log.destination }}<br />
|
||||
|
Loading…
Reference in New Issue
Block a user