diff --git a/src/model/personal/cal.rs b/src/model/personal/cal.rs index 88e6b7e..f0fc1ef 100644 --- a/src/model/personal/cal.rs +++ b/src/model/personal/cal.rs @@ -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(); diff --git a/src/model/trip.rs b/src/model/trip.rs index 46a97ca..dfeacc4 100644 --- a/src/model/trip.rs +++ b/src/model/trip.rs @@ -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