Skip to content

Commit

Permalink
only show warnings in non react pages
Browse files Browse the repository at this point in the history
  • Loading branch information
FinnIckler committed Dec 11, 2024
1 parent d4df2ba commit 91b2a5d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
5 changes: 2 additions & 3 deletions app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion app/models/competition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion app/views/competitions/_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>

Expand Down

0 comments on commit 91b2a5d

Please sign in to comment.