add rss feed with common actions
This commit is contained in:
@ -11,6 +11,7 @@ use rocket_dyn_templates::{tera::Context, Template};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::model::{
|
||||
log::Log,
|
||||
user::User,
|
||||
usertrip::{UserTrip, UserTripError},
|
||||
Day,
|
||||
@ -51,7 +52,17 @@ async fn index(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage<'_
|
||||
#[get("/join/<trip_details_id>")]
|
||||
async fn join(db: &State<SqlitePool>, trip_details_id: i64, user: User) -> Flash<Redirect> {
|
||||
match UserTrip::create(db, user.id, trip_details_id).await {
|
||||
Ok(_) => Flash::success(Redirect::to("/"), "Erfolgreich angemeldet!"),
|
||||
Ok(_) => {
|
||||
Log::create(
|
||||
db,
|
||||
format!(
|
||||
"User {} registered for trip_details.id={}",
|
||||
user.name, trip_details_id
|
||||
),
|
||||
)
|
||||
.await;
|
||||
Flash::success(Redirect::to("/"), "Erfolgreich angemeldet!")
|
||||
}
|
||||
Err(UserTripError::EventAlreadyFull) => {
|
||||
Flash::error(Redirect::to("/"), "Event bereits ausgebucht!")
|
||||
}
|
||||
@ -68,6 +79,15 @@ async fn join(db: &State<SqlitePool>, trip_details_id: i64, user: User) -> Flash
|
||||
async fn remove(db: &State<SqlitePool>, trip_details_id: i64, user: User) -> Flash<Redirect> {
|
||||
UserTrip::delete(db, user.id, trip_details_id).await;
|
||||
|
||||
Log::create(
|
||||
db,
|
||||
format!(
|
||||
"User {} unregistered for trip_details.id={}",
|
||||
user.name, trip_details_id
|
||||
),
|
||||
)
|
||||
.await;
|
||||
|
||||
Flash::success(Redirect::to("/"), "Erfolgreich abgemeldet!")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user