add cancellation, trip_type and notes to cal export
Some checks failed
CI/CD Pipeline / test (push) Failing after 9m56s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped

This commit is contained in:
2024-06-06 06:47:41 +02:00
parent 09cb8ebfa9
commit fa14cfbf83
3 changed files with 27 additions and 2 deletions

View File

@ -343,6 +343,10 @@ WHERE trip_details.id=?
Ok(())
}
pub fn is_cancelled(&self) -> bool {
self.max_people == 0
}
pub async fn get_ics_feed(db: &SqlitePool) -> String {
let mut calendar = ICalendar::new("2.0", "ics-rs");
@ -355,7 +359,20 @@ WHERE trip_details.id=?
event.day.replace('-', ""),
event.planned_starting_time.replace(':', "")
)));
vevent.push(Summary::new(event.name));
let mut name = String::new();
if event.is_cancelled() {
name.push_str("ABGESAGT :-( ");
}
name.push_str(&format!("{} ", event.name));
let tripdetails = event.trip_details(db).await;
if let Some(triptype) = tripdetails.triptype(db).await {
name.push_str(&format!("{} ", triptype.name))
}
if let Some(notes) = tripdetails.notes {
name.push_str(&format!("({notes}) "))
}
vevent.push(Summary::new(name));
calendar.add_event(vevent);
}
let mut buf = Vec::new();