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 65573a3
Show file tree
Hide file tree
Showing 3 changed files with 7 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
5 changes: 4 additions & 1 deletion app/models/competition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,11 @@ 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_warnings=true)
warnings = {}
return warnings unless show_warnings

if self.showAtAll
unless self.announced?
warnings[:announcement] = I18n.t('competitions.messages.not_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 65573a3

Please sign in to comment.