calc general boat cat #436

Merged
philipp merged 4 commits from calc-general-boatcat into main 2024-04-24 15:39:14 +02:00
5 changed files with 29 additions and 15 deletions

View File

@ -12,10 +12,10 @@ test("Cox can start and cancel trip", async ({ page }, testInfo) => {
await page.getByRole("link", { name: "Ausfahrt eintragen" }).click(); await page.getByRole("link", { name: "Ausfahrt eintragen" }).click();
if (testInfo.project.name.includes("Mobile")) { if (testInfo.project.name.includes("Mobile")) {
// No left boat selector on mobile views // No left boat selector on mobile views
await page.getByText("Kaputtes Boot :-( (7 x)").nth(1).click(); await page.getByText("Kaputtes Boot :-( (7x)").nth(1).click();
await page.getByRole("option", { name: "Joe" }).click(); await page.getByRole("option", { name: "Joe" }).click();
} else { } else {
await page.getByText('2x').click(); await page.getByText('2x', { exact: true }).click();
await page.getByText("Joe", { exact: true }).click(); await page.getByText("Joe", { exact: true }).click();
} }
await page.getByPlaceholder("Ruderer auswählen").click(); await page.getByPlaceholder("Ruderer auswählen").click();
@ -53,10 +53,10 @@ test("Cox can start and finish trip", async ({ page }, testInfo) => {
await page.getByRole("link", { name: "Ausfahrt eintragen" }).click(); await page.getByRole("link", { name: "Ausfahrt eintragen" }).click();
if (testInfo.project.name.includes("Mobile")) { if (testInfo.project.name.includes("Mobile")) {
// No left boat selector on mobile views // No left boat selector on mobile views
await page.getByText("Kaputtes Boot :-( (7 x)").nth(1).click(); await page.getByText("Kaputtes Boot :-( (7x)").nth(1).click();
await page.getByRole("option", { name: "Joe" }).click(); await page.getByRole("option", { name: "Joe" }).click();
} else { } else {
await page.getByText('2x').click(); await page.getByText('2x', { exact: true }).click();
await page.getByText("Joe", { exact: true }).click(); await page.getByText("Joe", { exact: true }).click();
} }
await page.getByPlaceholder("Ruderer auswählen").click(); await page.getByPlaceholder("Ruderer auswählen").click();
@ -105,10 +105,10 @@ test("Kiosk can start and cancel trip", async ({ page }, testInfo) => {
await page.goto("/log/kiosk/ekrv2019/Linz"); await page.goto("/log/kiosk/ekrv2019/Linz");
if (testInfo.project.name.includes("Mobile")) { if (testInfo.project.name.includes("Mobile")) {
// No left boat selector on mobile views // No left boat selector on mobile views
await page.getByText("Kaputtes Boot :-( (7 x)").nth(1).click(); await page.getByText("Kaputtes Boot :-( (7x)").nth(1).click();
await page.getByRole("option", { name: "Joe" }).click(); await page.getByRole("option", { name: "Joe" }).click();
} else { } else {
await page.getByText('2x').click(); await page.getByText('2x', { exact: true }).click();
await page.getByText("Joe", { exact: true }).click(); await page.getByText("Joe", { exact: true }).click();
} }
await page.getByPlaceholder("Ruderer auswählen").click(); await page.getByPlaceholder("Ruderer auswählen").click();
@ -139,10 +139,10 @@ test("Kiosk can start and finish trip", async ({ page }, testInfo) => {
if (testInfo.project.name.includes("Mobile")) { if (testInfo.project.name.includes("Mobile")) {
// No left boat selector on mobile views // No left boat selector on mobile views
await page.getByText("Kaputtes Boot :-( (7 x)").nth(1).click(); await page.getByText("Kaputtes Boot :-( (7x)").nth(1).click();
await page.getByRole("option", { name: "Joe" }).click(); await page.getByRole("option", { name: "Joe" }).click();
} else { } else {
await page.getByText('2x').click(); await page.getByText('2x', { exact: true }).click();
await page.getByText("Joe", { exact: true }).click(); await page.getByText("Joe", { exact: true }).click();
} }
await page.getByPlaceholder("Ruderer auswählen").click(); await page.getByPlaceholder("Ruderer auswählen").click();

View File

@ -21,9 +21,9 @@ pub struct Boat {
pub boatbuilder: Option<String>, pub boatbuilder: Option<String>,
pub default_destination: Option<String>, pub default_destination: Option<String>,
#[serde(default = "bool::default")] #[serde(default = "bool::default")]
convert_handoperated_possible: bool, pub convert_handoperated_possible: bool,
#[serde(default = "bool::default")] #[serde(default = "bool::default")]
default_shipmaster_only_steering: bool, pub default_shipmaster_only_steering: bool,
#[serde(default = "bool::default")] #[serde(default = "bool::default")]
skull: bool, skull: bool,
#[serde(default = "bool::default")] #[serde(default = "bool::default")]
@ -46,6 +46,7 @@ pub struct BoatWithDetails {
damage: BoatDamage, damage: BoatDamage,
on_water: bool, on_water: bool,
reserved_today: bool, reserved_today: bool,
cat: String,
} }
#[derive(FromForm)] #[derive(FromForm)]
@ -179,11 +180,18 @@ AND date('now') BETWEEN start_date AND end_date;",
if boat.is_locked(db).await { if boat.is_locked(db).await {
damage = BoatDamage::Locked; damage = BoatDamage::Locked;
} }
let cat = if boat.default_shipmaster_only_steering {
format!("{}+", boat.amount_seats - 1)
} else {
format!("{}x", boat.amount_seats)
};
res.push(BoatWithDetails { res.push(BoatWithDetails {
damage, damage,
on_water: boat.on_water(db).await, on_water: boat.on_water(db).await,
reserved_today: boat.reserved_today(db).await, reserved_today: boat.reserved_today(db).await,
boat, boat,
cat,
}); });
} }
res res

View File

@ -126,6 +126,7 @@ pub enum LogbookCreateError {
NotYourEntry, NotYourEntry,
ArrivalSetButNotRemainingTwo, ArrivalSetButNotRemainingTwo,
OnlyAllowedToEndTripsEndingToday, OnlyAllowedToEndTripsEndingToday,
CantChangeHandoperatableStatusForThisBoat,
} }
impl From<LogbookUpdateError> for LogbookCreateError { impl From<LogbookUpdateError> for LogbookCreateError {
@ -302,6 +303,12 @@ ORDER BY departure DESC
return Err(LogbookCreateError::BoatNotFound); return Err(LogbookCreateError::BoatNotFound);
}; };
if log.shipmaster_only_steering != boat.default_shipmaster_only_steering {
if !boat.convert_handoperated_possible {
return Err(LogbookCreateError::CantChangeHandoperatableStatusForThisBoat);
}
}
if boat.amount_seats == 1 && log.rowers.is_empty() { if boat.amount_seats == 1 && log.rowers.is_empty() {
log.rowers = vec![created_by_user.id]; log.rowers = vec![created_by_user.id];
} }

View File

@ -214,6 +214,7 @@ async fn create_logbook(
Err(LogbookCreateError::NotYourEntry) => Flash::error(Redirect::to("/log"), "Nicht deine Ausfahrt!"), Err(LogbookCreateError::NotYourEntry) => Flash::error(Redirect::to("/log"), "Nicht deine Ausfahrt!"),
Err(LogbookCreateError::ArrivalSetButNotRemainingTwo) => Flash::error(Redirect::to("/log"), "Ankunftszeit gesetzt aber nicht Distanz + Strecke"), Err(LogbookCreateError::ArrivalSetButNotRemainingTwo) => Flash::error(Redirect::to("/log"), "Ankunftszeit gesetzt aber nicht Distanz + Strecke"),
Err(LogbookCreateError::OnlyAllowedToEndTripsEndingToday) => Flash::error(Redirect::to("/log"), "Nur Ausfahrten, die in der letzten Woche enden dürfen eingetragen werden. Für einen Nachtrag schreibe alle Daten Philipp (Tel. nr. siehe Signal oder it@rudernlinz.at)."), Err(LogbookCreateError::OnlyAllowedToEndTripsEndingToday) => Flash::error(Redirect::to("/log"), "Nur Ausfahrten, die in der letzten Woche enden dürfen eingetragen werden. Für einen Nachtrag schreibe alle Daten Philipp (Tel. nr. siehe Signal oder it@rudernlinz.at)."),
Err(LogbookCreateError::CantChangeHandoperatableStatusForThisBoat) => Flash::error(Redirect::to("/log"), "Handsteuer-Status dieses Boots kann nicht verändert werden."),
} }
} }

View File

@ -3,16 +3,14 @@
Inputs: boats Inputs: boats
#} #}
{% macro show_boats() %} {% macro show_boats() %}
{% for amount_seats, grouped_boats in boats | group_by(attribute="amount_seats") %} {% for amount_seats, grouped_boats in boats | group_by(attribute="cat") %}
<details> <details>
<summary class="font-bold cursor-pointer text-primary-900 dark:text-white border-t p-3 hover:bg-gray-100 dark:hover:bg-primary-950"> <summary class="font-bold cursor-pointer text-primary-900 dark:text-white border-t p-3 hover:bg-gray-100 dark:hover:bg-primary-950">
<span> <span>
{% if grouped_boats[0].external %} {% if grouped_boats[0].external %}
Vereinsfremde Boote Vereinsfremde Boote
{% elif grouped_boats[0].default_shipmaster_only_steering %}
{{ grouped_boats[0].amount_seats - 1 }}+
{% else %} {% else %}
{{ amount_seats }}x {{ grouped_boats[0].cat }}
{% endif %} {% endif %}
</span> </span>
<small class="text-gray-500 dark:text-gray-100">({{ grouped_boats | length }})</small> <small class="text-gray-500 dark:text-gray-100">({{ grouped_boats | length }})</small>
@ -78,7 +76,7 @@
</form> </form>
{% endmacro new %} {% endmacro new %}
{% macro boat_select(id="boat_id") %} {% macro boat_select(id="boat_id") %}
{{ macros::select(label="Boot", data=boats, name="boat_id", id=id, display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats", "on_water", "default_destination"], wrapper_class="col-span-4", show_seats=true) }} {{ macros::select(label="Boot", data=boats, name="boat_id", id=id, display=["name", " (","cat",")"], extras=["default_shipmaster_only_steering", "amount_seats", "on_water", "default_destination"], wrapper_class="col-span-4", show_seats=true) }}
{% endmacro boat_select %} {% endmacro boat_select %}
{% macro rower_select(id, selected, amount_seats='', class='', init='false', cox_on_boat='', steering_person_id='') %} {% macro rower_select(id, selected, amount_seats='', class='', init='false', cox_on_boat='', steering_person_id='') %}
{#{% if not amount_seats or amount_seats > 1 %}#} {#{% if not amount_seats or amount_seats > 1 %}#}