updates #715
@@ -233,6 +233,7 @@ WHERE trip_details.id=?
 | 
			
		||||
        db: &SqlitePool,
 | 
			
		||||
        name: &str,
 | 
			
		||||
        planned_amount_cox: i32,
 | 
			
		||||
        always_show: bool,
 | 
			
		||||
        trip_details: &TripDetails,
 | 
			
		||||
    ) {
 | 
			
		||||
        if trip_details.always_show {
 | 
			
		||||
@@ -245,6 +246,10 @@ WHERE trip_details.id=?
 | 
			
		||||
            .await;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if always_show && !trip_details.always_show {
 | 
			
		||||
            trip_details.set_always_show(db, true).await;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        sqlx::query!(
 | 
			
		||||
            "INSERT INTO planned_event(name, planned_amount_cox, trip_details_id) VALUES(?, ?, ?)",
 | 
			
		||||
            name,
 | 
			
		||||
 
 | 
			
		||||
@@ -173,6 +173,17 @@ WHERE day = ? AND planned_starting_time = ?
 | 
			
		||||
        query.last_insert_rowid()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub async fn set_always_show(&self, db: &SqlitePool, value: bool) {
 | 
			
		||||
        sqlx::query!(
 | 
			
		||||
            "UPDATE trip_details SET always_show = ? WHERE id = ?",
 | 
			
		||||
            value,
 | 
			
		||||
            self.id
 | 
			
		||||
        )
 | 
			
		||||
        .execute(db)
 | 
			
		||||
        .await
 | 
			
		||||
        .unwrap(); //Okay, as planned_event can only be created with proper DB backing
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub async fn is_full(&self, db: &SqlitePool) -> bool {
 | 
			
		||||
        let amount_currently_registered = sqlx::query!(
 | 
			
		||||
            "SELECT COUNT(*) as count FROM user_trip WHERE trip_details_id = ?",
 | 
			
		||||
 
 | 
			
		||||
@@ -18,6 +18,7 @@ use crate::model::{
 | 
			
		||||
struct AddEventForm<'r> {
 | 
			
		||||
    name: &'r str,
 | 
			
		||||
    planned_amount_cox: i32,
 | 
			
		||||
    always_show: bool,
 | 
			
		||||
    tripdetails: TripDetailsToAdd<'r>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -34,7 +35,14 @@ async fn create(
 | 
			
		||||
                                                                                    //just created
 | 
			
		||||
                                                                                    //the object
 | 
			
		||||
 | 
			
		||||
    Event::create(db, data.name, data.planned_amount_cox, &trip_details).await;
 | 
			
		||||
    Event::create(
 | 
			
		||||
        db,
 | 
			
		||||
        data.name,
 | 
			
		||||
        data.planned_amount_cox,
 | 
			
		||||
        data.always_show,
 | 
			
		||||
        &trip_details,
 | 
			
		||||
    )
 | 
			
		||||
    .await;
 | 
			
		||||
 | 
			
		||||
    Flash::success(Redirect::to("/planned"), "Event hinzugefügt")
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,7 @@
 | 
			
		||||
        {{ macros::input(label='Anzahl Steuerleute', name='planned_amount_cox', type='number', required=true, min='0') }}
 | 
			
		||||
        {{ macros::input(label='Anzahl Ruderer (ohne Steuerperson)', name='tripdetails.max_people', type='number', required=true, min='0') }}
 | 
			
		||||
        {{ macros::checkbox(label='Scheckbuch-Anmeldungen erlauben', name='tripdetails.allow_guests') }}
 | 
			
		||||
        {{ macros::checkbox(label='Immer anzeigen', name='tripdetails.always_show') }}
 | 
			
		||||
        {{ macros::checkbox(label='Immer anzeigen', name='always_show') }}
 | 
			
		||||
        {{ macros::input(label='Anmerkungen', name='tripdetails.notes', type='input') }}
 | 
			
		||||
        {{ macros::select(label='Typ', data=trip_types, name='tripdetails.trip_type', default='Reguläre Ausfahrt') }}
 | 
			
		||||
        <input value="Erstellen" class="w-full btn btn-primary" type="submit" />
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user