forked from Ruderverein-Donau-Linz/rowt
send triptype to frontend
This commit is contained in:
@ -18,6 +18,7 @@ struct AddPlannedEventForm {
|
||||
planned_starting_time: String,
|
||||
max_people: i32,
|
||||
notes: Option<String>,
|
||||
trip_type: Option<i64>,
|
||||
}
|
||||
|
||||
#[post("/planned-event", data = "<data>")]
|
||||
@ -33,6 +34,7 @@ async fn create(
|
||||
data.max_people,
|
||||
data.day.clone(),
|
||||
data.notes.clone(),
|
||||
data.trip_type,
|
||||
)
|
||||
.await;
|
||||
|
||||
|
@ -21,6 +21,7 @@ struct AddTripForm {
|
||||
planned_starting_time: String,
|
||||
max_people: i32,
|
||||
notes: Option<String>,
|
||||
trip_type: Option<i64>,
|
||||
}
|
||||
|
||||
#[post("/trip", data = "<data>")]
|
||||
@ -32,6 +33,7 @@ async fn create(db: &State<SqlitePool>, data: Form<AddTripForm>, cox: CoxUser) -
|
||||
data.max_people,
|
||||
data.day.clone(),
|
||||
data.notes.clone(),
|
||||
data.trip_type,
|
||||
)
|
||||
.await;
|
||||
let trip_details = TripDetails::find_by_id(db, trip_details_id).await.unwrap(); //Okay, bc just
|
||||
|
@ -13,6 +13,7 @@ use sqlx::SqlitePool;
|
||||
use crate::model::{
|
||||
log::Log,
|
||||
tripdetails::TripDetails,
|
||||
triptype::TripType,
|
||||
user::User,
|
||||
usertrip::{UserTrip, UserTripError},
|
||||
Day,
|
||||
@ -26,6 +27,8 @@ mod cox;
|
||||
async fn index(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage<'_>>) -> Template {
|
||||
let mut days = Vec::new();
|
||||
|
||||
let mut context = Context::new();
|
||||
|
||||
let mut show_next_n_days = 6;
|
||||
if user.is_cox {
|
||||
let end_of_year = NaiveDate::from_ymd_opt(Local::now().year(), 12, 31).unwrap();
|
||||
@ -34,14 +37,16 @@ async fn index(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage<'_
|
||||
.num_days()
|
||||
+ 1;
|
||||
}
|
||||
if user.is_cox || user.is_admin {
|
||||
let triptypes = TripType::all(db).await;
|
||||
context.insert("trip_types", &triptypes);
|
||||
}
|
||||
|
||||
for i in 0..show_next_n_days {
|
||||
let date = (Local::now() + Duration::days(i)).date_naive();
|
||||
days.push(Day::new(db, date).await);
|
||||
}
|
||||
|
||||
let mut context = Context::new();
|
||||
|
||||
if let Some(msg) = flash {
|
||||
context.insert("flash", &msg.into_inner());
|
||||
}
|
||||
|
Reference in New Issue
Block a user