From 3fb011a5190bd16b800d19e489d1566809f8e507 Mon Sep 17 00:00:00 2001 From: Duncan Date: Mon, 29 Jul 2024 14:15:49 +0200 Subject: [PATCH 01/14] most basic implementation --- app/views/competitions/_nav.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/competitions/_nav.html.erb b/app/views/competitions/_nav.html.erb index 916dd8702b..70ab944557 100644 --- a/app/views/competitions/_nav.html.erb +++ b/app/views/competitions/_nav.html.erb @@ -141,7 +141,8 @@ icon: "sign in alt" } end - if @competition.registrations.any? + + if @competition.registration_opened? 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? From e4a367dd2df0e85bc1051265a0298c45da07aaa6 Mon Sep 17 00:00:00 2001 From: Duncan Date: Mon, 29 Jul 2024 14:51:41 +0200 Subject: [PATCH 02/14] still showing when registration closes --- app/views/competitions/_nav.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/competitions/_nav.html.erb b/app/views/competitions/_nav.html.erb index 70ab944557..a11547732d 100644 --- a/app/views/competitions/_nav.html.erb +++ b/app/views/competitions/_nav.html.erb @@ -142,7 +142,7 @@ } end - if @competition.registration_opened? + if !@competition.registration_not_yet_opened? 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? From 3f9ee5ccf9b0d6109c28543823896c9166b72e69 Mon Sep 17 00:00:00 2001 From: Duncan Date: Thu, 1 Aug 2024 20:38:15 +0200 Subject: [PATCH 03/14] added check for # registrations and register display logic --- app/views/competitions/_nav.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/competitions/_nav.html.erb b/app/views/competitions/_nav.html.erb index a11547732d..5c59afae4c 100644 --- a/app/views/competitions/_nav.html.erb +++ b/app/views/competitions/_nav.html.erb @@ -133,7 +133,7 @@ icon: "lightbulb", } end - unless @competition.results_posted? + if @competition.announced? && !@competition.results_posted? if @competition.use_wca_registration? nav_items << { text: t('.menu.register'), @@ -142,7 +142,7 @@ } end - if !@competition.registration_not_yet_opened? + if !@competition.registration_not_yet_opened? && (@competition.registrations.any? || @competition.microservice_registrations.any?) 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? From 82c34d3ca85dac17b74f3d21f3a79a2d8f9c2882 Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 6 Aug 2024 10:00:01 +0200 Subject: [PATCH 04/14] added WCA_REGISTRATIONS_URL in test --- .env.test | 1 + 1 file changed, 1 insertion(+) diff --git a/.env.test b/.env.test index dd3ee973cf..d9efabe521 100644 --- a/.env.test +++ b/.env.test @@ -28,4 +28,5 @@ PAYPAL_CLIENT_ID=AVOWeybtlJY6DJCDIu6LO64bVrzlsO9DiVFEFTnzraC3S5p4pJefSapwLUaRiro PAYPAL_CLIENT_SECRET=EIknLp919Gbuj2CYmEWECyKH5HwJTWQNuqFuCr1qFMrGNzwkF8dD0VkwzwI3P7LIjXeq_sGFElWaRxCj PAYPAL_ATTRIBUTION_CODE=FLAVORsb-noyt529176316_MP PAYPAL_BASE_URL=https://api-m.sandbox.paypal.com +WCA_REGISTRATIONS_URL=http://localhost:8000 WCA_REGISTRATIONS_BACKEND_URL=http://wca_registration_handler:3000 From fd09eae2b39ad7fee30fca4ee040432e1aa4ca19 Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 6 Aug 2024 11:11:07 +0200 Subject: [PATCH 05/14] fixed check for registrations throwing error in tests --- app/models/competition.rb | 8 ++++++++ app/views/competitions/_nav.html.erb | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/competition.rb b/app/models/competition.rb index 04e0ff5aa1..2fc581e072 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -973,6 +973,14 @@ def registration_status end end + def has_any_regisrations? + if uses_new_registration_service? + return self.registrations.any? + else + return self.microservice_registrations.any? + end + end + def registration_range_specified? registration_open.present? && registration_close.present? end diff --git a/app/views/competitions/_nav.html.erb b/app/views/competitions/_nav.html.erb index 5c59afae4c..d547de6433 100644 --- a/app/views/competitions/_nav.html.erb +++ b/app/views/competitions/_nav.html.erb @@ -142,7 +142,7 @@ } end - if !@competition.registration_not_yet_opened? && (@competition.registrations.any? || @competition.microservice_registrations.any?) + if !@competition.registration_not_yet_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? From 80393b510deb0a51622257e3b907a20c986e29f7 Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 6 Aug 2024 11:17:25 +0200 Subject: [PATCH 06/14] rubocop --- app/models/competition.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/competition.rb b/app/models/competition.rb index 2fc581e072..dc2e2f8905 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -975,9 +975,9 @@ def registration_status def has_any_regisrations? if uses_new_registration_service? - return self.registrations.any? + self.registrations.any? else - return self.microservice_registrations.any? + self.microservice_registrations.any? end end From 91193a3fdd13b57bc9d8656a1dca33b5304617dd Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 6 Aug 2024 11:56:56 +0200 Subject: [PATCH 07/14] fixed test failures --- .env.test | 1 - app/models/competition.rb | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.env.test b/.env.test index d9efabe521..dd3ee973cf 100644 --- a/.env.test +++ b/.env.test @@ -28,5 +28,4 @@ PAYPAL_CLIENT_ID=AVOWeybtlJY6DJCDIu6LO64bVrzlsO9DiVFEFTnzraC3S5p4pJefSapwLUaRiro PAYPAL_CLIENT_SECRET=EIknLp919Gbuj2CYmEWECyKH5HwJTWQNuqFuCr1qFMrGNzwkF8dD0VkwzwI3P7LIjXeq_sGFElWaRxCj PAYPAL_ATTRIBUTION_CODE=FLAVORsb-noyt529176316_MP PAYPAL_BASE_URL=https://api-m.sandbox.paypal.com -WCA_REGISTRATIONS_URL=http://localhost:8000 WCA_REGISTRATIONS_BACKEND_URL=http://wca_registration_handler:3000 diff --git a/app/models/competition.rb b/app/models/competition.rb index dc2e2f8905..96b9a4106d 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -973,11 +973,11 @@ def registration_status end end - def has_any_regisrations? + def has_any_registrations? if uses_new_registration_service? - self.registrations.any? - else self.microservice_registrations.any? + else + self.registrations.any? end end From 6a192a8daa6657c6b1dbc1c888c1ad93d0fe576d Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 6 Aug 2024 14:34:25 +0200 Subject: [PATCH 08/14] changed registration_opened? method definition --- app/models/competition.rb | 4 ++++ app/views/competitions/_nav.html.erb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/competition.rb b/app/models/competition.rb index 96b9a4106d..71d7eb783f 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -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? use_wca_registration? && !cancelled? && !registration_not_yet_opened? && !registration_past? end diff --git a/app/views/competitions/_nav.html.erb b/app/views/competitions/_nav.html.erb index d547de6433..c4cc7be86d 100644 --- a/app/views/competitions/_nav.html.erb +++ b/app/views/competitions/_nav.html.erb @@ -142,7 +142,7 @@ } end - if !@competition.registration_not_yet_opened? && @competition.has_any_registrations? + 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? From bc4dee3b885180afb857686e2469d807953e41f2 Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 6 Aug 2024 15:35:12 +0200 Subject: [PATCH 09/14] changed registration_opened? usage to registration_is_open? --- app/controllers/api/v0/competitions_controller.rb | 2 +- app/controllers/competitions_controller.rb | 2 +- app/controllers/registrations_controller.rb | 2 +- app/models/competition.rb | 8 ++++---- app/models/registration.rb | 4 ++-- app/views/competitions/_nav.html.erb | 2 +- app/views/registrations/register.html.erb | 2 +- .../components/RegistrationsV2/Register/CompetingStep.jsx | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/controllers/api/v0/competitions_controller.rb b/app/controllers/api/v0/competitions_controller.rb index adde2c3256..4956963656 100644 --- a/app/controllers/api/v0/competitions_controller.rb +++ b/app/controllers/api/v0/competitions_controller.rb @@ -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], } diff --git a/app/controllers/competitions_controller.rb b/app/controllers/competitions_controller.rb index e691591752..86066c2754 100644 --- a/app/controllers/competitions_controller.rb +++ b/app/controllers/competitions_controller.rb @@ -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 diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 4003d74df3..c00c35377c 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -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 diff --git a/app/models/competition.rb b/app/models/competition.rb index 71d7eb783f..543586160d 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -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 @@ -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 @@ -1372,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) @@ -1838,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], } diff --git a/app/models/registration.rb b/app/models/registration.rb index 1f18976fde..e273434baa 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -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( diff --git a/app/views/competitions/_nav.html.erb b/app/views/competitions/_nav.html.erb index c4cc7be86d..83499a1481 100644 --- a/app/views/competitions/_nav.html.erb +++ b/app/views/competitions/_nav.html.erb @@ -126,7 +126,7 @@ icon: "align left", } end - if !EnvConfig.WCA_LIVE_SITE? && current_user&.can_manage_competition?(@competition) && !@competition.uses_new_registration_service? && !@competition.registration_opened? + if !EnvConfig.WCA_LIVE_SITE? && current_user&.can_manage_competition?(@competition) && !@competition.uses_new_registration_service? && !@competition.registration_is_open? nav_items << { text: t('.menu.enable_v2'), path: enable_v2_path(@competition), diff --git a/app/views/registrations/register.html.erb b/app/views/registrations/register.html.erb index c12ae43533..277cf0f3ec 100644 --- a/app/views/registrations/register.html.erb +++ b/app/views/registrations/register.html.erb @@ -53,7 +53,7 @@ <%= t 'registrations.contact_organizer' %> <% end %>
- <% 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, diff --git a/app/webpacker/components/RegistrationsV2/Register/CompetingStep.jsx b/app/webpacker/components/RegistrationsV2/Register/CompetingStep.jsx index 3176fcbb04..95a2345981 100644 --- a/app/webpacker/components/RegistrationsV2/Register/CompetingStep.jsx +++ b/app/webpacker/components/RegistrationsV2/Register/CompetingStep.jsx @@ -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 From 8e94e90fc05c21bf6ca136c9af695f35a26de0a5 Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 7 Aug 2024 10:03:44 +0200 Subject: [PATCH 10/14] changed registration_is_open to registration_open? --- app/controllers/api/v0/competitions_controller.rb | 2 +- app/controllers/competitions_controller.rb | 2 +- app/controllers/registrations_controller.rb | 2 +- app/models/competition.rb | 14 +++++--------- app/models/registration.rb | 4 ++-- app/views/competitions/_nav.html.erb | 2 +- app/views/registrations/register.html.erb | 2 +- .../RegistrationsV2/Register/CompetingStep.jsx | 2 +- 8 files changed, 13 insertions(+), 17 deletions(-) diff --git a/app/controllers/api/v0/competitions_controller.rb b/app/controllers/api/v0/competitions_controller.rb index 4956963656..5a48ef02ff 100644 --- a/app/controllers/api/v0/competitions_controller.rb +++ b/app/controllers/api/v0/competitions_controller.rb @@ -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_is_open? + methods: %w[url website short_name city venue_address venue_details latitude_degrees longitude_degrees country_iso2 event_ids registration_open? main_event_id number_of_bookmarks using_payment_integrations? uses_qualification? uses_cutoff? competition_series_ids], include: %w[delegates organizers tabs], } diff --git a/app/controllers/competitions_controller.rb b/app/controllers/competitions_controller.rb index 86066c2754..1b99f74c0a 100644 --- a/app/controllers/competitions_controller.rb +++ b/app/controllers/competitions_controller.rb @@ -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_is_open? + if EnvConfig.WCA_LIVE_SITE? || @competition.registration_open? flash.now[:danger] = t('competitions.messages.cannot_activate_v2') return redirect_to competition_path(@competition) end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index c00c35377c..c68d83a9da 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -745,7 +745,7 @@ def refund_payment def create @competition = competition_from_params - unless @competition.registration_is_open? || @competition.user_can_pre_register?(current_user) + unless @competition.registration_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 diff --git a/app/models/competition.rb b/app/models/competition.rb index 819ec0ad6c..87d2d31a71 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -476,7 +476,7 @@ def warnings_for(user) end end - if self.registration_full? && self.registration_is_open? + if self.registration_full? && self.registration_open? warnings[:waiting_list] = registration_full_message end @@ -725,7 +725,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_is_open? || user_can_pre_register?(user)) + uses_new_registration_service? && user.cannot_register_for_competition_reasons(self).empty? && (registration_open? || user_can_pre_register?(user)) end before_validation :unpack_delegate_organizer_ids @@ -953,11 +953,7 @@ def can_edit_registration_fees? true end - def registration_opened? - use_wca_registration? && !cancelled? && !registration_not_yet_opened? - end - - def registration_is_open? + def registration_open? use_wca_registration? && !cancelled? && !registration_not_yet_opened? && !registration_past? end @@ -1376,7 +1372,7 @@ def can_be_cancelled? end def orga_can_close_reg_full_limit? - registration_full? && registration_is_open? + registration_full? && registration_open? end def display_name(short: false) @@ -1842,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_is_open? + methods: %w[url website short_name city venue_address venue_details latitude_degrees longitude_degrees country_iso2 event_ids registration_open? main_event_id number_of_bookmarks using_payment_integrations? uses_qualification? uses_cutoff? competition_series_ids registration_full?], include: %w[delegates organizers], } diff --git a/app/models/registration.rb b/app/models/registration.rb index e273434baa..dfc2f62e46 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -144,11 +144,11 @@ def to_be_paid_through_wca? end def show_payment_form? - competition.registration_is_open? && to_be_paid_through_wca? + competition.registration_open? && to_be_paid_through_wca? end def show_details?(user) - (competition.registration_is_open? || !(new_or_deleted?)) || (competition.user_can_pre_register?(user)) + (competition.registration_open? || !(new_or_deleted?)) || (competition.user_can_pre_register?(user)) end def record_payment( diff --git a/app/views/competitions/_nav.html.erb b/app/views/competitions/_nav.html.erb index 5497d03bc9..f4c343283d 100644 --- a/app/views/competitions/_nav.html.erb +++ b/app/views/competitions/_nav.html.erb @@ -126,7 +126,7 @@ icon: "align left", } end - if !EnvConfig.WCA_LIVE_SITE? && current_user&.can_manage_competition?(@competition) && !@competition.uses_new_registration_service? && !@competition.registration_is_open? + if !EnvConfig.WCA_LIVE_SITE? && current_user&.can_manage_competition?(@competition) && !@competition.uses_new_registration_service? && !@competition.registration_open? nav_items << { text: t('.menu.enable_v2'), path: enable_v2_path(@competition), diff --git a/app/views/registrations/register.html.erb b/app/views/registrations/register.html.erb index 277cf0f3ec..ca6b3a3885 100644 --- a/app/views/registrations/register.html.erb +++ b/app/views/registrations/register.html.erb @@ -53,7 +53,7 @@ <%= t 'registrations.contact_organizer' %> <% end %>
- <% elsif @competition.registration_is_open? %> + <% elsif @competition.registration_open? %> <% unless user_may_register %> <%= alert :danger do %> <%= t 'registrations.please_fix_profile_html', comp: @competition.name, diff --git a/app/webpacker/components/RegistrationsV2/Register/CompetingStep.jsx b/app/webpacker/components/RegistrationsV2/Register/CompetingStep.jsx index 95a2345981..73f9f05f61 100644 --- a/app/webpacker/components/RegistrationsV2/Register/CompetingStep.jsx +++ b/app/webpacker/components/RegistrationsV2/Register/CompetingStep.jsx @@ -29,7 +29,7 @@ const maxCommentLength = 240; const potentialWarnings = (competitionInfo) => { const warnings = []; // Organizer Pre Registration - if (!competitionInfo['registration_is_open?']) { + if (!competitionInfo['registration_open?']) { warnings.push(i18n.t('competitions.registration_v2.register.early_registration')); } // Favourites Competition From 0001fce738949d41ab679e4dfa85bd7083f90735 Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 7 Aug 2024 10:05:23 +0200 Subject: [PATCH 11/14] removed change to register tab visibility --- app/views/competitions/_nav.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/competitions/_nav.html.erb b/app/views/competitions/_nav.html.erb index f4c343283d..fe3379cf9e 100644 --- a/app/views/competitions/_nav.html.erb +++ b/app/views/competitions/_nav.html.erb @@ -133,7 +133,7 @@ icon: "lightbulb", } end - if @competition.announced? && !@competition.results_posted? + unless @competition.results_posted? if @competition.use_wca_registration? nav_items << { text: t('.menu.register'), From 1565c2a849442f6abcf32d44a869ed2089e0cd04 Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 7 Aug 2024 10:38:25 +0200 Subject: [PATCH 12/14] fix tests --- app/models/competition.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/competition.rb b/app/models/competition.rb index 87d2d31a71..68385f17fa 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -1180,7 +1180,8 @@ def registration_delete_after_acceptance_allowed? errors.add(:refund_policy_limit_date, I18n.t('competitions.errors.refund_date_after_start')) end - if registration_period_required? && registration_open? && registration_close? && (registration_open >= start_date || registration_close >= start_date) + if registration_period_required? && registration_open.present? && registration_close.present? && + (registration_open >= start_date || registration_close >= start_date) errors.add(:registration_close, I18n.t('competitions.errors.registration_period_after_start')) end end From 6b8a6dc36b4910026e64dd6a029031b052500c0d Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 7 Aug 2024 10:39:03 +0200 Subject: [PATCH 13/14] rubocop --- app/models/competition.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/competition.rb b/app/models/competition.rb index 68385f17fa..7e5a68bf13 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -1181,7 +1181,7 @@ def registration_delete_after_acceptance_allowed? end if registration_period_required? && registration_open.present? && registration_close.present? && - (registration_open >= start_date || registration_close >= start_date) + (registration_open >= start_date || registration_close >= start_date) errors.add(:registration_close, I18n.t('competitions.errors.registration_period_after_start')) end end From 3328123bf0e4afee7388ce91d69e74f555dfa46c Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 7 Aug 2024 15:18:54 +0200 Subject: [PATCH 14/14] switched to registration_currently_open? --- app/controllers/api/v0/competitions_controller.rb | 2 +- app/controllers/competitions_controller.rb | 2 +- app/controllers/registrations_controller.rb | 2 +- app/models/competition.rb | 10 +++++----- app/models/registration.rb | 4 ++-- app/views/competitions/_nav.html.erb | 2 +- app/views/registrations/register.html.erb | 2 +- .../RegistrationsV2/Register/CompetingStep.jsx | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/controllers/api/v0/competitions_controller.rb b/app/controllers/api/v0/competitions_controller.rb index 5a48ef02ff..66fd30a0e4 100644 --- a/app/controllers/api/v0/competitions_controller.rb +++ b/app/controllers/api/v0/competitions_controller.rb @@ -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_open? + methods: %w[url website short_name city venue_address venue_details latitude_degrees longitude_degrees country_iso2 event_ids registration_currently_open? main_event_id number_of_bookmarks using_payment_integrations? uses_qualification? uses_cutoff? competition_series_ids], include: %w[delegates organizers tabs], } diff --git a/app/controllers/competitions_controller.rb b/app/controllers/competitions_controller.rb index 1b99f74c0a..d93530106b 100644 --- a/app/controllers/competitions_controller.rb +++ b/app/controllers/competitions_controller.rb @@ -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_open? + if EnvConfig.WCA_LIVE_SITE? || @competition.registration_currently_open? flash.now[:danger] = t('competitions.messages.cannot_activate_v2') return redirect_to competition_path(@competition) end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index c68d83a9da..3308d91f58 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -745,7 +745,7 @@ def refund_payment def create @competition = competition_from_params - unless @competition.registration_open? || @competition.user_can_pre_register?(current_user) + unless @competition.registration_currently_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 diff --git a/app/models/competition.rb b/app/models/competition.rb index 7e5a68bf13..4b22b8f087 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -476,7 +476,7 @@ def warnings_for(user) end end - if self.registration_full? && self.registration_open? + if self.registration_full? && self.registration_currently_open? warnings[:waiting_list] = registration_full_message end @@ -725,7 +725,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_open? || user_can_pre_register?(user)) + uses_new_registration_service? && user.cannot_register_for_competition_reasons(self).empty? && (registration_currently_open? || user_can_pre_register?(user)) end before_validation :unpack_delegate_organizer_ids @@ -953,7 +953,7 @@ def can_edit_registration_fees? true end - def registration_open? + def registration_currently_open? use_wca_registration? && !cancelled? && !registration_not_yet_opened? && !registration_past? end @@ -1373,7 +1373,7 @@ def can_be_cancelled? end def orga_can_close_reg_full_limit? - registration_full? && registration_open? + registration_full? && registration_currently_open? end def display_name(short: false) @@ -1839,7 +1839,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_open? + methods: %w[url website short_name city venue_address venue_details latitude_degrees longitude_degrees country_iso2 event_ids registration_currently_open? main_event_id number_of_bookmarks using_payment_integrations? uses_qualification? uses_cutoff? competition_series_ids registration_full?], include: %w[delegates organizers], } diff --git a/app/models/registration.rb b/app/models/registration.rb index dfc2f62e46..6f4cfce8f3 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -144,11 +144,11 @@ def to_be_paid_through_wca? end def show_payment_form? - competition.registration_open? && to_be_paid_through_wca? + competition.registration_currently_open? && to_be_paid_through_wca? end def show_details?(user) - (competition.registration_open? || !(new_or_deleted?)) || (competition.user_can_pre_register?(user)) + (competition.registration_currently_open? || !(new_or_deleted?)) || (competition.user_can_pre_register?(user)) end def record_payment( diff --git a/app/views/competitions/_nav.html.erb b/app/views/competitions/_nav.html.erb index fe3379cf9e..2d7b67f9c4 100644 --- a/app/views/competitions/_nav.html.erb +++ b/app/views/competitions/_nav.html.erb @@ -126,7 +126,7 @@ icon: "align left", } end - if !EnvConfig.WCA_LIVE_SITE? && current_user&.can_manage_competition?(@competition) && !@competition.uses_new_registration_service? && !@competition.registration_open? + if !EnvConfig.WCA_LIVE_SITE? && current_user&.can_manage_competition?(@competition) && !@competition.uses_new_registration_service? && !@competition.registration_currently_open? nav_items << { text: t('.menu.enable_v2'), path: enable_v2_path(@competition), diff --git a/app/views/registrations/register.html.erb b/app/views/registrations/register.html.erb index ca6b3a3885..c492cb988d 100644 --- a/app/views/registrations/register.html.erb +++ b/app/views/registrations/register.html.erb @@ -53,7 +53,7 @@ <%= t 'registrations.contact_organizer' %> <% end %>
- <% elsif @competition.registration_open? %> + <% elsif @competition.registration_currently_open? %> <% unless user_may_register %> <%= alert :danger do %> <%= t 'registrations.please_fix_profile_html', comp: @competition.name, diff --git a/app/webpacker/components/RegistrationsV2/Register/CompetingStep.jsx b/app/webpacker/components/RegistrationsV2/Register/CompetingStep.jsx index 73f9f05f61..1f40b23278 100644 --- a/app/webpacker/components/RegistrationsV2/Register/CompetingStep.jsx +++ b/app/webpacker/components/RegistrationsV2/Register/CompetingStep.jsx @@ -29,7 +29,7 @@ const maxCommentLength = 240; const potentialWarnings = (competitionInfo) => { const warnings = []; // Organizer Pre Registration - if (!competitionInfo['registration_open?']) { + if (!competitionInfo['registration_currently_open?']) { warnings.push(i18n.t('competitions.registration_v2.register.early_registration')); } // Favourites Competition