only allow guests to register for specific events; don't even show them the other trips
This commit is contained in:
@ -9,19 +9,19 @@ pub struct PlannedEvent {
|
||||
pub id: i64,
|
||||
name: String,
|
||||
planned_amount_cox: i64,
|
||||
allow_guests: bool,
|
||||
trip_details_id: i64,
|
||||
planned_starting_time: String,
|
||||
max_people: i64,
|
||||
day: String,
|
||||
notes: Option<String>,
|
||||
pub allow_guests: bool,
|
||||
trip_type_id: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct PlannedEventWithUserAndTriptype {
|
||||
#[serde(flatten)]
|
||||
planned_event: PlannedEvent,
|
||||
pub planned_event: PlannedEvent,
|
||||
trip_type: Option<TripType>,
|
||||
cox_needed: bool,
|
||||
cox: Vec<Registration>,
|
||||
@ -42,7 +42,7 @@ impl PlannedEvent {
|
||||
Self,
|
||||
"
|
||||
SELECT
|
||||
planned_event.id, planned_event.name, planned_amount_cox, allow_guests, trip_details_id, planned_starting_time, max_people, day, notes, trip_type_id
|
||||
planned_event.id, planned_event.name, planned_amount_cox, trip_details_id, planned_starting_time, max_people, day, notes, allow_guests, trip_type_id
|
||||
FROM planned_event
|
||||
INNER JOIN trip_details ON planned_event.trip_details_id = trip_details.id
|
||||
WHERE planned_event.id like ?
|
||||
@ -61,7 +61,7 @@ WHERE planned_event.id like ?
|
||||
let day = format!("{day}");
|
||||
let events = sqlx::query_as!(
|
||||
PlannedEvent,
|
||||
"SELECT planned_event.id, planned_event.name, planned_amount_cox, allow_guests, trip_details_id, planned_starting_time, max_people, day, notes, trip_type_id
|
||||
"SELECT planned_event.id, planned_event.name, planned_amount_cox, trip_details_id, planned_starting_time, max_people, day, notes, allow_guests, trip_type_id
|
||||
FROM planned_event
|
||||
INNER JOIN trip_details ON planned_event.trip_details_id = trip_details.id
|
||||
WHERE day=?",
|
||||
@ -127,12 +127,13 @@ FROM user_trip WHERE trip_details_id = (SELECT trip_details_id FROM planned_even
|
||||
db: &SqlitePool,
|
||||
name: String,
|
||||
planned_amount_cox: i32,
|
||||
allow_guests: bool,
|
||||
trip_details: TripDetails,
|
||||
) {
|
||||
sqlx::query!(
|
||||
"INSERT INTO planned_event(name, planned_amount_cox, allow_guests, trip_details_id) VALUES(?, ?, ?, ?)",
|
||||
name, planned_amount_cox, allow_guests, trip_details.id
|
||||
"INSERT INTO planned_event(name, planned_amount_cox, trip_details_id) VALUES(?, ?, ?)",
|
||||
name,
|
||||
planned_amount_cox,
|
||||
trip_details.id
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
@ -170,7 +171,7 @@ mod test {
|
||||
|
||||
let trip_details = TripDetails::find_by_id(&pool, 1).await.unwrap();
|
||||
|
||||
PlannedEvent::create(&pool, "new-event".into(), 2, false, trip_details).await;
|
||||
PlannedEvent::create(&pool, "new-event".into(), 2, trip_details).await;
|
||||
|
||||
let res =
|
||||
PlannedEvent::get_for_day(&pool, NaiveDate::from_ymd_opt(1970, 1, 1).unwrap()).await;
|
||||
|
Reference in New Issue
Block a user