Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename registration_opened? to registration_open? #9709

Merged
merged 15 commits into from
Aug 7, 2024
Merged
2 changes: 1 addition & 1 deletion app/controllers/api/v0/competitions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def show
allow_registration_without_qualification refund_policy_percent use_wca_registration guests_per_registration_limit venue contact
force_comment_in_registration use_wca_registration external_registration_page guests_entry_fee_lowest_denomination guest_entry_status
information events_per_registration_limit],
methods: %w[url website short_name city venue_address venue_details latitude_degrees longitude_degrees country_iso2 event_ids registration_opened?
methods: %w[url website short_name city venue_address venue_details latitude_degrees longitude_degrees country_iso2 event_ids registration_is_open?
main_event_id number_of_bookmarks using_payment_integrations? uses_qualification? uses_cutoff? competition_series_ids],
include: %w[delegates organizers tabs],
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/competitions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def unbookmark
# Enables the New Registration Service for a Competition
def enable_v2
@competition = competition_from_params
if EnvConfig.WCA_LIVE_SITE? || @competition.registration_opened?
if EnvConfig.WCA_LIVE_SITE? || @competition.registration_is_open?
flash.now[:danger] = t('competitions.messages.cannot_activate_v2')
return redirect_to competition_path(@competition)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ def refund_payment

def create
@competition = competition_from_params
unless @competition.registration_opened? || @competition.user_can_pre_register?(current_user)
unless @competition.registration_is_open? || @competition.user_can_pre_register?(current_user)
flash[:danger] = "You cannot register for this competition, registration is closed"
redirect_to competition_path(@competition)
return
Expand Down
20 changes: 16 additions & 4 deletions app/models/competition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def warnings_for(user)
warnings[:results] = I18n.t('competitions.messages.results_not_posted')
end

if self.registration_full? && self.registration_opened?
if self.registration_full? && self.registration_is_open?
warnings[:waiting_list] = registration_full_message
end

Expand Down Expand Up @@ -721,7 +721,7 @@ def uses_new_registration_service?
end

def should_render_register_v2?(user)
uses_new_registration_service? && user.cannot_register_for_competition_reasons(self).empty? && (registration_opened? || user_can_pre_register?(user))
uses_new_registration_service? && user.cannot_register_for_competition_reasons(self).empty? && (registration_is_open? || user_can_pre_register?(user))
end

before_validation :unpack_delegate_organizer_ids
Expand Down Expand Up @@ -950,6 +950,10 @@ def can_edit_registration_fees?
end

def registration_opened?
use_wca_registration? && !cancelled? && !registration_not_yet_opened?
end

def registration_is_open?
dunkOnIT marked this conversation as resolved.
Show resolved Hide resolved
use_wca_registration? && !cancelled? && !registration_not_yet_opened? && !registration_past?
dunkOnIT marked this conversation as resolved.
Show resolved Hide resolved
end

Expand All @@ -973,6 +977,14 @@ def registration_status
end
end

def has_any_registrations?
if uses_new_registration_service?
self.microservice_registrations.any?
else
self.registrations.any?
end
end

def registration_range_specified?
registration_open.present? && registration_close.present?
end
Expand Down Expand Up @@ -1360,7 +1372,7 @@ def can_be_cancelled?
end

def orga_can_close_reg_full_limit?
registration_full? && registration_opened?
registration_full? && registration_is_open?
end

def display_name(short: false)
Expand Down Expand Up @@ -1826,7 +1838,7 @@ def to_competition_info
allow_registration_without_qualification refund_policy_percent use_wca_registration guests_per_registration_limit venue contact
force_comment_in_registration use_wca_registration external_registration_page guests_entry_fee_lowest_denomination guest_entry_status
information events_per_registration_limit],
methods: %w[url website short_name city venue_address venue_details latitude_degrees longitude_degrees country_iso2 event_ids registration_opened?
methods: %w[url website short_name city venue_address venue_details latitude_degrees longitude_degrees country_iso2 event_ids registration_is_open?
main_event_id number_of_bookmarks using_payment_integrations? uses_qualification? uses_cutoff? competition_series_ids registration_full?],
include: %w[delegates organizers],
}
Expand Down
4 changes: 2 additions & 2 deletions app/models/registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ def to_be_paid_through_wca?
end

def show_payment_form?
competition.registration_opened? && to_be_paid_through_wca?
competition.registration_is_open? && to_be_paid_through_wca?
end

def show_details?(user)
(competition.registration_opened? || !(new_or_deleted?)) || (competition.user_can_pre_register?(user))
(competition.registration_is_open? || !(new_or_deleted?)) || (competition.user_can_pre_register?(user))
end

def record_payment(
Expand Down
7 changes: 4 additions & 3 deletions app/views/competitions/_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,23 @@
icon: "align left",
}
end
if !EnvConfig.WCA_LIVE_SITE? && current_user&.can_manage_competition?(@competition) && [email protected]_new_registration_service? && !@competition.registration_opened?
if !EnvConfig.WCA_LIVE_SITE? && current_user&.can_manage_competition?(@competition) && [email protected]_new_registration_service? && !@competition.registration_is_open?
nav_items << {
text: t('.menu.enable_v2'),
path: enable_v2_path(@competition),
icon: "lightbulb",
}
end
unless @competition.results_posted?
if @competition.announced? && !@competition.results_posted?
if @competition.use_wca_registration?
nav_items << {
text: t('.menu.register'),
path: competition_register_path(@competition),
icon: "sign in alt"
}
end
if @competition.registrations.any?

if @competition.registration_opened? && @competition.has_any_registrations?
event_icons = @competition.events.map do |event|
{ text: event.id, path: competition_psych_sheet_event_path(@competition, event.id), cubing_icon: event.id, title: event.name }
end unless @competition.uses_new_registration_service?
Expand Down
2 changes: 1 addition & 1 deletion app/views/registrations/register.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<%= t 'registrations.contact_organizer' %>
<% end %>
<hr/>
<% elsif @competition.registration_opened? %>
<% elsif @competition.registration_is_open? %>
<% unless user_may_register %>
<%= alert :danger do %>
<%= t 'registrations.please_fix_profile_html', comp: @competition.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const maxCommentLength = 240;
const potentialWarnings = (competitionInfo) => {
const warnings = [];
// Organizer Pre Registration
if (!competitionInfo['registration_opened?']) {
if (!competitionInfo['registration_is_open?']) {
warnings.push(i18n.t('competitions.registration_v2.register.early_registration'));
}
// Favourites Competition
Expand Down