From 91b2a5d3d4518f94e2b0cd655d143e463546dfcd Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Wed, 11 Dec 2024 11:53:48 +0100 Subject: [PATCH] only show warnings in non react pages --- app/controllers/registrations_controller.rb | 5 ++--- app/models/competition.rb | 3 ++- app/views/competitions/_nav.html.erb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index c23293789e7..9489b31961f 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -261,9 +261,8 @@ def do_add def register @competition = competition_from_params - if current_user - @registration = @competition.registrations.find_or_initialize_by(user_id: current_user.id, competition_id: @competition.id) - end + # This page is in react so we don't want to show the warnings twice + @show_warnings = false end def payment_denomination diff --git a/app/models/competition.rb b/app/models/competition.rb index 7a918b4e4d1..f6d374389e2 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -492,7 +492,8 @@ def user_should_post_competition_results?(user) persisted? && is_probably_over? && !cancelled? && !self.results_submitted? && delegates.include?(user) end - def warnings_for(user) + # For react pages we do not want to show warnings as we show them in react + def warnings_for(user, show_warning=true) warnings = {} if self.showAtAll unless self.announced? diff --git a/app/views/competitions/_nav.html.erb b/app/views/competitions/_nav.html.erb index e0c862a5de5..73447aee818 100644 --- a/app/views/competitions/_nav.html.erb +++ b/app/views/competitions/_nav.html.erb @@ -267,7 +267,7 @@ <% end %> <% end %> - <% @competition.warnings_for(current_user).each do |field, message| %> + <% @competition.warnings_for(current_user, @show_warnings).each do |field, message| %> <%= alert :warning, message, note: true %> <% end %>