1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-02 13:15:27 +00:00

Added is_public to a tournament to hide lineups and brackets until you're ready to make it public

This commit is contained in:
2023-01-01 23:16:12 -05:00
parent d675337d7a
commit c328bbd91c
15 changed files with 547 additions and 16 deletions

View File

@@ -4,6 +4,7 @@ class TournamentsController < ApplicationController
before_action :check_access_destroy, only: [:destroy,:delegate,:remove_delegate]
before_action :check_tournament_errors, only: [:generate_matches]
before_action :check_for_matches, only: [:up_matches,:bracket,:all_brackets]
before_action :check_access_read, only: [:up_matches,:bracket,:all_brackets]
def weigh_in_sheet
@@ -289,7 +290,7 @@ class TournamentsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def tournament_params
params.require(:tournament).permit(:name, :address, :director, :director_email, :tournament_type, :weigh_in_ref, :user_id, :date, :originalId, :swapId)
params.require(:tournament).permit(:name, :address, :director, :director_email, :tournament_type, :weigh_in_ref, :user_id, :date, :originalId, :swapId, :is_public)
end
#Check for tournament owner
@@ -301,6 +302,10 @@ class TournamentsController < ApplicationController
authorize! :manage, @tournament
end
def check_access_read
authorize! :read, @tournament
end
def check_for_matches
if @tournament
if @tournament.matches.empty? or @tournament.curently_generating_matches == 1