Skip to content

Commit

Permalink
Remove a controller from event pos. on unreg.
Browse files Browse the repository at this point in the history
  • Loading branch information
Celeo committed Nov 1, 2024
1 parent 5538172 commit cf0c213
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions vzdv-site/src/endpoints/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ async fn api_register_unregister(
} else {
return Ok(StatusCode::UNAUTHORIZED);
};
// get the registration ID from event ID & CID
let existing_registration: Option<EventRegistration> =
sqlx::query_as(sql::GET_EVENT_REGISTRATION_FOR)
.bind(id)
Expand All @@ -537,6 +538,12 @@ async fn api_register_unregister(
.execute(&state.db)
.await?;
}
// remove the controller from any positions in this event
sqlx::query(sql::CLEAR_CID_FROM_EVENT_POSITIONS)
.bind(id)
.bind(cid)
.execute(&state.db)
.await?;
info!("{cid} removed their registration to event {id}");
Ok(StatusCode::ACCEPTED)
}
Expand Down
2 changes: 2 additions & 0 deletions vzdv/src/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ pub const INSERT_EVENT_POSITION: &str =
"INSERT INTO event_position VALUES (NULL, $1, $2, $3, NULL);";
pub const DELETE_EVENT_POSITION: &str = "DELETE FROM event_position WHERE id=$1";
pub const UPDATE_EVENT_POSITION_CONTROLLER: &str = "UPDATE event_position SET cid=$2 WHERE id=$1";
pub const CLEAR_CID_FROM_EVENT_POSITIONS: &str =
"UPDATE event_position SET cid=NULL WHERE event_id=$1 AND cid=$2";

pub const GET_STAFF_NOTES_FOR: &str = "SELECT * FROM staff_note WHERE cid=$1";
pub const GET_STAFF_NOTE: &str = "SELECT * FROM staff_note WHERE id=$1";
Expand Down

0 comments on commit cf0c213

Please sign in to comment.