Merge branch 'staging' into clippy
This commit is contained in:
		@@ -147,6 +147,10 @@ WHERE trip.id=?
 | 
			
		||||
            return Err(CoxHelpError::DetailsLocked);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if planned_event.max_people == 0 {
 | 
			
		||||
            return Err(CoxHelpError::CanceledEvent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        match sqlx::query!(
 | 
			
		||||
            "INSERT INTO trip (cox_id, planned_event_id) VALUES(?, ?)",
 | 
			
		||||
            cox.id,
 | 
			
		||||
@@ -197,6 +201,9 @@ WHERE day=?
 | 
			
		||||
            return Err(TripUpdateError::TripDetailsDoesNotExist); //TODO: Remove?
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        let tripdetails = TripDetails::find_by_id(db, trip_details_id).await.unwrap();
 | 
			
		||||
        let was_already_cancelled = tripdetails.max_people == 0;
 | 
			
		||||
 | 
			
		||||
        sqlx::query!(
 | 
			
		||||
            "UPDATE trip_details SET max_people = ?, notes = ?, trip_type_id = ?, always_show = ?, is_locked = ? WHERE id = ?",
 | 
			
		||||
            update.max_people,
 | 
			
		||||
@@ -210,7 +217,7 @@ WHERE day=?
 | 
			
		||||
        .await
 | 
			
		||||
        .unwrap(); //Okay, as trip_details can only be created with proper DB backing
 | 
			
		||||
 | 
			
		||||
        if update.max_people == 0 {
 | 
			
		||||
        if update.max_people == 0 && !was_already_cancelled {
 | 
			
		||||
            let rowers = TripWithUserAndType::from(db, update.trip.clone())
 | 
			
		||||
                .await
 | 
			
		||||
                .rower;
 | 
			
		||||
@@ -249,6 +256,14 @@ WHERE day=?
 | 
			
		||||
            .await;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if update.max_people > 0 && was_already_cancelled {
 | 
			
		||||
            Notification::delete_by_action(
 | 
			
		||||
                db,
 | 
			
		||||
                &format!("remove_user_trip_with_trip_details_id:{}", trip_details_id),
 | 
			
		||||
            )
 | 
			
		||||
            .await;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        let trip_details = TripDetails::find_by_id(db, trip_details_id).await.unwrap();
 | 
			
		||||
        trip_details.check_free_spaces(db).await;
 | 
			
		||||
 | 
			
		||||
@@ -333,6 +348,7 @@ pub enum CoxHelpError {
 | 
			
		||||
    AlreadyRegisteredAsRower,
 | 
			
		||||
    AlreadyRegisteredAsCox,
 | 
			
		||||
    DetailsLocked,
 | 
			
		||||
    CanceledEvent,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[derive(Debug, PartialEq)]
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user