add logs
This commit is contained in:
parent
ec046f4cf5
commit
cfd0ccc8c2
@ -162,6 +162,15 @@ async fn create_logbook(
|
|||||||
data: Form<LogToAdd>,
|
data: Form<LogToAdd>,
|
||||||
user: &NonGuestUser,
|
user: &NonGuestUser,
|
||||||
) -> Flash<Redirect> {
|
) -> Flash<Redirect> {
|
||||||
|
Log::create(
|
||||||
|
db,
|
||||||
|
format!(
|
||||||
|
"User {} tries to create log entry={:?}",
|
||||||
|
user.user.name, data
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
match Logbook::create(
|
match Logbook::create(
|
||||||
db,
|
db,
|
||||||
data.into_inner(),
|
data.into_inner(),
|
||||||
@ -202,6 +211,15 @@ async fn create_kiosk(
|
|||||||
_kiosk: KioskCookie,
|
_kiosk: KioskCookie,
|
||||||
) -> Flash<Redirect> {
|
) -> Flash<Redirect> {
|
||||||
let creator = User::find_by_id(db, data.shipmaster as i32).await.unwrap();
|
let creator = User::find_by_id(db, data.shipmaster as i32).await.unwrap();
|
||||||
|
Log::create(
|
||||||
|
db,
|
||||||
|
format!(
|
||||||
|
"Kiosk tries to create log for shipmaster {} entry={:?}",
|
||||||
|
creator.name, data
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
create_logbook(db, data, &NonGuestUser::try_from(creator).unwrap()).await //TODO: fixme
|
create_logbook(db, data, &NonGuestUser::try_from(creator).unwrap()).await //TODO: fixme
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,6 +255,13 @@ async fn home_kiosk(
|
|||||||
_kiosk: KioskCookie,
|
_kiosk: KioskCookie,
|
||||||
) -> Flash<Redirect> {
|
) -> Flash<Redirect> {
|
||||||
let logbook = Logbook::find_by_id(db, logbook_id).await.unwrap(); //TODO: fixme
|
let logbook = Logbook::find_by_id(db, logbook_id).await.unwrap(); //TODO: fixme
|
||||||
|
|
||||||
|
Log::create(
|
||||||
|
db,
|
||||||
|
format!("Kiosk tries to finish log entry {logbook_id} {data:?}"),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
home_logbook(
|
home_logbook(
|
||||||
db,
|
db,
|
||||||
data,
|
data,
|
||||||
@ -258,6 +283,15 @@ async fn home(
|
|||||||
logbook_id: i32,
|
logbook_id: i32,
|
||||||
user: NonGuestUser,
|
user: NonGuestUser,
|
||||||
) -> Flash<Redirect> {
|
) -> Flash<Redirect> {
|
||||||
|
Log::create(
|
||||||
|
db,
|
||||||
|
format!(
|
||||||
|
"User {} tries to finish log entry {logbook_id} {data:?}",
|
||||||
|
user.user.name
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
home_logbook(db, data, logbook_id, &user).await
|
home_logbook(db, data, logbook_id, &user).await
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,6 +299,11 @@ async fn home(
|
|||||||
async fn delete(db: &State<SqlitePool>, logbook_id: i32, user: User) -> Flash<Redirect> {
|
async fn delete(db: &State<SqlitePool>, logbook_id: i32, user: User) -> Flash<Redirect> {
|
||||||
let logbook = Logbook::find_by_id(db, logbook_id).await;
|
let logbook = Logbook::find_by_id(db, logbook_id).await;
|
||||||
if let Some(logbook) = logbook {
|
if let Some(logbook) = logbook {
|
||||||
|
Log::create(
|
||||||
|
db,
|
||||||
|
format!("User {} tries to delete log entry {logbook_id}", user.name),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
match logbook.delete(db, &user).await {
|
match logbook.delete(db, &user).await {
|
||||||
Ok(_) => Flash::success(
|
Ok(_) => Flash::success(
|
||||||
Redirect::to("/log"),
|
Redirect::to("/log"),
|
||||||
@ -294,6 +333,7 @@ async fn delete_kiosk(
|
|||||||
let cox = User::find_by_id(db, logbook.shipmaster as i32)
|
let cox = User::find_by_id(db, logbook.shipmaster as i32)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
Log::create(db, format!("Kiosk tries to delete log entry {logbook_id} ")).await;
|
||||||
match logbook.delete(db, &cox).await {
|
match logbook.delete(db, &cox).await {
|
||||||
Ok(_) => Flash::success(
|
Ok(_) => Flash::success(
|
||||||
Redirect::to("/log"),
|
Redirect::to("/log"),
|
||||||
|
Loading…
Reference in New Issue
Block a user