Skip to content
This repository has been archived by the owner on Jan 3, 2025. It is now read-only.

Commit

Permalink
Allow updating the waiting list through the update API and return his…
Browse files Browse the repository at this point in the history
…tory (#607)

* allow waiting list updates

* run rubocop
  • Loading branch information
FinnIckler authored Jun 21, 2024
1 parent 10712fd commit 2ae204e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/controllers/registration_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,23 @@ def process_update(update_request)
comment = update_request.dig('competing', 'comment')
event_ids = update_request.dig('competing', 'event_ids')
admin_comment = update_request.dig('competing', 'admin_comment')
waiting_list_position = update_request.dig('competing', 'waiting_list_position')
user_id = update_request[:user_id]

registration = Registration.find("#{@competition_id}-#{user_id}")
old_status = registration.competing_status
updated_registration = registration.update_competing_lane!({ status: status, comment: comment, event_ids: event_ids, admin_comment: admin_comment, guests: guests })
updated_registration = registration.update_competing_lane!({ status: status, comment: comment, event_ids: event_ids, admin_comment: admin_comment, guests: guests, waiting_list_position: waiting_list_position })
registration.history.add_entry(update_changes(update_request), 'user', @current_user, action_type(update_request))
if old_status == 'accepted' && status != 'accepted'
Registration.decrement_competitors_count(@competition_id)
elsif old_status != 'accepted' && status == 'accepted'
Registration.increment_competitors_count(@competition_id)
end

if Rails.env.production?
EmailApi.send_update_email(@competition_id, user_id, status, @current_user)
# Don't send email if we only change the waiting list position
if waiting_list_position.blank?
# commented out until shuryuken PR is merged
# EmailApi.send_update_email(@competition_id, user_id, status, @current_user)
end

{
Expand All @@ -147,6 +150,7 @@ def process_update(update_request)
comment: updated_registration.competing_comment,
admin_comment: updated_registration.admin_comment,
},
history: updated_registration.history.entries,
}
end

Expand Down

0 comments on commit 2ae204e

Please sign in to comment.