Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 51257e4b32 |
@@ -31,7 +31,6 @@ jobs:
|
||||
run: cd frontend && npx playwright install && npx playwright test --workers 1 --reporter html,line
|
||||
- uses: actions/upload-artifact@v3
|
||||
if: always()
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: playwright-report
|
||||
path: frontend/playwright-report/
|
||||
|
||||
Generated
+777
-830
File diff suppressed because it is too large
Load Diff
+4
-4
@@ -23,11 +23,11 @@ tera = { version = "1.20", features = ["date-locale"], optional = true}
|
||||
ics = "0.5"
|
||||
futures = "0.3"
|
||||
lettre = "0.11"
|
||||
csv = "1.3"
|
||||
csv = "1.4"
|
||||
itertools = "0.14"
|
||||
job_scheduler_ng = "2.2"
|
||||
ureq = { version = "3.0", features = ["json"] }
|
||||
regex = "1.11"
|
||||
job_scheduler_ng = "2.4"
|
||||
ureq = { version = "3.3", features = ["json"] }
|
||||
regex = "1.12"
|
||||
urlencoding = "2.1"
|
||||
|
||||
[target.'cfg(not(windows))'.dependencies]
|
||||
|
||||
@@ -11,7 +11,6 @@ import { defineConfig, devices } from '@playwright/test';
|
||||
*/
|
||||
export default defineConfig({
|
||||
testDir: './tests',
|
||||
timeout: process.env.CI ? 120000 : 30000,
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
|
||||
@@ -9,10 +9,21 @@ export async function resetDatabase(): Promise<void> {
|
||||
}
|
||||
|
||||
export async function login(page: Page, username: string, password: string): Promise<void> {
|
||||
// Clear cookies to ensure clean state
|
||||
await page.context().clearCookies();
|
||||
|
||||
// Navigate to auth page and wait for it to fully load
|
||||
await page.goto("/auth", { waitUntil: 'load' });
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
await page.getByPlaceholder("Name").click();
|
||||
await page.getByPlaceholder("Name").fill(username);
|
||||
await page.getByPlaceholder("Passwort").click();
|
||||
await page.getByPlaceholder("Passwort").fill(password);
|
||||
await page.getByPlaceholder("Passwort").press("Enter");
|
||||
await page.waitForURL(/\/(planned|log|$)/);
|
||||
|
||||
// Wait for navigation after form submission
|
||||
await Promise.all([
|
||||
page.waitForURL(/\/(planned|log|$)/, { timeout: 10000 }),
|
||||
page.getByPlaceholder("Passwort").press("Enter")
|
||||
]);
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ use rot::rest;
|
||||
use rot::tera;
|
||||
use rot::{scheduled, tera::Config};
|
||||
|
||||
use sqlx::{pool::PoolOptions, sqlite::SqliteConnectOptions, ConnectOptions};
|
||||
use sqlx::{ConnectOptions, pool::PoolOptions, sqlite::SqliteConnectOptions};
|
||||
|
||||
#[macro_use]
|
||||
extern crate rocket;
|
||||
|
||||
@@ -271,52 +271,6 @@ ORDER BY created_at DESC
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn unfix(&self, db: &SqlitePool, tech_user: &User) -> Result<(), String> {
|
||||
if self.user_id_verified.is_some() {
|
||||
return Err("Reparatur wurde bereits verifiziert und kann nicht mehr rückgängig gemacht werden.".into());
|
||||
}
|
||||
if self.user_id_fixed.is_none() {
|
||||
return Err("Reparatur wurde noch nicht eingetragen.".into());
|
||||
}
|
||||
|
||||
let boat = Boat::find_by_id(db, self.boat_id as i32)
|
||||
.await
|
||||
.ok_or("Boot gibt's ned")?;
|
||||
|
||||
Log::create(
|
||||
db,
|
||||
format!("Unfix boat damage id={} by user {:?}", self.id, tech_user),
|
||||
)
|
||||
.await;
|
||||
|
||||
sqlx::query!(
|
||||
"UPDATE boat_damage SET user_id_fixed=NULL, fixed_at=NULL WHERE id=?",
|
||||
self.id
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
let technicals =
|
||||
User::all_with_role(db, &Role::find_by_name(db, "tech").await.unwrap()).await;
|
||||
for technical in technicals {
|
||||
Notification::create(
|
||||
db,
|
||||
&technical,
|
||||
&format!(
|
||||
"{} hat die Reparatur des Bootschadens '{}' beim Boot '{}' als fehlerhaft eingetragen zurückgesetzt.",
|
||||
tech_user.name, self.desc, boat.name,
|
||||
),
|
||||
"Bootsschaden-Reparatur rückgängig gemacht",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn verified(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
|
||||
@@ -95,13 +95,13 @@ WHERE end_date >= ? AND start_date <= ?
|
||||
res
|
||||
}
|
||||
|
||||
pub async fn next_future(db: &SqlitePool) -> Vec<BoatReservationWithDetails> {
|
||||
pub async fn all_future(db: &SqlitePool) -> Vec<BoatReservationWithDetails> {
|
||||
let boatreservations = sqlx::query_as!(
|
||||
Self,
|
||||
"
|
||||
SELECT id, boat_id, start_date, end_date, time_desc, usage, user_id_applicant, user_id_confirmation, created_at
|
||||
FROM boat_reservation
|
||||
WHERE end_date >= CURRENT_DATE AND end_date <= date(CURRENT_DATE, '+3 days') ORDER BY end_date
|
||||
WHERE end_date >= CURRENT_DATE ORDER BY end_date
|
||||
"
|
||||
)
|
||||
.fetch_all(db)
|
||||
@@ -158,10 +158,10 @@ WHERE end_date >= CURRENT_DATE AND end_date <= date(CURRENT_DATE, '+3 days') ORD
|
||||
|
||||
grouped_reservations
|
||||
}
|
||||
pub async fn next_future_with_groups(
|
||||
pub async fn all_future_with_groups(
|
||||
db: &SqlitePool,
|
||||
) -> HashMap<String, Vec<BoatReservationWithDetails>> {
|
||||
let reservations = Self::next_future(db).await;
|
||||
let reservations = Self::all_future(db).await;
|
||||
Self::with_groups(reservations)
|
||||
}
|
||||
|
||||
|
||||
+2
-15
@@ -93,24 +93,11 @@ GROUP BY family.id;"
|
||||
}
|
||||
|
||||
pub async fn clean_families_without_members(db: &SqlitePool) {
|
||||
sqlx::query(
|
||||
"UPDATE user SET family_id = NULL
|
||||
WHERE family_id IN (
|
||||
SELECT family_id FROM user
|
||||
WHERE family_id IS NOT NULL
|
||||
GROUP BY family_id
|
||||
HAVING COUNT(*) = 1
|
||||
);",
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
sqlx::query(
|
||||
"DELETE FROM family
|
||||
WHERE id NOT IN (
|
||||
SELECT DISTINCT family_id
|
||||
FROM user
|
||||
SELECT DISTINCT family_id
|
||||
FROM user
|
||||
WHERE family_id IS NOT NULL
|
||||
);",
|
||||
)
|
||||
|
||||
@@ -152,25 +152,6 @@ pub struct FormBoatDamageVerified<'r> {
|
||||
desc: &'r str,
|
||||
}
|
||||
|
||||
#[post("/<boatdamage_id>/unfix")]
|
||||
async fn unfix(
|
||||
db: &State<SqlitePool>,
|
||||
boatdamage_id: i32,
|
||||
techuser: TechUser,
|
||||
) -> Flash<Redirect> {
|
||||
let Some(boatdamage) = BoatDamage::find_by_id(db, boatdamage_id).await else {
|
||||
return Flash::error(Redirect::to("/boatdamage"), "Bootsschaden nicht gefunden.");
|
||||
};
|
||||
let user: User = techuser.into_inner();
|
||||
match boatdamage.unfix(db, &user).await {
|
||||
Ok(_) => Flash::success(
|
||||
Redirect::to("/boatdamage"),
|
||||
"Reparatur wurde zurückgesetzt.",
|
||||
),
|
||||
Err(e) => Flash::error(Redirect::to("/boatdamage"), format!("Fehler: {e}")),
|
||||
}
|
||||
}
|
||||
|
||||
#[post("/<boatdamage_id>/verified", data = "<data>")]
|
||||
async fn verified<'r>(
|
||||
db: &State<SqlitePool>,
|
||||
@@ -195,7 +176,6 @@ pub fn routes() -> Vec<Route> {
|
||||
index_kiosk,
|
||||
create,
|
||||
fixed,
|
||||
unfix,
|
||||
verified,
|
||||
create_from_kiosk
|
||||
]
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
use chrono::NaiveDate;
|
||||
use rocket::{
|
||||
FromForm, Route, State,
|
||||
form::Form,
|
||||
get, post,
|
||||
request::FlashMessage,
|
||||
response::{Flash, Redirect},
|
||||
routes, FromForm, Route, State,
|
||||
routes,
|
||||
};
|
||||
use rocket_dyn_templates::Template;
|
||||
use sqlx::SqlitePool;
|
||||
@@ -26,7 +27,7 @@ async fn index_kiosk(
|
||||
flash: Option<FlashMessage<'_>>,
|
||||
_kiosk: KioskCookie,
|
||||
) -> Template {
|
||||
let boatreservations = BoatReservation::next_future(db).await;
|
||||
let boatreservations = BoatReservation::all_future(db).await;
|
||||
|
||||
let mut context = Context::new();
|
||||
if let Some(msg) = flash {
|
||||
@@ -55,7 +56,7 @@ async fn index(
|
||||
flash: Option<FlashMessage<'_>>,
|
||||
user: DonauLinzUser,
|
||||
) -> Template {
|
||||
let boatreservations = BoatReservation::next_future(db).await;
|
||||
let boatreservations = BoatReservation::all_future(db).await;
|
||||
|
||||
let mut context = Context::new();
|
||||
if let Some(msg) = flash {
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ async fn index(db: &SqlitePool, flash: Option<FlashMessage<'_>>, mut context: Co
|
||||
context.insert("planned_trips", &Trip::get_for_today(db).await);
|
||||
context.insert(
|
||||
"reservations",
|
||||
&BoatReservation::next_future_with_groups(db).await,
|
||||
&BoatReservation::all_future_with_groups(db).await,
|
||||
);
|
||||
context.insert("coxes", &coxes);
|
||||
context.insert("users", &users);
|
||||
|
||||
@@ -55,13 +55,6 @@
|
||||
</small>
|
||||
{% if boatdamage.fixed_at %}
|
||||
<small class="block text-gray-600 dark:text-gray-100">Repariert von {{ boatdamage.user_fixed.name }} am/um {{ boatdamage.fixed_at | date(format='%d.%m.%Y (%H:%M)') }}</small>
|
||||
{% if loggedin_user and "tech" in loggedin_user.roles and not boatdamage.verified_at %}
|
||||
<form action="/boatdamage/{{ boatdamage.id }}/unfix" method="post" class="mt-1">
|
||||
<input type="submit"
|
||||
class="btn btn-dark text-sm"
|
||||
value="Reparatur rückgängig" />
|
||||
</form>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if loggedin_user and loggedin_user.allowed_to_steer %}
|
||||
<form action="/boatdamage/{{ boatdamage.id }}/fixed"
|
||||
|
||||
@@ -40,7 +40,7 @@ function setChoiceByLabel(choicesInstance, label) {
|
||||
{% endmacro plannedtrips %}
|
||||
{% macro boatreservation() %}
|
||||
<div class="bg-white dark:bg-primary-900 rounded-md shadow pb-2 mt-3">
|
||||
<h2 class="h2">Reservierungen<br /><small>in den nächsten 3 Tagen</small></h2>
|
||||
<h2 class="h2">Reservierungen ({{ reservations | length }})</h2>
|
||||
<div class="grid grid-cols-1 gap-3 mb-3 w-full">
|
||||
{% for _, reservations_for_event in reservations %}
|
||||
{% set reservation = reservations_for_event[0] %}
|
||||
|
||||
Reference in New Issue
Block a user