Skip to content

Commit

Permalink
Don't delete empty event regs. on pos. delete
Browse files Browse the repository at this point in the history
  • Loading branch information
Celeo committed Feb 17, 2025
1 parent b98c11e commit 43994a6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 1 addition & 6 deletions vzdv-site/src/endpoints/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,7 @@ async fn post_delete_position(
.fetch_optional(&state.db)
.await?;
if event.is_some() {
// Need to clear out any existing registrations that are using that position
// and then delete any registrations that are now empty.
// need to clear out any existing registrations that are using that position
let mut tx = state.db.begin().await?;
sqlx::query(sql::CLEAR_REGISTRATIONS_FOR_POSITION_1)
.bind(pos_id)
Expand All @@ -682,10 +681,6 @@ async fn post_delete_position(
.bind(pos_id)
.execute(&mut *tx)
.await?;
sqlx::query(sql::DELETE_REGISTRATIONS_NOW_EMPTY)
.bind(id)
.execute(&mut *tx)
.await?;
sqlx::query(sql::DELETE_EVENT_POSITION)
.bind(pos_id)
.execute(&mut *tx)
Expand Down
11 changes: 11 additions & 0 deletions vzdv-site/templates/changelog.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@

<hr>

<div class="card shadow mb-3">
<div class="card-body">
<h5 class="card-title">2025-02-16</h5>
<div class="card-text">
<ul>
<li>Event registrations without position assignments are now longer deleted when a position in that event is deleted</li>
</ul>
</div>
</div>
</div>

<div class="card shadow mb-3">
<div class="card-body">
<h5 class="card-title">2025-02-07</h5>
Expand Down
2 changes: 0 additions & 2 deletions vzdv/src/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,6 @@ pub const CLEAR_REGISTRATIONS_FOR_POSITION_2: &str =
"UPDATE event_registration SET choice_2=NULL WHERE choice_2=$1";
pub const CLEAR_REGISTRATIONS_FOR_POSITION_3: &str =
"UPDATE event_registration SET choice_3=NULL WHERE choice_3=$1";
pub const DELETE_REGISTRATIONS_NOW_EMPTY: &str =
"DELETE from event_registration WHERE event_id=$1 AND choice_1 is NULL AND choice_2 is NULL AND choice_3 is NULL";

pub const GET_EVENT_POSITIONS: &str = "SELECT * FROM event_position WHERE event_id=$1";
pub const INSERT_EVENT_POSITION: &str =
Expand Down

0 comments on commit 43994a6

Please sign in to comment.