first draft
This commit is contained in:
		@@ -87,6 +87,7 @@ CREATE TABLE IF NOT EXISTS "logbook" (
 | 
				
			|||||||
	"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
 | 
						"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
 | 
				
			||||||
	"boat_id" INTEGER NOT NULL REFERENCES boat(id),
 | 
						"boat_id" INTEGER NOT NULL REFERENCES boat(id),
 | 
				
			||||||
	"shipmaster" INTEGER NOT NULL REFERENCES user(id), 
 | 
						"shipmaster" INTEGER NOT NULL REFERENCES user(id), 
 | 
				
			||||||
 | 
						"steering_person" INTEGER NOT NULL REFERENCES user(id), 
 | 
				
			||||||
	"shipmaster_only_steering" boolean not null,
 | 
						"shipmaster_only_steering" boolean not null,
 | 
				
			||||||
	"departure" datetime not null,
 | 
						"departure" datetime not null,
 | 
				
			||||||
	"arrival" datetime, -- None -> ship is on water
 | 
						"arrival" datetime, -- None -> ship is on water
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,9 +26,9 @@ INSERT INTO "boat" (name, amount_seats, location_id) VALUES ('Ottensheim Boot',
 | 
				
			|||||||
INSERT INTO "boat" (name, amount_seats, location_id, owner) VALUES ('second_private_boat_from_rower', 1, 1, 2);
 | 
					INSERT INTO "boat" (name, amount_seats, location_id, owner) VALUES ('second_private_boat_from_rower', 1, 1, 2);
 | 
				
			||||||
INSERT INTO "logbook_type" (name) VALUES ('Wanderfahrt');
 | 
					INSERT INTO "logbook_type" (name) VALUES ('Wanderfahrt');
 | 
				
			||||||
INSERT INTO "logbook_type" (name) VALUES ('Regatta');
 | 
					INSERT INTO "logbook_type" (name) VALUES ('Regatta');
 | 
				
			||||||
INSERT INTO "logbook" (boat_id, shipmaster, shipmaster_only_steering, departure) VALUES (2, 2, false, '1142-12-24 10:00');
 | 
					INSERT INTO "logbook" (boat_id, shipmaster,steering_person, shipmaster_only_steering, departure) VALUES (2, 2, 2, false, '1142-12-24 10:00');
 | 
				
			||||||
INSERT INTO "logbook" (boat_id, shipmaster, shipmaster_only_steering, departure, arrival, destination, distance_in_km) VALUES (1, 4, false, '1141-12-24 10:00', '2141-12-24 15:00', 'Ottensheim', 25);
 | 
					INSERT INTO "logbook" (boat_id, shipmaster, steering_person, shipmaster_only_steering, departure, arrival, destination, distance_in_km) VALUES (1, 4, 4, false, '1141-12-24 10:00', '2141-12-24 15:00', 'Ottensheim', 25);
 | 
				
			||||||
INSERT INTO "logbook" (boat_id, shipmaster, shipmaster_only_steering, departure, arrival, destination, distance_in_km) VALUES (3, 4, false, '1142-12-24 10:00', '2142-12-24 11:30', 'Ottensheim + Regattastrecke', 29);
 | 
					INSERT INTO "logbook" (boat_id, shipmaster, steering_person, shipmaster_only_steering, departure, arrival, destination, distance_in_km) VALUES (3, 4, 4, false, '1142-12-24 10:00', '2142-12-24 11:30', 'Ottensheim + Regattastrecke', 29);
 | 
				
			||||||
INSERT INTO "rower" (logbook_id, rower_id) VALUES(3,3);
 | 
					INSERT INTO "rower" (logbook_id, rower_id) VALUES(3,3);
 | 
				
			||||||
INSERT INTO "boat_damage" (boat_id, desc, user_id_created, created_at) VALUES(4,'Dolle bei Position 2 fehlt', 5, '2142-12-24 15:02');
 | 
					INSERT INTO "boat_damage" (boat_id, desc, user_id_created, created_at) VALUES(4,'Dolle bei Position 2 fehlt', 5, '2142-12-24 15:02');
 | 
				
			||||||
INSERT INTO "boat_damage" (boat_id, desc, user_id_created, created_at, lock_boat) VALUES(5, 'TOHT', 5, '2142-12-24 15:02', 1);
 | 
					INSERT INTO "boat_damage" (boat_id, desc, user_id_created, created_at, lock_boat) VALUES(5, 'TOHT', 5, '2142-12-24 15:02', 1);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,6 +11,7 @@ pub struct Logbook {
 | 
				
			|||||||
    pub id: i64,
 | 
					    pub id: i64,
 | 
				
			||||||
    pub boat_id: i64,
 | 
					    pub boat_id: i64,
 | 
				
			||||||
    pub shipmaster: i64,
 | 
					    pub shipmaster: i64,
 | 
				
			||||||
 | 
					    pub steering_person: i64,
 | 
				
			||||||
    #[serde(default = "bool::default")]
 | 
					    #[serde(default = "bool::default")]
 | 
				
			||||||
    pub shipmaster_only_steering: bool,
 | 
					    pub shipmaster_only_steering: bool,
 | 
				
			||||||
    pub departure: NaiveDateTime,
 | 
					    pub departure: NaiveDateTime,
 | 
				
			||||||
@@ -31,6 +32,7 @@ impl PartialEq for Logbook {
 | 
				
			|||||||
pub struct LogToAdd {
 | 
					pub struct LogToAdd {
 | 
				
			||||||
    pub boat_id: i32,
 | 
					    pub boat_id: i32,
 | 
				
			||||||
    pub shipmaster: i64,
 | 
					    pub shipmaster: i64,
 | 
				
			||||||
 | 
					    pub steering_person: i64,
 | 
				
			||||||
    pub shipmaster_only_steering: bool,
 | 
					    pub shipmaster_only_steering: bool,
 | 
				
			||||||
    pub departure: String,
 | 
					    pub departure: String,
 | 
				
			||||||
    pub arrival: Option<String>,
 | 
					    pub arrival: Option<String>,
 | 
				
			||||||
@@ -43,6 +45,11 @@ pub struct LogToAdd {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#[derive(FromForm, Debug)]
 | 
					#[derive(FromForm, Debug)]
 | 
				
			||||||
pub struct LogToFinalize {
 | 
					pub struct LogToFinalize {
 | 
				
			||||||
 | 
					    pub shipmaster: i64,
 | 
				
			||||||
 | 
					    pub steering_person: i64,
 | 
				
			||||||
 | 
					    pub shipmaster_only_steering: bool,
 | 
				
			||||||
 | 
					    pub departure: String,
 | 
				
			||||||
 | 
					    pub arrival: String,
 | 
				
			||||||
    pub destination: String,
 | 
					    pub destination: String,
 | 
				
			||||||
    pub distance_in_km: i64,
 | 
					    pub distance_in_km: i64,
 | 
				
			||||||
    pub comments: Option<String>,
 | 
					    pub comments: Option<String>,
 | 
				
			||||||
@@ -56,6 +63,7 @@ pub struct LogbookWithBoatAndRowers {
 | 
				
			|||||||
    pub logbook: Logbook,
 | 
					    pub logbook: Logbook,
 | 
				
			||||||
    pub boat: Boat,
 | 
					    pub boat: Boat,
 | 
				
			||||||
    pub shipmaster_user: User,
 | 
					    pub shipmaster_user: User,
 | 
				
			||||||
 | 
					    pub steering_user: User,
 | 
				
			||||||
    pub rowers: Vec<User>,
 | 
					    pub rowers: Vec<User>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -93,7 +101,7 @@ impl Logbook {
 | 
				
			|||||||
        sqlx::query_as!(
 | 
					        sqlx::query_as!(
 | 
				
			||||||
            Self,
 | 
					            Self,
 | 
				
			||||||
            "
 | 
					            "
 | 
				
			||||||
    SELECT id,boat_id,shipmaster,shipmaster_only_steering,departure,arrival,destination,distance_in_km,comments,logtype
 | 
					    SELECT id,boat_id,shipmaster,steering_person,shipmaster_only_steering,departure,arrival,destination,distance_in_km,comments,logtype
 | 
				
			||||||
    FROM logbook
 | 
					    FROM logbook
 | 
				
			||||||
    WHERE id like ?
 | 
					    WHERE id like ?
 | 
				
			||||||
            ",
 | 
					            ",
 | 
				
			||||||
@@ -107,7 +115,7 @@ impl Logbook {
 | 
				
			|||||||
    pub async fn on_water(db: &SqlitePool) -> Vec<LogbookWithBoatAndRowers> {
 | 
					    pub async fn on_water(db: &SqlitePool) -> Vec<LogbookWithBoatAndRowers> {
 | 
				
			||||||
        let rows = sqlx::query!(
 | 
					        let rows = sqlx::query!(
 | 
				
			||||||
    "
 | 
					    "
 | 
				
			||||||
SELECT id, boat_id, shipmaster, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype
 | 
					SELECT id, boat_id, shipmaster,steering_person, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype
 | 
				
			||||||
FROM logbook
 | 
					FROM logbook
 | 
				
			||||||
WHERE arrival is null
 | 
					WHERE arrival is null
 | 
				
			||||||
ORDER BY departure DESC
 | 
					ORDER BY departure DESC
 | 
				
			||||||
@@ -123,6 +131,7 @@ ORDER BY departure DESC
 | 
				
			|||||||
                id: row.id,
 | 
					                id: row.id,
 | 
				
			||||||
                boat_id: row.boat_id,
 | 
					                boat_id: row.boat_id,
 | 
				
			||||||
                shipmaster: row.shipmaster,
 | 
					                shipmaster: row.shipmaster,
 | 
				
			||||||
 | 
					                steering_person: row.steering_person,
 | 
				
			||||||
                shipmaster_only_steering: row.shipmaster_only_steering,
 | 
					                shipmaster_only_steering: row.shipmaster_only_steering,
 | 
				
			||||||
                departure: row.departure,
 | 
					                departure: row.departure,
 | 
				
			||||||
                arrival: row.arrival,
 | 
					                arrival: row.arrival,
 | 
				
			||||||
@@ -139,6 +148,9 @@ ORDER BY departure DESC
 | 
				
			|||||||
                rowers: Rower::for_log(db, &log).await,
 | 
					                rowers: Rower::for_log(db, &log).await,
 | 
				
			||||||
                boat: Boat::find_by_id(db, log.boat_id as i32).await.unwrap(),
 | 
					                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(),
 | 
					                shipmaster_user: User::find_by_id(db, log.shipmaster as i32).await.unwrap(),
 | 
				
			||||||
 | 
					                steering_user: User::find_by_id(db, log.steering_person as i32)
 | 
				
			||||||
 | 
					                    .await
 | 
				
			||||||
 | 
					                    .unwrap(),
 | 
				
			||||||
                logbook: log,
 | 
					                logbook: log,
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -149,7 +161,7 @@ ORDER BY departure DESC
 | 
				
			|||||||
        let logs = sqlx::query_as!(
 | 
					        let logs = sqlx::query_as!(
 | 
				
			||||||
                Logbook,
 | 
					                Logbook,
 | 
				
			||||||
                "
 | 
					                "
 | 
				
			||||||
    SELECT id, boat_id, shipmaster, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype
 | 
					    SELECT id, boat_id, shipmaster, steering_person, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype
 | 
				
			||||||
    FROM logbook
 | 
					    FROM logbook
 | 
				
			||||||
    WHERE arrival is not null
 | 
					    WHERE arrival is not null
 | 
				
			||||||
    ORDER BY departure DESC
 | 
					    ORDER BY departure DESC
 | 
				
			||||||
@@ -165,6 +177,9 @@ ORDER BY departure DESC
 | 
				
			|||||||
                rowers: Rower::for_log(db, &log).await,
 | 
					                rowers: Rower::for_log(db, &log).await,
 | 
				
			||||||
                boat: Boat::find_by_id(db, log.boat_id as i32).await.unwrap(),
 | 
					                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(),
 | 
					                shipmaster_user: User::find_by_id(db, log.shipmaster as i32).await.unwrap(),
 | 
				
			||||||
 | 
					                steering_user: User::find_by_id(db, log.steering_person as i32)
 | 
				
			||||||
 | 
					                    .await
 | 
				
			||||||
 | 
					                    .unwrap(),
 | 
				
			||||||
                logbook: log,
 | 
					                logbook: log,
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -252,9 +267,10 @@ ORDER BY departure DESC
 | 
				
			|||||||
        //});
 | 
					        //});
 | 
				
			||||||
        //let arrival = log.arrival.map(|a| format!("{}+02:00", a));
 | 
					        //let arrival = log.arrival.map(|a| format!("{}+02:00", a));
 | 
				
			||||||
        let inserted_row = sqlx::query!(
 | 
					        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",
 | 
					                "INSERT INTO logbook(boat_id, shipmaster, steering_person, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype) VALUES (?,?,?,?,?,?,?,?,?,?) RETURNING id",
 | 
				
			||||||
                log.boat_id,
 | 
					                log.boat_id,
 | 
				
			||||||
                log.shipmaster,
 | 
					                log.shipmaster,
 | 
				
			||||||
 | 
					                log.steering_person,
 | 
				
			||||||
                log.shipmaster_only_steering,
 | 
					                log.shipmaster_only_steering,
 | 
				
			||||||
                log.departure,
 | 
					                log.departure,
 | 
				
			||||||
                log.arrival,
 | 
					                log.arrival,
 | 
				
			||||||
@@ -444,6 +460,7 @@ mod test {
 | 
				
			|||||||
            LogToAdd {
 | 
					            LogToAdd {
 | 
				
			||||||
                boat_id: 3,
 | 
					                boat_id: 3,
 | 
				
			||||||
                shipmaster: 4,
 | 
					                shipmaster: 4,
 | 
				
			||||||
 | 
					                steering_person: 4,
 | 
				
			||||||
                shipmaster_only_steering: false,
 | 
					                shipmaster_only_steering: false,
 | 
				
			||||||
                departure: "2128-05-20T12:00".into(),
 | 
					                departure: "2128-05-20T12:00".into(),
 | 
				
			||||||
                arrival: None,
 | 
					                arrival: None,
 | 
				
			||||||
@@ -468,6 +485,7 @@ mod test {
 | 
				
			|||||||
            LogToAdd {
 | 
					            LogToAdd {
 | 
				
			||||||
                boat_id: 999,
 | 
					                boat_id: 999,
 | 
				
			||||||
                shipmaster: 5,
 | 
					                shipmaster: 5,
 | 
				
			||||||
 | 
					                steering_person: 5,
 | 
				
			||||||
                shipmaster_only_steering: false,
 | 
					                shipmaster_only_steering: false,
 | 
				
			||||||
                departure: "2128-05-20T12:00".into(),
 | 
					                departure: "2128-05-20T12:00".into(),
 | 
				
			||||||
                arrival: None,
 | 
					                arrival: None,
 | 
				
			||||||
@@ -493,6 +511,7 @@ mod test {
 | 
				
			|||||||
            LogToAdd {
 | 
					            LogToAdd {
 | 
				
			||||||
                boat_id: 5,
 | 
					                boat_id: 5,
 | 
				
			||||||
                shipmaster: 5,
 | 
					                shipmaster: 5,
 | 
				
			||||||
 | 
					                steering_person: 5,
 | 
				
			||||||
                shipmaster_only_steering: false,
 | 
					                shipmaster_only_steering: false,
 | 
				
			||||||
                departure: "2128-05-20T12:00".into(),
 | 
					                departure: "2128-05-20T12:00".into(),
 | 
				
			||||||
                arrival: None,
 | 
					                arrival: None,
 | 
				
			||||||
@@ -518,6 +537,7 @@ mod test {
 | 
				
			|||||||
            LogToAdd {
 | 
					            LogToAdd {
 | 
				
			||||||
                boat_id: 2,
 | 
					                boat_id: 2,
 | 
				
			||||||
                shipmaster: 5,
 | 
					                shipmaster: 5,
 | 
				
			||||||
 | 
					                steering_person: 5,
 | 
				
			||||||
                shipmaster_only_steering: false,
 | 
					                shipmaster_only_steering: false,
 | 
				
			||||||
                departure: "2128-05-20T12:00".into(),
 | 
					                departure: "2128-05-20T12:00".into(),
 | 
				
			||||||
                arrival: None,
 | 
					                arrival: None,
 | 
				
			||||||
@@ -543,6 +563,7 @@ mod test {
 | 
				
			|||||||
            LogToAdd {
 | 
					            LogToAdd {
 | 
				
			||||||
                boat_id: 3,
 | 
					                boat_id: 3,
 | 
				
			||||||
                shipmaster: 5,
 | 
					                shipmaster: 5,
 | 
				
			||||||
 | 
					                steering_person: 5,
 | 
				
			||||||
                shipmaster_only_steering: false,
 | 
					                shipmaster_only_steering: false,
 | 
				
			||||||
                departure: "2128-05-20T12:00".into(),
 | 
					                departure: "2128-05-20T12:00".into(),
 | 
				
			||||||
                arrival: Some("2128-05-20T11:00".into()),
 | 
					                arrival: Some("2128-05-20T11:00".into()),
 | 
				
			||||||
@@ -568,6 +589,7 @@ mod test {
 | 
				
			|||||||
            LogToAdd {
 | 
					            LogToAdd {
 | 
				
			||||||
                boat_id: 3,
 | 
					                boat_id: 3,
 | 
				
			||||||
                shipmaster: 2,
 | 
					                shipmaster: 2,
 | 
				
			||||||
 | 
					                steering_person: 2,
 | 
				
			||||||
                shipmaster_only_steering: false,
 | 
					                shipmaster_only_steering: false,
 | 
				
			||||||
                departure: "2128-05-20T12:00".into(),
 | 
					                departure: "2128-05-20T12:00".into(),
 | 
				
			||||||
                arrival: None,
 | 
					                arrival: None,
 | 
				
			||||||
@@ -593,6 +615,7 @@ mod test {
 | 
				
			|||||||
            LogToAdd {
 | 
					            LogToAdd {
 | 
				
			||||||
                boat_id: 3,
 | 
					                boat_id: 3,
 | 
				
			||||||
                shipmaster: 5,
 | 
					                shipmaster: 5,
 | 
				
			||||||
 | 
					                steering_person: 5,
 | 
				
			||||||
                shipmaster_only_steering: false,
 | 
					                shipmaster_only_steering: false,
 | 
				
			||||||
                departure: "2128-05-20T12:00".into(),
 | 
					                departure: "2128-05-20T12:00".into(),
 | 
				
			||||||
                arrival: None,
 | 
					                arrival: None,
 | 
				
			||||||
@@ -618,6 +641,7 @@ mod test {
 | 
				
			|||||||
            LogToAdd {
 | 
					            LogToAdd {
 | 
				
			||||||
                boat_id: 1,
 | 
					                boat_id: 1,
 | 
				
			||||||
                shipmaster: 5,
 | 
					                shipmaster: 5,
 | 
				
			||||||
 | 
					                steering_person: 5,
 | 
				
			||||||
                shipmaster_only_steering: false,
 | 
					                shipmaster_only_steering: false,
 | 
				
			||||||
                departure: "2128-05-20T12:00".into(),
 | 
					                departure: "2128-05-20T12:00".into(),
 | 
				
			||||||
                arrival: None,
 | 
					                arrival: None,
 | 
				
			||||||
@@ -666,6 +690,11 @@ mod test {
 | 
				
			|||||||
                    comments: Some("Perfect water".into()),
 | 
					                    comments: Some("Perfect water".into()),
 | 
				
			||||||
                    logtype: None,
 | 
					                    logtype: None,
 | 
				
			||||||
                    rowers: vec![],
 | 
					                    rowers: vec![],
 | 
				
			||||||
 | 
					                    shipmaster: 2,
 | 
				
			||||||
 | 
					                    steering_person: 2,
 | 
				
			||||||
 | 
					                    shipmaster_only_steering: false,
 | 
				
			||||||
 | 
					                    departure: "1990-01-01T10:00".into(),
 | 
				
			||||||
 | 
					                    arrival: "1990-01-01T12:00".into(),
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
            .await
 | 
					            .await
 | 
				
			||||||
@@ -689,6 +718,11 @@ mod test {
 | 
				
			|||||||
                    comments: Some("Perfect water".into()),
 | 
					                    comments: Some("Perfect water".into()),
 | 
				
			||||||
                    logtype: None,
 | 
					                    logtype: None,
 | 
				
			||||||
                    rowers: vec![],
 | 
					                    rowers: vec![],
 | 
				
			||||||
 | 
					                    shipmaster: 1,
 | 
				
			||||||
 | 
					                    steering_person: 1,
 | 
				
			||||||
 | 
					                    shipmaster_only_steering: false,
 | 
				
			||||||
 | 
					                    departure: "1990-01-01T10:00".into(),
 | 
				
			||||||
 | 
					                    arrival: "1990-01-01T12:00".into(),
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
            .await;
 | 
					            .await;
 | 
				
			||||||
@@ -713,6 +747,11 @@ mod test {
 | 
				
			|||||||
                    comments: Some("Perfect water".into()),
 | 
					                    comments: Some("Perfect water".into()),
 | 
				
			||||||
                    logtype: None,
 | 
					                    logtype: None,
 | 
				
			||||||
                    rowers: vec![1],
 | 
					                    rowers: vec![1],
 | 
				
			||||||
 | 
					                    shipmaster: 2,
 | 
				
			||||||
 | 
					                    steering_person: 2,
 | 
				
			||||||
 | 
					                    shipmaster_only_steering: false,
 | 
				
			||||||
 | 
					                    departure: "1990-01-01T10:00".into(),
 | 
				
			||||||
 | 
					                    arrival: "1990-01-01T12:00".into(),
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
            .await;
 | 
					            .await;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -162,15 +162,6 @@ async fn create_logbook(
 | 
				
			|||||||
    data: Form<LogToAdd>,
 | 
					    data: Form<LogToAdd>,
 | 
				
			||||||
    user: &NonGuestUser,
 | 
					    user: &NonGuestUser,
 | 
				
			||||||
) -> Flash<Redirect> {
 | 
					) -> Flash<Redirect> {
 | 
				
			||||||
    Log::create(
 | 
					 | 
				
			||||||
        db,
 | 
					 | 
				
			||||||
        format!(
 | 
					 | 
				
			||||||
            "User {} tries to create log entry={:?}",
 | 
					 | 
				
			||||||
            user.user.name, data
 | 
					 | 
				
			||||||
        ),
 | 
					 | 
				
			||||||
    )
 | 
					 | 
				
			||||||
    .await;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    match Logbook::create(
 | 
					    match Logbook::create(
 | 
				
			||||||
        db,
 | 
					        db,
 | 
				
			||||||
        data.into_inner(),
 | 
					        data.into_inner(),
 | 
				
			||||||
@@ -201,6 +192,15 @@ async fn create(
 | 
				
			|||||||
    data: Form<LogToAdd>,
 | 
					    data: Form<LogToAdd>,
 | 
				
			||||||
    user: NonGuestUser,
 | 
					    user: NonGuestUser,
 | 
				
			||||||
) -> Flash<Redirect> {
 | 
					) -> Flash<Redirect> {
 | 
				
			||||||
 | 
					    Log::create(
 | 
				
			||||||
 | 
					        db,
 | 
				
			||||||
 | 
					        format!(
 | 
				
			||||||
 | 
					            "User {} tries to create log entry={:?}",
 | 
				
			||||||
 | 
					            user.user.name, data
 | 
				
			||||||
 | 
					        ),
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					    .await;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    create_logbook(db, data, &user).await
 | 
					    create_logbook(db, data, &user).await
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -515,7 +515,7 @@ mod test {
 | 
				
			|||||||
        let req = client
 | 
					        let req = client
 | 
				
			||||||
            .post("/log")
 | 
					            .post("/log")
 | 
				
			||||||
            .header(ContentType::Form)
 | 
					            .header(ContentType::Form)
 | 
				
			||||||
            .body("boat_id=1&shipmaster=4&departure=2199-12-31T10:00");
 | 
					            .body("boat_id=1&shipmaster=4&departure=2199-12-31T10:00&steering_person=4");
 | 
				
			||||||
        let response = req.dispatch().await;
 | 
					        let response = req.dispatch().await;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        assert_eq!(response.status(), Status::SeeOther);
 | 
					        assert_eq!(response.status(), Status::SeeOther);
 | 
				
			||||||
@@ -546,7 +546,7 @@ mod test {
 | 
				
			|||||||
        let req = client
 | 
					        let req = client
 | 
				
			||||||
            .post("/log/1")
 | 
					            .post("/log/1")
 | 
				
			||||||
            .header(ContentType::Form)
 | 
					            .header(ContentType::Form)
 | 
				
			||||||
            .body("destination=Ottensheim&distance_in_km=25");
 | 
					            .body("destination=Ottensheim&distance_in_km=25&shipmaster=1&steering_person=1&departure=1990-01-01T10:00&arrival=1990-01-01T12:00");
 | 
				
			||||||
        let response = req.dispatch().await;
 | 
					        let response = req.dispatch().await;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        assert_eq!(response.status(), Status::SeeOther);
 | 
					        assert_eq!(response.status(), Status::SeeOther);
 | 
				
			||||||
@@ -655,7 +655,7 @@ mod test {
 | 
				
			|||||||
        let shipmaster_id = User::find_by_name(&db, "rower2".into()).await.unwrap().id;
 | 
					        let shipmaster_id = User::find_by_name(&db, "rower2".into()).await.unwrap().id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let req = client.post("/log").header(ContentType::Form).body(format!(
 | 
					        let req = client.post("/log").header(ContentType::Form).body(format!(
 | 
				
			||||||
            "boat_id={boat_id}&shipmaster={shipmaster_id}&departure=1199-12-31T10:00"
 | 
					            "boat_id={boat_id}&shipmaster={shipmaster_id}&departure=1199-12-31T10:00&steering_person={shipmaster_id}"
 | 
				
			||||||
        ));
 | 
					        ));
 | 
				
			||||||
        let response = req.dispatch().await;
 | 
					        let response = req.dispatch().await;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -684,7 +684,7 @@ mod test {
 | 
				
			|||||||
        let req = client
 | 
					        let req = client
 | 
				
			||||||
            .post(format!("/log/{log_id}"))
 | 
					            .post(format!("/log/{log_id}"))
 | 
				
			||||||
            .header(ContentType::Form)
 | 
					            .header(ContentType::Form)
 | 
				
			||||||
            .body("destination=Ottensheim&distance_in_km=25");
 | 
					            .body(format!("destination=Ottensheim&distance_in_km=25&shipmaster={shipmaster_id}&steering_person={shipmaster_id}&departure=1990-01-01T10:00&arrival=1990-01-01T12:00"));
 | 
				
			||||||
        let response = req.dispatch().await;
 | 
					        let response = req.dispatch().await;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        assert_eq!(response.status(), Status::SeeOther);
 | 
					        assert_eq!(response.status(), Status::SeeOther);
 | 
				
			||||||
@@ -875,7 +875,7 @@ mod test {
 | 
				
			|||||||
        let req = client
 | 
					        let req = client
 | 
				
			||||||
            .post("/log/1")
 | 
					            .post("/log/1")
 | 
				
			||||||
            .header(ContentType::Form)
 | 
					            .header(ContentType::Form)
 | 
				
			||||||
            .body("destination=Ottensheim&distance_in_km=25");
 | 
					            .body("destination=Ottensheim&distance_in_km=25&shipmaster=1&steering_person=1&departure=1199-12-12T10:00&arrival=1199-12-12T12:00");
 | 
				
			||||||
        let response = req.dispatch().await;
 | 
					        let response = req.dispatch().await;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        assert_eq!(response.status(), Status::SeeOther);
 | 
					        assert_eq!(response.status(), Status::SeeOther);
 | 
				
			||||||
@@ -902,7 +902,7 @@ mod test {
 | 
				
			|||||||
        let shipmaster_id = User::find_by_name(db, &shipmaster_name).await.unwrap().id;
 | 
					        let shipmaster_id = User::find_by_name(db, &shipmaster_name).await.unwrap().id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let req = client.post("/log").header(ContentType::Form).body(format!(
 | 
					        let req = client.post("/log").header(ContentType::Form).body(format!(
 | 
				
			||||||
            "boat_id={boat_id}&shipmaster={shipmaster_id}&departure=1199-12-31T10:00"
 | 
					            "boat_id={boat_id}&shipmaster={shipmaster_id}&departure=1199-12-31T10:00&steering_person={shipmaster_id}"
 | 
				
			||||||
        ));
 | 
					        ));
 | 
				
			||||||
        let response = req.dispatch().await;
 | 
					        let response = req.dispatch().await;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -924,7 +924,7 @@ mod test {
 | 
				
			|||||||
        let req = client
 | 
					        let req = client
 | 
				
			||||||
            .post(format!("/log/{log_id}"))
 | 
					            .post(format!("/log/{log_id}"))
 | 
				
			||||||
            .header(ContentType::Form)
 | 
					            .header(ContentType::Form)
 | 
				
			||||||
            .body("destination=Ottensheim&distance_in_km=25");
 | 
					            .body(format!("destination=Ottensheim&distance_in_km=25&shipmaster={shipmaster_id}&steering_person={shipmaster_id}&departure=1199-12-31T10:00&arrival=1199-12-31T12:00"));
 | 
				
			||||||
        let response = req.dispatch().await;
 | 
					        let response = req.dispatch().await;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        assert_eq!(response.status(), Status::SeeOther);
 | 
					        assert_eq!(response.status(), Status::SeeOther);
 | 
				
			||||||
@@ -952,7 +952,7 @@ mod test {
 | 
				
			|||||||
        let shipmaster_id = User::find_by_name(db, &shipmaster_name).await.unwrap().id;
 | 
					        let shipmaster_id = User::find_by_name(db, &shipmaster_name).await.unwrap().id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let req = client.post("/log").header(ContentType::Form).body(format!(
 | 
					        let req = client.post("/log").header(ContentType::Form).body(format!(
 | 
				
			||||||
            "boat_id={boat_id}&shipmaster={shipmaster_id}&departure=2199-12-31T10:00"
 | 
					            "boat_id={boat_id}&shipmaster={shipmaster_id}&departure=2199-12-31T10:00&steering_person={shipmaster_id}"
 | 
				
			||||||
        ));
 | 
					        ));
 | 
				
			||||||
        let response = req.dispatch().await;
 | 
					        let response = req.dispatch().await;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user