push
This commit is contained in:
@ -23,26 +23,30 @@ mod admin;
|
||||
mod auth;
|
||||
mod cox;
|
||||
|
||||
fn amount_days_to_show(is_cox: bool) -> i64 {
|
||||
if is_cox {
|
||||
let end_of_year = NaiveDate::from_ymd_opt(Local::now().year(), 12, 31).unwrap();
|
||||
end_of_year
|
||||
.signed_duration_since(Local::now().date_naive())
|
||||
.num_days()
|
||||
+ 1
|
||||
} else {
|
||||
6
|
||||
}
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
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();
|
||||
show_next_n_days = end_of_year
|
||||
.signed_duration_since(Local::now().date_naive())
|
||||
.num_days()
|
||||
+ 1;
|
||||
}
|
||||
|
||||
if user.is_cox || user.is_admin {
|
||||
let triptypes = TripType::all(db).await;
|
||||
context.insert("trip_types", &triptypes);
|
||||
}
|
||||
|
||||
let show_next_n_days = amount_days_to_show(user.is_cox);
|
||||
for i in 0..show_next_n_days {
|
||||
let date = (Local::now() + Duration::days(i)).date_naive();
|
||||
|
||||
|
Reference in New Issue
Block a user