add is_pinned functionality
This commit is contained in:
@ -17,6 +17,7 @@ struct AddPlannedEventForm<'r> {
|
||||
allow_guests: bool,
|
||||
planned_starting_time: &'r str,
|
||||
max_people: i32,
|
||||
always_show: bool,
|
||||
notes: Option<&'r str>,
|
||||
trip_type: Option<i64>,
|
||||
}
|
||||
@ -42,7 +43,14 @@ async fn create(
|
||||
//just created
|
||||
//the object
|
||||
|
||||
PlannedEvent::create(db, data.name, data.planned_amount_cox, trip_details).await;
|
||||
PlannedEvent::create(
|
||||
db,
|
||||
data.name,
|
||||
data.planned_amount_cox,
|
||||
data.always_show,
|
||||
trip_details,
|
||||
)
|
||||
.await;
|
||||
|
||||
Flash::success(Redirect::to("/"), "Successfully planned the event")
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ use sqlx::SqlitePool;
|
||||
|
||||
use crate::model::{
|
||||
log::Log,
|
||||
planned_event::PlannedEvent,
|
||||
tripdetails::TripDetails,
|
||||
triptype::TripType,
|
||||
user::User,
|
||||
@ -57,9 +58,18 @@ async fn index(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage<'_
|
||||
let date = (Local::now() + Duration::days(i)).date_naive();
|
||||
|
||||
if user.is_guest {
|
||||
days.push(Day::new_guest(db, date).await);
|
||||
days.push(Day::new_guest(db, date, false).await);
|
||||
} else {
|
||||
days.push(Day::new(db, date).await);
|
||||
days.push(Day::new(db, date, false).await);
|
||||
}
|
||||
}
|
||||
|
||||
for date in PlannedEvent::pinned_days(db, show_next_n_days).await {
|
||||
//TODO: extract the 2 if's (this block + prev. one) after the 2 for's
|
||||
if user.is_guest {
|
||||
days.push(Day::new_guest(db, date, true).await);
|
||||
} else {
|
||||
days.push(Day::new(db, date, true).await);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user