fix-calender #737

Merged
philipp merged 3 commits from fix-calender into staging 2024-09-11 11:43:21 +02:00
2 changed files with 10 additions and 3 deletions
Showing only changes of commit 8666b014f2 - Show all commits

View File

@ -19,7 +19,7 @@ pub(crate) async fn get_personal_cal(db: &SqlitePool, user: &User) -> String {
let trips = Trip::all_with_user(db, user).await;
for trip in trips {
calendar.add_event(trip.get_vevent(db).await);
calendar.add_event(trip.get_vevent(user).await);
}
let mut buf = Vec::new();
write!(&mut buf, "{}", calendar).unwrap();

View File

@ -125,7 +125,7 @@ WHERE trip_details.id=?
.ok()
}
pub(crate) async fn get_vevent(self, db: &SqlitePool) -> ics::Event {
pub(crate) async fn get_vevent(self, user: &User) -> ics::Event {
let mut vevent = ics::Event::new(format!("{}@rudernlinz.at", self.id), "19900101T180000");
vevent.push(DtStart::new(format!(
"{}T{}00",
@ -143,7 +143,11 @@ WHERE trip_details.id=?
name.push_str("! :-( ");
}
name.push_str(&format!("Ruderausfahrt mit {} ", self.cox_name));
if self.cox_id == user.id {
name.push_str("Ruderausfahrt (selber ausgeschrieben)");
} else {
name.push_str(&format!("Ruderausfahrt mit {} ", self.cox_name));
}
vevent.push(Summary::new(name));
vevent
@ -168,6 +172,9 @@ INNER JOIN user ON trip.cox_id = user.id
let mut ret = Vec::new();
let trips = Self::all(db).await;
for trip in trips {
if user.id == trip.cox_id {
ret.push(trip.clone());
}
if let Some(trip_details_id) = trip.trip_details_id {
if UserTrip::find_by_userid_and_trip_detail_id(db, user.id, trip_details_id)
.await