Compare commits
14 Commits
main
..
7635dd1649
| Author | SHA1 | Date | |
|---|---|---|---|
| 7635dd1649 | |||
| e65c34688f | |||
| 987feacbbe | |||
| c1fc75b187 | |||
| c2d8427e1a | |||
| 45f595e147 | |||
| de357c3db3 | |||
| b2157a31c5 | |||
| bfb3ae4b6e | |||
| 88a3e5f2d0 | |||
| 32c250536d | |||
| b9d0e2a2dc | |||
| b597898bdf | |||
| e90555214a |
Generated
+792
-839
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"
|
ics = "0.5"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
lettre = "0.11"
|
lettre = "0.11"
|
||||||
csv = "1.3"
|
csv = "1.4"
|
||||||
itertools = "0.14"
|
itertools = "0.14"
|
||||||
job_scheduler_ng = "2.2"
|
job_scheduler_ng = "2.4"
|
||||||
ureq = { version = "3.0", features = ["json"] }
|
ureq = { version = "3.3", features = ["json"] }
|
||||||
regex = "1.11"
|
regex = "1.12"
|
||||||
urlencoding = "2.1"
|
urlencoding = "2.1"
|
||||||
|
|
||||||
[target.'cfg(not(windows))'.dependencies]
|
[target.'cfg(not(windows))'.dependencies]
|
||||||
|
|||||||
@@ -271,52 +271,6 @@ ORDER BY created_at DESC
|
|||||||
Ok(())
|
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(
|
pub async fn verified(
|
||||||
&self,
|
&self,
|
||||||
db: &SqlitePool,
|
db: &SqlitePool,
|
||||||
|
|||||||
@@ -152,25 +152,6 @@ pub struct FormBoatDamageVerified<'r> {
|
|||||||
desc: &'r str,
|
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>")]
|
#[post("/<boatdamage_id>/verified", data = "<data>")]
|
||||||
async fn verified<'r>(
|
async fn verified<'r>(
|
||||||
db: &State<SqlitePool>,
|
db: &State<SqlitePool>,
|
||||||
@@ -195,7 +176,6 @@ pub fn routes() -> Vec<Route> {
|
|||||||
index_kiosk,
|
index_kiosk,
|
||||||
create,
|
create,
|
||||||
fixed,
|
fixed,
|
||||||
unfix,
|
|
||||||
verified,
|
verified,
|
||||||
create_from_kiosk
|
create_from_kiosk
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -55,13 +55,6 @@
|
|||||||
</small>
|
</small>
|
||||||
{% if boatdamage.fixed_at %}
|
{% 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>
|
<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 %}
|
{% else %}
|
||||||
{% if loggedin_user and loggedin_user.allowed_to_steer %}
|
{% if loggedin_user and loggedin_user.allowed_to_steer %}
|
||||||
<form action="/boatdamage/{{ boatdamage.id }}/fixed"
|
<form action="/boatdamage/{{ boatdamage.id }}/fixed"
|
||||||
|
|||||||
Reference in New Issue
Block a user