first draft of normannen deployment

This commit is contained in:
2024-12-11 16:24:20 +01:00
parent 2485f910fd
commit caeb9dd59f
75 changed files with 593 additions and 10939 deletions

View File

@@ -45,7 +45,7 @@ async fn create(
)
.await;
Flash::success(Redirect::to("/planned"), "Event hinzugefügt")
Flash::success(Redirect::to("/"), "Event hinzugefügt")
}
//TODO: add constraints (e.g. planned_amount_cox > 0)
@@ -79,21 +79,21 @@ async fn update(
match Event::find_by_id(db, data.id).await {
Some(planned_event) => {
planned_event.update(db, &update).await;
Flash::success(Redirect::to("/planned"), "Event erfolgreich bearbeitet")
Flash::success(Redirect::to("/"), "Event erfolgreich bearbeitet")
}
None => Flash::error(Redirect::to("/planned"), "Planned event id not found"),
None => Flash::error(Redirect::to("/"), "Planned event id not found"),
}
}
#[get("/planned-event/<id>/delete")]
async fn delete(db: &State<SqlitePool>, id: i64, _admin: EventUser) -> Flash<Redirect> {
let Some(event) = Event::find_by_id(db, id).await else {
return Flash::error(Redirect::to("/planned"), "Event does not exist");
return Flash::error(Redirect::to("/"), "Event does not exist");
};
match event.delete(db).await {
Ok(()) => Flash::success(Redirect::to("/planned"), "Event gelöscht"),
Err(e) => Flash::error(Redirect::to("/planned"), e),
Ok(()) => Flash::success(Redirect::to("/"), "Event gelöscht"),
Err(e) => Flash::error(Redirect::to("/"), e),
}
}
@@ -132,7 +132,7 @@ mod test {
let response = req.dispatch().await;
assert_eq!(response.status(), Status::SeeOther);
assert_eq!(response.headers().get("Location").next(), Some("/planned"));
assert_eq!(response.headers().get("Location").next(), Some("/"));
let flash_cookie = response
.cookies()
@@ -163,7 +163,7 @@ mod test {
let response = req.dispatch().await;
assert_eq!(response.status(), Status::SeeOther);
assert_eq!(response.headers().get("Location").next(), Some("/planned"));
assert_eq!(response.headers().get("Location").next(), Some("/"));
let flash_cookie = response
.cookies()
@@ -199,7 +199,7 @@ mod test {
let response = req.dispatch().await;
assert_eq!(response.status(), Status::SeeOther);
assert_eq!(response.headers().get("Location").next(), Some("/planned"));
assert_eq!(response.headers().get("Location").next(), Some("/"));
let flash_cookie = response
.cookies()
@@ -238,7 +238,7 @@ mod test {
let response = req.dispatch().await;
assert_eq!(response.status(), Status::SeeOther);
assert_eq!(response.headers().get("Location").next(), Some("/planned"));
assert_eq!(response.headers().get("Location").next(), Some("/"));
let flash_cookie = response
.cookies()
@@ -269,7 +269,7 @@ mod test {
let response = req.dispatch().await;
assert_eq!(response.status(), Status::SeeOther);
assert_eq!(response.headers().get("Location").next(), Some("/planned"));
assert_eq!(response.headers().get("Location").next(), Some("/"));
let flash_cookie = response
.cookies()