add debug trait; switch to proper name of form field (rowerS)
This commit is contained in:
parent
9bb2996a4d
commit
c6a8866207
@ -26,7 +26,7 @@ impl PartialEq for Logbook {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(FromForm)]
|
||||
#[derive(FromForm, Debug)]
|
||||
pub struct LogToAdd {
|
||||
pub boat_id: i32,
|
||||
pub shipmaster: i64,
|
||||
@ -37,7 +37,7 @@ pub struct LogToAdd {
|
||||
pub distance_in_km: Option<i64>,
|
||||
pub comments: Option<String>,
|
||||
pub logtype: Option<i64>,
|
||||
pub rower: Vec<i64>,
|
||||
pub rowers: Vec<i64>,
|
||||
}
|
||||
|
||||
#[derive(FromForm)]
|
||||
@ -49,7 +49,7 @@ pub struct LogToFinalize {
|
||||
pub rower: Vec<i64>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct LogbookWithBoatAndRowers {
|
||||
#[serde(flatten)]
|
||||
pub logbook: Logbook,
|
||||
@ -187,14 +187,14 @@ ORDER BY departure DESC
|
||||
return Err(LogbookCreateError::ShipmasterAlreadyOnWater);
|
||||
}
|
||||
|
||||
if log.rower.len() > boat.amount_seats as usize - 1 {
|
||||
if log.rowers.len() > boat.amount_seats as usize - 1 {
|
||||
return Err(LogbookCreateError::TooManyRowers(
|
||||
boat.amount_seats as usize,
|
||||
log.rower.len() + 1,
|
||||
log.rowers.len() + 1,
|
||||
));
|
||||
}
|
||||
|
||||
for rower in &log.rower {
|
||||
for rower in &log.rowers {
|
||||
let user = User::find_by_id(db, *rower as i32).await.unwrap();
|
||||
if user.on_water(db).await {
|
||||
return Err(LogbookCreateError::RowerAlreadyOnWater(user));
|
||||
@ -204,7 +204,6 @@ ORDER BY departure DESC
|
||||
let mut tx = db.begin().await.unwrap();
|
||||
|
||||
let departure = NaiveDateTime::parse_from_str(&log.departure, "%Y-%m-%dT%H:%M").unwrap();
|
||||
println!("@@@@@@ {:?}", log.arrival);
|
||||
let arrival = log
|
||||
.arrival
|
||||
.map(|a| NaiveDateTime::parse_from_str(&a, "%Y-%m-%dT%H:%M").unwrap());
|
||||
@ -223,7 +222,7 @@ ORDER BY departure DESC
|
||||
.fetch_one(&mut tx)
|
||||
.await.unwrap();
|
||||
|
||||
for rower in &log.rower {
|
||||
for rower in &log.rowers {
|
||||
Rower::create(&mut tx, inserted_row.id, *rower)
|
||||
.await
|
||||
.map_err(|e| LogbookCreateError::RowerCreateError(*rower, e.to_string()))?;
|
||||
|
@ -48,6 +48,8 @@ async fn index(
|
||||
|
||||
let on_water = Logbook::on_water(db).await;
|
||||
|
||||
println!("{on_water:?}");
|
||||
|
||||
let mut context = Context::new();
|
||||
if let Some(msg) = flash {
|
||||
context.insert("flash", &msg.into_inner());
|
||||
|
Loading…
Reference in New Issue
Block a user