mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-17 05:15:36 +00:00
Error page for generating matches, cannot have more than 16 for Pool to bracket tournaments
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
class TournamentsController < ApplicationController
|
class TournamentsController < ApplicationController
|
||||||
before_action :set_tournament, only: [:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:remove_delegate,:school_delegate,:delegate,:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:brackets,:generate_matches,:bracket,:all_brackets]
|
before_action :set_tournament, only: [:error,:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:remove_delegate,:school_delegate,:delegate,:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:brackets,:generate_matches,:bracket,:all_brackets]
|
||||||
before_filter :check_access_manage, only: [:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:school_delegate,:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:generate_matches,:matches]
|
before_filter :check_access_manage, only: [:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:school_delegate,:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:generate_matches,:matches]
|
||||||
before_filter :check_access_destroy, only: [:destroy,:delegate,:remove_delegate]
|
before_filter :check_access_destroy, only: [:destroy,:delegate,:remove_delegate]
|
||||||
|
before_filter :check_tournament_errors, only: [:generate_matches]
|
||||||
before_filter :check_for_matches, only: [:up_matches,:bracket,:all_brackets]
|
before_filter :check_for_matches, only: [:up_matches,:bracket,:all_brackets]
|
||||||
|
|
||||||
def remove_teampointadjust
|
def remove_teampointadjust
|
||||||
@@ -230,6 +230,9 @@ class TournamentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def error
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_tournament
|
def set_tournament
|
||||||
@@ -257,4 +260,13 @@ class TournamentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_tournament_errors
|
||||||
|
if @tournament.tournamentMatchGenerationError != nil
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to "/tournaments/#{@tournament.id}/error" }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -109,4 +109,26 @@ class Tournament < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def poolToBracketWeightsWithTooManyWrestlers
|
||||||
|
if self.tournament_type == "Pool to bracket"
|
||||||
|
weights.select{|w| w.wrestlers.size > 16}
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def tournamentMatchGenerationError
|
||||||
|
errorString = "There is a tournament error."
|
||||||
|
if poolToBracketWeightsWithTooManyWrestlers != nil
|
||||||
|
errorString = errorString + " The following weights have too many wrestlers "
|
||||||
|
poolToBracketWeightsWithTooManyWrestlers.each do |w|
|
||||||
|
errorString = errorString + "#{w.max} "
|
||||||
|
end
|
||||||
|
return errorString
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
3
app/views/tournaments/error.html.erb
Normal file
3
app/views/tournaments/error.html.erb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default" %>
|
||||||
|
<br><br>
|
||||||
|
<%= @tournament.tournamentMatchGenerationError %>
|
||||||
@@ -49,6 +49,7 @@ Wrestling::Application.routes.draw do
|
|||||||
get 'tournaments/:id/teampointadjust' => 'tournaments#teampointadjust'
|
get 'tournaments/:id/teampointadjust' => 'tournaments#teampointadjust'
|
||||||
post 'tournaments/:id/teampointadjust' => 'tournaments#teampointadjust'
|
post 'tournaments/:id/teampointadjust' => 'tournaments#teampointadjust'
|
||||||
delete 'tournaments/:id/:teampointadjust/remove_teampointadjust' => 'tournaments#remove_teampointadjust'
|
delete 'tournaments/:id/:teampointadjust/remove_teampointadjust' => 'tournaments#remove_teampointadjust'
|
||||||
|
get 'tournaments/:id/error' => 'tournaments#error'
|
||||||
|
|
||||||
# Example of regular route:
|
# Example of regular route:
|
||||||
# get 'products/:id' => 'catalog#view'
|
# get 'products/:id' => 'catalog#view'
|
||||||
|
|||||||
Reference in New Issue
Block a user