Merge branch 'main' into separate-scheckbuch-user
This commit is contained in:
commit
876451fc02
@ -313,7 +313,7 @@ WHERE trip_details.id=?
|
||||
}
|
||||
|
||||
//TODO: create unit test
|
||||
pub async fn update(&self, db: &SqlitePool, update: &EventUpdate<'_>) {
|
||||
pub async fn update(&self, db: &SqlitePool, user: &EventUser, update: &EventUpdate<'_>) {
|
||||
sqlx::query!(
|
||||
"UPDATE planned_event SET name = ?, planned_amount_cox = ? WHERE id = ?",
|
||||
update.name,
|
||||
@ -340,6 +340,20 @@ WHERE trip_details.id=?
|
||||
.await
|
||||
.unwrap(); //Okay, as planned_event can only be created with proper DB backing
|
||||
|
||||
Log::create(
|
||||
db,
|
||||
format!(
|
||||
"{} updated the event {} on {} at {} from {:?} to {:?}",
|
||||
user.user.name,
|
||||
self.name,
|
||||
tripdetails.day,
|
||||
tripdetails.planned_starting_time,
|
||||
self,
|
||||
update
|
||||
),
|
||||
)
|
||||
.await;
|
||||
|
||||
if !tripdetails.always_show && update.always_show {
|
||||
Self::advertise(
|
||||
db,
|
||||
@ -457,10 +471,16 @@ WHERE trip_details.id=?
|
||||
format!("event-{}@rudernlinz.at", self.id),
|
||||
"19900101T180000",
|
||||
);
|
||||
let time_str = self.planned_starting_time.replace(':', "");
|
||||
let formatted_time = if time_str.len() == 3 {
|
||||
format!("0{}", time_str)
|
||||
} else {
|
||||
time_str.clone() // TODO: remove again
|
||||
};
|
||||
vevent.push(DtStart::new(format!(
|
||||
"{}T{}00",
|
||||
self.day.replace('-', ""),
|
||||
self.planned_starting_time.replace(':', "")
|
||||
formatted_time
|
||||
)));
|
||||
|
||||
let original_time = NaiveTime::parse_from_str(&self.planned_starting_time, "%H:%M")
|
||||
|
@ -148,10 +148,17 @@ WHERE trip_details.id=?
|
||||
pub(crate) async fn get_vevent(self, user: &User) -> ics::Event {
|
||||
let mut vevent =
|
||||
ics::Event::new(format!("trip-{}@rudernlinz.at", self.id), "19900101T180000");
|
||||
let time_str = self.planned_starting_time.replace(':', "");
|
||||
let formatted_time = if time_str.len() == 3 {
|
||||
format!("0{}", time_str)
|
||||
} else {
|
||||
time_str
|
||||
};
|
||||
|
||||
vevent.push(DtStart::new(format!(
|
||||
"{}T{}00",
|
||||
self.day.replace('-', ""),
|
||||
self.planned_starting_time.replace(':', "")
|
||||
formatted_time
|
||||
)));
|
||||
|
||||
let original_time = NaiveTime::parse_from_str(&self.planned_starting_time, "%H:%M")
|
||||
|
@ -65,7 +65,7 @@ struct UpdateEventForm<'r> {
|
||||
async fn update(
|
||||
db: &State<SqlitePool>,
|
||||
data: Form<UpdateEventForm<'_>>,
|
||||
_admin: EventUser,
|
||||
user: EventUser,
|
||||
) -> Flash<Redirect> {
|
||||
let update = event::EventUpdate {
|
||||
name: data.name,
|
||||
@ -78,7 +78,7 @@ async fn update(
|
||||
};
|
||||
match Event::find_by_id(db, data.id).await {
|
||||
Some(planned_event) => {
|
||||
planned_event.update(db, &update).await;
|
||||
planned_event.update(db, &user, &update).await;
|
||||
Flash::success(Redirect::to("/planned"), "Event erfolgreich bearbeitet")
|
||||
}
|
||||
None => Flash::error(Redirect::to("/planned"), "Planned event id not found"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user