only allow guests to register for specific events; don't even show them the other trips

This commit is contained in:
2023-04-29 18:57:01 +02:00
parent 5b06eaeebc
commit bb4dba7bc9
12 changed files with 96 additions and 29 deletions

View File

@ -8,6 +8,7 @@ pub struct TripDetails {
max_people: i64,
day: String,
notes: Option<String>,
pub allow_guests: bool,
trip_type_id: Option<i64>,
}
@ -16,7 +17,7 @@ impl TripDetails {
sqlx::query_as!(
TripDetails,
"
SELECT id, planned_starting_time, max_people, day, notes, trip_type_id
SELECT id, planned_starting_time, max_people, day, notes, allow_guests, trip_type_id
FROM trip_details
WHERE id like ?
",
@ -34,14 +35,16 @@ WHERE id like ?
max_people: i32,
day: String,
notes: Option<String>,
allow_guests: bool,
trip_type_id: Option<i64>,
) -> i64 {
let query = sqlx::query!(
"INSERT INTO trip_details(planned_starting_time, max_people, day, notes, trip_type_id) VALUES(?, ?, ?, ?, ?)" ,
"INSERT INTO trip_details(planned_starting_time, max_people, day, notes, allow_guests, trip_type_id) VALUES(?, ?, ?, ?, ?, ?)" ,
planned_starting_time,
max_people,
day,
notes,
allow_guests,
trip_type_id
)
.execute(db)
@ -97,11 +100,29 @@ mod test {
let pool = testdb!();
assert_eq!(
TripDetails::create(&pool, "10:00".into(), 2, "1970-01-01".into(), None, None).await,
TripDetails::create(
&pool,
"10:00".into(),
2,
"1970-01-01".into(),
None,
false,
None
)
.await,
3,
);
assert_eq!(
TripDetails::create(&pool, "10:00".into(), 2, "1970-01-01".into(), None, None).await,
TripDetails::create(
&pool,
"10:00".into(),
2,
"1970-01-01".into(),
None,
false,
None
)
.await,
4,
);
}